b311480e |
1 | // Created on: 1998-08-06 |
2 | // Created by: Administrateur Atelier MDL |
3 | // Copyright (c) 1998-1999 Matra Datavision |
973c2be1 |
4 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
b311480e |
5 | // |
973c2be1 |
6 | // This file is part of Open CASCADE Technology software library. |
b311480e |
7 | // |
d5f74e42 |
8 | // This library is free software; you can redistribute it and/or modify it under |
9 | // the terms of the GNU Lesser General Public License version 2.1 as published |
973c2be1 |
10 | // by the Free Software Foundation, with special exception defined in the file |
11 | // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT |
12 | // distribution for complete text of the license and disclaimer of any warranty. |
b311480e |
13 | // |
973c2be1 |
14 | // Alternatively, this file may be used under the terms of Open CASCADE |
15 | // commercial license or contractual agreement. |
b311480e |
16 | |
57c28b61 |
17 | #ifdef _WIN32 |
7fd59977 |
18 | |
7fd59977 |
19 | #include <windows.h> |
20 | #include <DrawRessource.h> |
21 | #include <init.h> |
22 | #include <MainWindow.h> |
23 | #include <Draw_Window.hxx> |
24 | #include <CommandWindow.h> |
25 | |
bf03eb83 |
26 | Standard_Boolean Draw_Interprete(const char* command); // Implemented in Draw.cxx |
7fd59977 |
27 | extern Standard_Boolean Draw_IsConsoleSubsystem; |
28 | |
29 | //extern "C" int compat_unlink(const char *fname); // Implemente dans TCL |
30 | |
31 | /*--------------------------------------------------------*\ |
32 | | CLIENT WINDOW PROCEDURE |
33 | | |
34 | | |
35 | \*--------------------------------------------------------*/ |
6a7d83c4 |
36 | LRESULT APIENTRY WndProc(HWND hWndFrame, UINT wMsg, WPARAM wParam, LPARAM lParam ) |
7fd59977 |
37 | { |
38 | HWND hWndClient; |
39 | switch(wMsg) |
40 | { |
41 | case WM_CREATE : |
42 | { |
43 | CreateProc(hWndFrame); |
e89e2d67 |
44 | hWndClient = (HWND)GetWindowLongPtr(hWndFrame, CLIENTWND); |
7fd59977 |
45 | DrawWindow::hWndClientMDI = hWndClient; |
46 | if (!Draw_IsConsoleSubsystem) |
47 | CreateCommandWindow(hWndFrame,0); |
48 | } |
49 | break; |
50 | |
51 | case WM_COMMAND : |
839b8d3c |
52 | CmdProc(hWndFrame, LOWORD(wParam), wParam, lParam); |
7fd59977 |
53 | break; |
54 | |
55 | case WM_DESTROY : |
56 | Draw_Interprete("exit"); |
57 | DestroyProc(hWndFrame); |
58 | break; |
59 | |
60 | default : |
e89e2d67 |
61 | hWndClient = (HWND)GetWindowLongPtr(hWndFrame, CLIENTWND); |
7fd59977 |
62 | return(DefFrameProc(hWndFrame, hWndClient, wMsg, wParam, lParam)); |
63 | } |
64 | return(0l); |
65 | } |
66 | |
67 | |
68 | /*--------------------------------------------------------------------------*\ |
69 | | CLIENT CREATE PROCEDURE |
0d969553 |
70 | | Handler for message WM_CREATE. Creation of control window MDI |
7fd59977 |
71 | | |
72 | \*--------------------------------------------------------------------------*/ |
73 | BOOL CreateProc(HWND hWndFrame) |
74 | { |
773f53f1 |
75 | HWND hWnd = CreateMDIClientWindow (hWndFrame); |
76 | if (hWnd != NULL) |
77 | { |
78 | // Save hWnd in the main window in extra memory in 0 |
e89e2d67 |
79 | SetWindowLongPtr(hWndFrame, CLIENTWND, (LONG_PTR)hWnd); |
773f53f1 |
80 | } |
7fd59977 |
81 | return(TRUE); |
82 | } |
83 | |
84 | |
85 | /*--------------------------------------------------------------------------*\ |
86 | | COMMAND PROCEDURE |
0d969553 |
87 | | Handler for message WM_COMMAND |
839b8d3c |
88 | | It is used when Draw_IsConsoleSubsystem = Standard_False |
89 | | i.e. in non-console mode (see _main_() in Draw_Main.cxx). |
7fd59977 |
90 | \*--------------------------------------------------------------------------*/ |
839b8d3c |
91 | LRESULT APIENTRY CmdProc(HWND hWndFrame, UINT wMsg, WPARAM /*wParam*/, LPARAM /*lParam*/) |
7fd59977 |
92 | { |
773f53f1 |
93 | // Handle on window MDI |
e89e2d67 |
94 | HWND hWndClient = (HWND)GetWindowLongPtr (hWndFrame, CLIENTWND); |
839b8d3c |
95 | switch (wMsg) |
7fd59977 |
96 | { |
97 | case IDM_WINDOW_NEXT : |
773f53f1 |
98 | if(hWndClient) |
99 | { |
100 | HWND hWndActive = (HWND)SendMessage(hWndClient, WM_MDIGETACTIVE, 0, 0l); |
101 | SendMessage(hWndClient, WM_MDINEXT, (WPARAM)hWndActive, 0l); |
102 | } |
7fd59977 |
103 | break; |
104 | |
105 | case IDM_WINDOW_CASCADE : |
773f53f1 |
106 | if(hWndClient) |
7fd59977 |
107 | SendMessage(hWndClient, WM_MDICASCADE, 0, 0l); |
108 | break; |
109 | |
110 | case IDM_WINDOW_TILEHOR : |
773f53f1 |
111 | if(hWndClient) |
7fd59977 |
112 | SendMessage(hWndClient, WM_MDITILE, MDITILE_HORIZONTAL, 0l); |
113 | break; |
114 | |
115 | case IDM_WINDOW_TILEVERT : |
773f53f1 |
116 | if(hWndClient) |
7fd59977 |
117 | SendMessage(hWndClient, WM_MDITILE, MDITILE_VERTICAL, 0l); |
118 | break; |
119 | |
120 | case IDM_FILE_EXIT : |
121 | Draw_Interprete("exit"); |
122 | //compat_unlink(NULL); |
123 | |
124 | DestroyProc(hWndFrame); |
125 | break; |
839b8d3c |
126 | } |
127 | return(0l); |
7fd59977 |
128 | } |
129 | |
130 | |
131 | /*--------------------------------------------------------------------------*\ |
132 | | CLIENT DESTROY PROCEDURE |
0d969553 |
133 | | Handler for message WM_DESTROY. |
7fd59977 |
134 | | |
135 | \*--------------------------------------------------------------------------*/ |
136 | VOID DestroyProc(HWND hWnd) |
137 | { |
e89e2d67 |
138 | HINSTANCE hInst = (HINSTANCE)GetWindowLongPtr(hWnd, GWLP_HINSTANCE); |
139 | |
7fd59977 |
140 | Destroy_Appli(hInst); |
141 | PostQuitMessage(0); |
142 | } |
143 | #endif |
144 | |