0028110: Configuration - specify Unicode charset instead of multibyte in project...
[occt.git] / src / Draw / init.cxx
CommitLineData
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.
7fd59977 16
57c28b61 17#ifdef _WIN32
7fd59977 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|
36d\*--------------------------------------------------------*/
37
38BOOL RegisterAppClass(HINSTANCE hInstance)
39{
ad03c234 40 WNDCLASSW wndClass;
7fd59977 41
42 // Parametres communs aux classes
43 //-----
44 wndClass.style = CS_HREDRAW | CS_VREDRAW | CS_CLASSDC;
45 wndClass.cbClsExtra = 0;
ad03c234 46 wndClass.hCursor = LoadCursorW (NULL, IDC_ARROW);
7fd59977 47 wndClass.hInstance = hInstance;
48
49 // Enregistrement de la fenetre principale
50 //-----
ad03c234 51 wndClass.cbWndExtra = sizeof(void*);
7fd59977 52 wndClass.lpfnWndProc = (WNDPROC)WndProc;
ad03c234 53 wndClass.hIcon = (HICON )LoadIconW (hInstance, MAKEINTRESOURCE(IDI_ICON1));
7fd59977 54 wndClass.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH);
ad03c234 55 wndClass.lpszMenuName = MAKEINTRESOURCEW(APPMENU);
7fd59977 56 wndClass.lpszClassName = APPCLASS;
57
ad03c234 58 if(!RegisterClassW(&wndClass))
7fd59977 59 return(FALSE);
60
61 // Enregistrement de la fenetre DrawWindow
62 //------
ad03c234 63 wndClass.cbWndExtra = sizeof(void*); // Extra Memory
7fd59977 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
ad03c234 70 if(!RegisterClassW(&wndClass))
7fd59977 71 {
ad03c234 72 UnregisterClassW(APPCLASS, hInstance);
7fd59977 73 return(FALSE);
74 }
75
76
77 // Enregistrement de la fenetre CommandWindow
78 //------
ad03c234 79 wndClass.lpfnWndProc = (WNDPROC)CommandProc;
7fd59977 80 wndClass.hIcon = 0;
81 wndClass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
82 wndClass.lpszMenuName = NULL;
83 wndClass.lpszClassName = COMMANDCLASS;
84
ad03c234 85 if(!RegisterClassW(&wndClass))
7fd59977 86 {
ad03c234 87 UnregisterClassW(APPCLASS, hInstance);
88 UnregisterClassW(DRAWCLASS, hInstance);
7fd59977 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\*--------------------------------------------------------*/
101VOID UnregisterAppClass(HINSTANCE hInstance)
102{
ad03c234 103 UnregisterClassW(APPCLASS, hInstance);
104 UnregisterClassW(DRAWCLASS, hInstance);
7fd59977 105}
106
107
108/*--------------------------------------------------------*\
109| CREATE APPLICATION WINDOW
110| Creation de la fenetre Top-Level
111|
112\*--------------------------------------------------------*/
113HWND CreateAppWindow(HINSTANCE hInstance)
114{
ad03c234 115 return(CreateWindowW(APPCLASS, APPTITLE,
7fd59977 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\*--------------------------------------------------------*/
128HWND 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
ad03c234 138 hInstance = (HANDLE)GetWindowLongPtrW(hWndFrame, GWLP_HINSTANCE);
7fd59977 139
ad03c234 140 hWndClient = CreateWindowW(L"MDICLIENT",NULL,
7fd59977 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