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 | |
1ce0716b |
17 | #include <WNT_WClass.hxx> |
18 | |
42cf5bc1 |
19 | #include <Standard_PCharacter.hxx> |
20 | #include <Standard_Type.hxx> |
21 | #include <WNT_ClassDefinitionError.hxx> |
42cf5bc1 |
22 | #include <WNT_Window.hxx> |
7fd59977 |
23 | |
1ce0716b |
24 | #if defined(_WIN32) && !defined(OCCT_UWP) |
25 | |
7fd59977 |
26 | #include <string.h> |
92efcf78 |
27 | IMPLEMENT_STANDARD_RTTIEXT(WNT_WClass,MMgt_TShared) |
28 | |
7fd59977 |
29 | //======================================================================= |
30 | //function : WNT_WClass |
31 | //purpose : |
32 | //======================================================================= |
7fd59977 |
33 | WNT_WClass::WNT_WClass ( |
34 | const Standard_CString aClassName, |
35 | const Standard_Address aWndProc, |
36 | const WNT_Uint& aStyle, |
37 | const Standard_Integer aClassExtra, |
38 | const Standard_Integer aWindowExtra, |
39 | const Aspect_Handle aCursor, |
40 | const Aspect_Handle anIcon, |
41 | const Standard_CString aMenuName |
42 | ) { |
43 | |
44 | WNDCLASS wc; |
45 | |
46 | hInstance = GetModuleHandle ( NULL ); |
47 | |
48 | wc.style = aStyle; |
49 | wc.lpfnWndProc = ( aWndProc ) ? ( WNDPROC )aWndProc : DefWindowProc; |
50 | wc.cbClsExtra = aClassExtra; |
eaf5c5e0 |
51 | wc.cbWndExtra = aWindowExtra; |
7fd59977 |
52 | wc.hInstance = ( HINSTANCE )hInstance; |
53 | wc.hIcon = ( anIcon ) ? ( HICON )anIcon : |
54 | LoadIcon ( NULL, IDI_APPLICATION ); |
55 | wc.hCursor = ( aCursor ) ? ( HCURSOR )aCursor : |
56 | LoadCursor ( NULL, IDC_NO ); |
57 | wc.hbrBackground = 0; |
58 | wc.lpszMenuName = aMenuName; |
59 | wc.lpszClassName = aClassName; |
60 | |
61 | if ( !RegisterClass ( &wc ) ) |
62 | |
63 | WNT_ClassDefinitionError :: Raise ( "Unable to register window class" ); |
64 | |
65 | lpszName = new char[ strlen ( aClassName ) + 1 ]; |
66 | strcpy ( (Standard_PCharacter)lpszName, aClassName ); |
7c65581d |
67 | lpfnWndProc = (void* )wc.lpfnWndProc; |
7fd59977 |
68 | |
69 | } // end constructor |
70 | |
71 | //======================================================================= |
e6f550da |
72 | //function : ~WNT_WClass |
7fd59977 |
73 | //purpose : |
74 | //======================================================================= |
75 | |
e6f550da |
76 | WNT_WClass::~WNT_WClass () |
7fd59977 |
77 | { |
78 | |
79 | UnregisterClass ( lpszName, ( HINSTANCE )hInstance ); |
80 | delete [] (Standard_PCharacter)lpszName; |
81 | |
82 | } // end WNT_WClass :: Destroy |
83 | |
1ce0716b |
84 | #endif // _WIN32 |