b311480e |
1 | // Copyright (c) 1996-1999 Matra Datavision |
973c2be1 |
2 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
b311480e |
3 | // |
973c2be1 |
4 | // This file is part of Open CASCADE Technology software library. |
b311480e |
5 | // |
d5f74e42 |
6 | // This library is free software; you can redistribute it and/or modify it under |
7 | // the terms of the GNU Lesser General Public License version 2.1 as published |
973c2be1 |
8 | // by the Free Software Foundation, with special exception defined in the file |
9 | // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT |
10 | // distribution for complete text of the license and disclaimer of any warranty. |
b311480e |
11 | // |
973c2be1 |
12 | // Alternatively, this file may be used under the terms of Open CASCADE |
13 | // commercial license or contractual agreement. |
7fd59977 |
14 | |
15 | #include <windows.h> |
7fd59977 |
16 | |
42cf5bc1 |
17 | #include <Standard_PCharacter.hxx> |
18 | #include <Standard_Type.hxx> |
19 | #include <WNT_ClassDefinitionError.hxx> |
20 | #include <WNT_WClass.hxx> |
21 | #include <WNT_Window.hxx> |
7fd59977 |
22 | |
23 | #include <string.h> |
92efcf78 |
24 | IMPLEMENT_STANDARD_RTTIEXT(WNT_WClass,MMgt_TShared) |
25 | |
7fd59977 |
26 | //======================================================================= |
27 | //function : WNT_WClass |
28 | //purpose : |
29 | //======================================================================= |
7fd59977 |
30 | WNT_WClass::WNT_WClass ( |
31 | const Standard_CString aClassName, |
32 | const Standard_Address aWndProc, |
33 | const WNT_Uint& aStyle, |
34 | const Standard_Integer aClassExtra, |
35 | const Standard_Integer aWindowExtra, |
36 | const Aspect_Handle aCursor, |
37 | const Aspect_Handle anIcon, |
38 | const Standard_CString aMenuName |
39 | ) { |
40 | |
41 | WNDCLASS wc; |
42 | |
43 | hInstance = GetModuleHandle ( NULL ); |
44 | |
45 | wc.style = aStyle; |
46 | wc.lpfnWndProc = ( aWndProc ) ? ( WNDPROC )aWndProc : DefWindowProc; |
47 | wc.cbClsExtra = aClassExtra; |
eaf5c5e0 |
48 | wc.cbWndExtra = aWindowExtra; |
7fd59977 |
49 | wc.hInstance = ( HINSTANCE )hInstance; |
50 | wc.hIcon = ( anIcon ) ? ( HICON )anIcon : |
51 | LoadIcon ( NULL, IDI_APPLICATION ); |
52 | wc.hCursor = ( aCursor ) ? ( HCURSOR )aCursor : |
53 | LoadCursor ( NULL, IDC_NO ); |
54 | wc.hbrBackground = 0; |
55 | wc.lpszMenuName = aMenuName; |
56 | wc.lpszClassName = aClassName; |
57 | |
58 | if ( !RegisterClass ( &wc ) ) |
59 | |
60 | WNT_ClassDefinitionError :: Raise ( "Unable to register window class" ); |
61 | |
62 | lpszName = new char[ strlen ( aClassName ) + 1 ]; |
63 | strcpy ( (Standard_PCharacter)lpszName, aClassName ); |
7c65581d |
64 | lpfnWndProc = (void* )wc.lpfnWndProc; |
7fd59977 |
65 | |
66 | } // end constructor |
67 | |
68 | //======================================================================= |
e6f550da |
69 | //function : ~WNT_WClass |
7fd59977 |
70 | //purpose : |
71 | //======================================================================= |
72 | |
e6f550da |
73 | WNT_WClass::~WNT_WClass () |
7fd59977 |
74 | { |
75 | |
76 | UnregisterClass ( lpszName, ( HINSTANCE )hInstance ); |
77 | delete [] (Standard_PCharacter)lpszName; |
78 | |
79 | } // end WNT_WClass :: Destroy |
80 | |