0026371: Implementation of new entities for GD&T
[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 WNT
18
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
26Standard_Boolean Draw_Interprete(const char* command); // Implemented in Draw.cxx
27extern 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\*--------------------------------------------------------*/
36LRESULT APIENTRY WndProc(HWND hWndFrame, UINT wMsg, WPARAM wParam, LPARAM lParam )
37{
38 HWND hWndClient;
39 switch(wMsg)
40 {
41 case WM_CREATE :
42 {
43 CreateProc(hWndFrame);
44 hWndClient = (HWND)GetWindowLongPtr(hWndFrame, CLIENTWND);
45 DrawWindow::hWndClientMDI = hWndClient;
46 if (!Draw_IsConsoleSubsystem)
47 CreateCommandWindow(hWndFrame,0);
48 }
49 break;
50
51 case WM_COMMAND :
52 CommandProc(hWndFrame, wParam, lParam);
53 break;
54
55 case WM_DESTROY :
56 Draw_Interprete("exit");
57 DestroyProc(hWndFrame);
58 break;
59
60 default :
61 hWndClient = (HWND)GetWindowLongPtr(hWndFrame, CLIENTWND);
62 return(DefFrameProc(hWndFrame, hWndClient, wMsg, wParam, lParam));
63 }
64 return(0l);
65}
66
67
68/*--------------------------------------------------------------------------*\
69| CLIENT CREATE PROCEDURE
70| Handler for message WM_CREATE. Creation of control window MDI
71|
72\*--------------------------------------------------------------------------*/
73BOOL CreateProc(HWND hWndFrame)
74{
75 HWND hWnd = CreateMDIClientWindow (hWndFrame);
76 if (hWnd != NULL)
77 {
78 // Save hWnd in the main window in extra memory in 0
79 SetWindowLongPtr(hWndFrame, CLIENTWND, (LONG_PTR)hWnd);
80 }
81 return(TRUE);
82}
83
84
85/*--------------------------------------------------------------------------*\
86| COMMAND PROCEDURE
87| Handler for message WM_COMMAND
88|
89\*--------------------------------------------------------------------------*/
90BOOL CommandProc(HWND hWndFrame, WPARAM wParam, LPARAM /*lParam*/)
91{
92 // Handle on window MDI
93 HWND hWndClient = (HWND)GetWindowLongPtr (hWndFrame, CLIENTWND);
94 switch (LOWORD(wParam))
95 {
96 case IDM_WINDOW_NEXT :
97 if(hWndClient)
98 {
99 HWND hWndActive = (HWND)SendMessage(hWndClient, WM_MDIGETACTIVE, 0, 0l);
100 SendMessage(hWndClient, WM_MDINEXT, (WPARAM)hWndActive, 0l);
101 }
102 break;
103
104 case IDM_WINDOW_CASCADE :
105 if(hWndClient)
106 SendMessage(hWndClient, WM_MDICASCADE, 0, 0l);
107 break;
108
109 case IDM_WINDOW_TILEHOR :
110 if(hWndClient)
111 SendMessage(hWndClient, WM_MDITILE, MDITILE_HORIZONTAL, 0l);
112 break;
113
114 case IDM_WINDOW_TILEVERT :
115 if(hWndClient)
116 SendMessage(hWndClient, WM_MDITILE, MDITILE_VERTICAL, 0l);
117 break;
118
119 case IDM_FILE_EXIT :
120 Draw_Interprete("exit");
121 //compat_unlink(NULL);
122
123 DestroyProc(hWndFrame);
124 break;
125 }
126 return(TRUE);
127}
128
129
130/*--------------------------------------------------------------------------*\
131| CLIENT DESTROY PROCEDURE
132| Handler for message WM_DESTROY.
133|
134\*--------------------------------------------------------------------------*/
135VOID DestroyProc(HWND hWnd)
136{
137 HINSTANCE hInst = (HINSTANCE)GetWindowLongPtr(hWnd, GWLP_HINSTANCE);
138
139 Destroy_Appli(hInst);
140 PostQuitMessage(0);
141}
142#endif
143