7fd59977 |
1 | // File: WNT_WClass.cxx |
2 | // Copyright: Open Cascade 2008 |
3 | |
4 | #include <windows.h> |
5 | #include <WNT_WClass.ixx> |
6 | |
7 | #include <InterfaceGraphic_WNT.hxx> |
8 | |
9 | #include <string.h> |
10 | |
11 | //======================================================================= |
12 | //function : WNT_WClass |
13 | //purpose : |
14 | //======================================================================= |
15 | |
16 | WNT_WClass::WNT_WClass ( |
17 | const Standard_CString aClassName, |
18 | const Standard_Address aWndProc, |
19 | const WNT_Uint& aStyle, |
20 | const Standard_Integer aClassExtra, |
21 | const Standard_Integer aWindowExtra, |
22 | const Aspect_Handle aCursor, |
23 | const Aspect_Handle anIcon, |
24 | const Standard_CString aMenuName |
25 | ) { |
26 | |
27 | WNDCLASS wc; |
28 | |
29 | hInstance = GetModuleHandle ( NULL ); |
30 | |
31 | wc.style = aStyle; |
32 | wc.lpfnWndProc = ( aWndProc ) ? ( WNDPROC )aWndProc : DefWindowProc; |
33 | wc.cbClsExtra = aClassExtra; |
34 | wc.cbWndExtra = aWindowExtra + sizeof ( WINDOW_DATA* ); |
35 | wc.hInstance = ( HINSTANCE )hInstance; |
36 | wc.hIcon = ( anIcon ) ? ( HICON )anIcon : |
37 | LoadIcon ( NULL, IDI_APPLICATION ); |
38 | wc.hCursor = ( aCursor ) ? ( HCURSOR )aCursor : |
39 | LoadCursor ( NULL, IDC_NO ); |
40 | wc.hbrBackground = 0; |
41 | wc.lpszMenuName = aMenuName; |
42 | wc.lpszClassName = aClassName; |
43 | |
44 | if ( !RegisterClass ( &wc ) ) |
45 | |
46 | WNT_ClassDefinitionError :: Raise ( "Unable to register window class" ); |
47 | |
48 | lpszName = new char[ strlen ( aClassName ) + 1 ]; |
49 | strcpy ( (Standard_PCharacter)lpszName, aClassName ); |
50 | lpfnWndProc = wc.lpfnWndProc; |
51 | |
52 | } // end constructor |
53 | |
54 | //======================================================================= |
55 | //function : Destroy |
56 | //purpose : |
57 | //======================================================================= |
58 | |
59 | void WNT_WClass::Destroy () |
60 | { |
61 | |
62 | UnregisterClass ( lpszName, ( HINSTANCE )hInstance ); |
63 | delete [] (Standard_PCharacter)lpszName; |
64 | |
65 | } // end WNT_WClass :: Destroy |
66 | |