0024057: Eliminate compiler warning C4100 in MSVC++ with warning level 4
[occt.git] / src / Draw / MainWindow.cxx
1 // Created on: 1998-08-06
2 // Created by: Administrateur Atelier MDL
3 // Copyright (c) 1998-1999 Matra Datavision
4 // Copyright (c) 1999-2012 OPEN CASCADE SAS
5 //
6 // The content of this file is subject to the Open CASCADE Technology Public
7 // License Version 6.5 (the "License"). You may not use the content of this file
8 // except in compliance with the License. Please obtain a copy of the License
9 // at http://www.opencascade.org and read it completely before using this file.
10 //
11 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
12 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
13 //
14 // The Original Code and all software distributed under the License is
15 // distributed on an "AS IS" basis, without warranty of any kind, and the
16 // Initial Developer hereby disclaims all such warranties, including without
17 // limitation, any warranties of merchantability, fitness for a particular
18 // purpose or non-infringement. Please see the License for the specific terms
19 // and conditions governing the rights and limitations under the License.
20
21
22
23
24 #ifdef WNT
25
26
27 #include <windows.h>
28 #include <DrawRessource.h>
29 #include <init.h>
30 #include <MainWindow.h>
31 #include <Draw_Window.hxx>
32 #include <CommandWindow.h>
33
34 Standard_Boolean Draw_Interprete(const char* command); // Implemented in Draw.cxx
35 extern Standard_Boolean Draw_IsConsoleSubsystem;
36
37 //extern "C" int  compat_unlink(const char *fname); // Implemente dans TCL
38
39 /*--------------------------------------------------------*\
40 |  CLIENT WINDOW PROCEDURE
41 |
42 |
43 \*--------------------------------------------------------*/
44 LRESULT APIENTRY WndProc(HWND hWndFrame, UINT wMsg, WPARAM wParam, LPARAM lParam )
45 {
46   HWND hWndClient;      
47   switch(wMsg)
48   {
49     case WM_CREATE :
50       {
51         CreateProc(hWndFrame);                                  
52         hWndClient = (HWND)GetWindowLong(hWndFrame, CLIENTWND);
53         DrawWindow::hWndClientMDI = hWndClient;
54         if (!Draw_IsConsoleSubsystem)
55           CreateCommandWindow(hWndFrame,0);                                     
56       }
57       break;
58
59     case WM_COMMAND :
60       CommandProc(hWndFrame, wParam, lParam);
61       break;
62       
63     case WM_DESTROY :
64       Draw_Interprete("exit");
65       DestroyProc(hWndFrame);                                                           
66       break;
67
68     default :
69       hWndClient = (HWND)GetWindowLong(hWndFrame, CLIENTWND);
70       return(DefFrameProc(hWndFrame, hWndClient, wMsg, wParam, lParam));
71   }
72   return(0l);
73 }
74
75
76 /*--------------------------------------------------------------------------*\
77 |  CLIENT CREATE PROCEDURE
78 |     Handler for message WM_CREATE. Creation of control window MDI
79 |
80 \*--------------------------------------------------------------------------*/
81 BOOL CreateProc(HWND hWndFrame)
82 {
83   HWND hWnd;
84
85   // Save hWnd in the main window in extra memory in 0
86   if (hWnd = CreateMDIClientWindow(hWndFrame))
87     SetWindowLong(hWndFrame, CLIENTWND, (LONG)hWnd);
88   return(TRUE);
89 }
90
91
92 /*--------------------------------------------------------------------------*\
93 |  COMMAND PROCEDURE
94 |               Handler for message WM_COMMAND   
95 |
96 \*--------------------------------------------------------------------------*/
97 BOOL CommandProc(HWND hWndFrame, WPARAM wParam, LPARAM /*lParam*/)
98 {
99   HWND hWndClient; // Handle on window MDI
100   HWND hWndActive;
101
102         hWndClient = (HWND)GetWindowLong(hWndFrame, CLIENTWND);
103   switch (LOWORD(wParam))
104         {
105           case IDM_WINDOW_NEXT :
106                                         if(hWndClient = (HWND)GetWindowLong(hWndFrame, CLIENTWND))
107                                           hWndActive = (HWND)SendMessage(hWndClient, WM_MDIGETACTIVE, 0, 0l);
108                                                 SendMessage(hWndClient, WM_MDINEXT, (WPARAM)hWndActive, 0l);  
109                                         break;
110
111                 case IDM_WINDOW_CASCADE :
112                                         if(hWndClient = (HWND)GetWindowLong(hWndFrame, CLIENTWND))
113                                                 SendMessage(hWndClient, WM_MDICASCADE, 0, 0l);
114                                         break;
115                                          
116                 case IDM_WINDOW_TILEHOR :
117                                         if(hWndClient = (HWND)GetWindowLong(hWndFrame, CLIENTWND))
118                                                 SendMessage(hWndClient, WM_MDITILE, MDITILE_HORIZONTAL, 0l);
119                                         break;
120
121                 case IDM_WINDOW_TILEVERT :
122                                         if(hWndClient = (HWND)GetWindowLong(hWndFrame, CLIENTWND))
123                                                 SendMessage(hWndClient, WM_MDITILE, MDITILE_VERTICAL, 0l);
124                                         break;
125                 
126                 case IDM_FILE_EXIT :
127                                         Draw_Interprete("exit");
128                                         //compat_unlink(NULL);
129
130                                         DestroyProc(hWndFrame);
131                                         break;
132         }
133   return(TRUE);
134 }
135
136
137 /*--------------------------------------------------------------------------*\
138 |  CLIENT DESTROY PROCEDURE
139 |     Handler for message WM_DESTROY.
140 |
141 \*--------------------------------------------------------------------------*/
142 VOID DestroyProc(HWND hWnd)
143 {
144 #ifndef _WIN64
145   HINSTANCE hInst = (HINSTANCE)GetWindowLong(hWnd, GWL_HINSTANCE);
146 #else
147   HINSTANCE hInst = (HINSTANCE)GetWindowLong(hWnd, GWLP_HINSTANCE);
148 #endif
149   Destroy_Appli(hInst);
150   PostQuitMessage(0);
151 }
152 #endif
153