0030948: Configuration, CMake - problem building with CMake 3.15.2
[occt.git] / src / Draw / MainWindow.cxx
... / ...
CommitLineData
1// Created on: 1998-08-06
2// Created by: Administrateur Atelier MDL
3// Copyright (c) 1998-1999 Matra Datavision
4// Copyright (c) 1999-2014 OPEN CASCADE SAS
5//
6// This file is part of Open CASCADE Technology software library.
7//
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
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.
13//
14// Alternatively, this file may be used under the terms of Open CASCADE
15// commercial license or contractual agreement.
16
17#ifdef _WIN32
18
19#include <windows.h>
20#include <DrawRessource.h>
21#include <init.h>
22#include <Draw_Window.hxx>
23
24#include <MainWindow.h>
25#include <CommandWindow.h>
26
27Standard_Boolean Draw_Interprete(const char* command); // Implemented in Draw.cxx
28extern Standard_Boolean Draw_IsConsoleSubsystem;
29
30//extern "C" int compat_unlink(const char *fname); // Implemente dans TCL
31
32/*--------------------------------------------------------*\
33| CLIENT WINDOW PROCEDURE
34|
35|
36\*--------------------------------------------------------*/
37LRESULT APIENTRY WndProc(HWND hWndFrame, UINT wMsg, WPARAM wParam, LPARAM lParam )
38{
39 switch (wMsg)
40 {
41 case WM_CREATE:
42 {
43 CreateProc (hWndFrame);
44 HWND hWndClient = (HWND )GetWindowLongPtrW (hWndFrame, CLIENTWND);
45 DrawWindow::hWndClientMDI = hWndClient;
46 if (!Draw_IsConsoleSubsystem)
47 {
48 CreateCommandWindow (hWndFrame, 0);
49 }
50 return 0;
51 }
52 case WM_COMMAND:
53 {
54 CmdProc (hWndFrame, LOWORD(wParam), wParam, lParam);
55 return 0;
56 }
57 case WM_DESTROY:
58 {
59 Draw_Interprete ("exit");
60 DestroyProc (hWndFrame);
61 return 0;
62 }
63 }
64 HWND hWndClient = (HWND)GetWindowLongPtrW(hWndFrame, CLIENTWND);
65 return DefFrameProcW(hWndFrame, hWndClient, wMsg, wParam, lParam);
66}
67
68
69/*--------------------------------------------------------------------------*\
70| CLIENT CREATE PROCEDURE
71| Handler for message WM_CREATE. Creation of control window MDI
72|
73\*--------------------------------------------------------------------------*/
74BOOL CreateProc(HWND hWndFrame)
75{
76 HWND hWnd = CreateMDIClientWindow (hWndFrame);
77 if (hWnd != NULL)
78 {
79 // Save hWnd in the main window in extra memory in 0
80 SetWindowLongPtrW (hWndFrame, CLIENTWND, (LONG_PTR)hWnd);
81 }
82 return(TRUE);
83}
84
85
86/*--------------------------------------------------------------------------*\
87| COMMAND PROCEDURE
88| Handler for message WM_COMMAND
89| It is used when Draw_IsConsoleSubsystem = Standard_False
90| i.e. in non-console mode (see Draw_main() in Draw_Main.cxx).
91\*--------------------------------------------------------------------------*/
92LRESULT APIENTRY CmdProc(HWND hWndFrame, UINT wMsg, WPARAM /*wParam*/, LPARAM /*lParam*/)
93{
94 // Handle on window MDI
95 HWND hWndClient = (HWND )GetWindowLongPtrW (hWndFrame, CLIENTWND);
96 switch (wMsg)
97 {
98 case IDM_WINDOW_NEXT:
99 {
100 if (hWndClient != NULL)
101 {
102 HWND hWndActive = (HWND )SendMessageW (hWndClient, WM_MDIGETACTIVE, 0, 0l);
103 SendMessageW (hWndClient, WM_MDINEXT, (WPARAM )hWndActive, 0l);
104 }
105 break;
106 }
107 case IDM_WINDOW_CASCADE:
108 {
109 if (hWndClient != NULL)
110 {
111 SendMessageW (hWndClient, WM_MDICASCADE, 0, 0l);
112 }
113 break;
114 }
115 case IDM_WINDOW_TILEHOR:
116 {
117 if (hWndClient != NULL)
118 {
119 SendMessageW (hWndClient, WM_MDITILE, MDITILE_HORIZONTAL, 0l);
120 }
121 break;
122 }
123 case IDM_WINDOW_TILEVERT:
124 {
125 if (hWndClient != NULL)
126 {
127 SendMessageW (hWndClient, WM_MDITILE, MDITILE_VERTICAL, 0l);
128 }
129 break;
130 }
131 case IDM_FILE_EXIT:
132 {
133 Draw_Interprete ("exit");
134 DestroyProc (hWndFrame);
135 break;
136 }
137 }
138 return 0;
139}
140
141
142/*--------------------------------------------------------------------------*\
143| CLIENT DESTROY PROCEDURE
144| Handler for message WM_DESTROY.
145|
146\*--------------------------------------------------------------------------*/
147VOID DestroyProc(HWND hWnd)
148{
149 HINSTANCE hInst = (HINSTANCE )GetWindowLongPtrW (hWnd, GWLP_HINSTANCE);
150
151 Destroy_Appli(hInst);
152 PostQuitMessage(0);
153}
154#endif
155