0031668: Visualization - WebGL sample doesn't work on Emscripten 1.39
[occt.git] / src / Draw / init.cxx
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 first to have all definitions available
20 #include <windows.h>
21
22 #include "Draw_Window.hxx"
23 #include "DrawRessource.h"
24 #include "init.h"
25 #include "MainWindow.h"
26 #include "CommandWindow.h"
27
28
29 #define USEDEFAULT 200
30
31
32 /*--------------------------------------------------------*\
33 |  REGISTER APPLICATION CLASS
34 |  Enregistrement des classes de fenetres de l'application
35 |
36 d\*--------------------------------------------------------*/
37
38 BOOL RegisterAppClass(HINSTANCE hInstance)
39 {
40   WNDCLASSW wndClass;
41
42   // Parametres communs aux classes
43   //-----
44   wndClass.style         = CS_HREDRAW | CS_VREDRAW | CS_CLASSDC;
45   wndClass.cbClsExtra    = 0;
46   wndClass.hCursor       = LoadCursor (NULL, IDC_ARROW);
47   wndClass.hInstance     = hInstance;
48
49   // Enregistrement de la fenetre principale
50   //-----
51   wndClass.cbWndExtra    = sizeof(void*);
52   wndClass.lpfnWndProc   = (WNDPROC)WndProc;
53   wndClass.hIcon         = LoadIconW (hInstance, MAKEINTRESOURCEW(IDI_ICON1));
54   wndClass.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH);
55   wndClass.lpszMenuName  = MAKEINTRESOURCEW(APPMENU);
56   wndClass.lpszClassName = APPCLASS;
57
58   if(!RegisterClassW(&wndClass))
59     return(FALSE);
60
61   // Enregistrement de la fenetre DrawWindow
62   //------
63   wndClass.cbWndExtra    = sizeof(void*); // Extra Memory
64   wndClass.lpfnWndProc   = (WNDPROC)DrawWindow::DrawProc;
65   wndClass.hIcon         = 0;
66   wndClass.hbrBackground = (HBRUSH) GetStockObject(BLACK_BRUSH);
67   wndClass.lpszMenuName  = NULL;
68   wndClass.lpszClassName = DRAWCLASS;
69
70   if(!RegisterClassW(&wndClass))
71   {
72     UnregisterClassW(APPCLASS, hInstance);
73     return(FALSE);
74   }
75
76
77   // Enregistrement de la fenetre CommandWindow
78   //------
79   wndClass.lpfnWndProc   = (WNDPROC)CommandProc;
80   wndClass.hIcon         = 0;
81   wndClass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
82   wndClass.lpszMenuName  = NULL;
83   wndClass.lpszClassName = COMMANDCLASS;
84
85   if(!RegisterClassW(&wndClass))
86   {
87     UnregisterClassW(APPCLASS, hInstance);
88     UnregisterClassW(DRAWCLASS, hInstance);
89     return(FALSE);
90   }
91
92   return(TRUE);
93 }
94
95
96 /*--------------------------------------------------------*\
97 |  UNREGISTER APPLICATION CLASS
98 |    Suppression des classes de fenetres de l'application
99 |
100 \*--------------------------------------------------------*/
101 VOID UnregisterAppClass(HINSTANCE hInstance)
102 {
103   UnregisterClassW(APPCLASS, hInstance);
104   UnregisterClassW(DRAWCLASS, hInstance);
105 }
106
107
108 /*--------------------------------------------------------*\
109 |  CREATE APPLICATION WINDOW
110 |    Creation de la fenetre Top-Level
111 |
112 \*--------------------------------------------------------*/
113 HWND CreateAppWindow(HINSTANCE hInstance)
114 {
115   return(CreateWindowW(APPCLASS, APPTITLE,
116                             WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN,
117                             400,0,
118                             623,767,
119                             NULL, NULL, hInstance, NULL));
120 }
121
122
123 /*--------------------------------------------------------*\
124 |  CREATE MDI CLIENT WINDOW
125 |    Creation de la fenetre qui contient des fenetres MDI
126 |
127 \*--------------------------------------------------------*/
128 HWND CreateMDIClientWindow(HWND hWndFrame)
129 {
130   HWND               hWndClient;
131   HANDLE             hInstance;
132   CLIENTCREATESTRUCT ccs;
133
134   // Initialisation de la structure client
135   ccs.hWindowMenu = NULL;
136   ccs.idFirstChild = 0;
137
138   hInstance = (HANDLE)GetWindowLongPtrW(hWndFrame, GWLP_HINSTANCE);
139
140   hWndClient = CreateWindowW(L"MDICLIENT",NULL,
141                                                                                                 WS_CHILD | WS_CLIPSIBLINGS | 
142                                                                                                 WS_VISIBLE | MDIS_ALLCHILDSTYLES, 
143                                                                                                 0, 0, 1, 1,
144                                                                                                 hWndFrame, NULL, 
145                                                                                                 (HINSTANCE)hInstance, (LPVOID)&ccs);
146   return(hWndClient);
147 }
148 #endif