b311480e |
1 | // Copyright (c) 1996-1999 Matra Datavision |
2 | // Copyright (c) 1999-2012 OPEN CASCADE SAS |
3 | // |
4 | // The content of this file is subject to the Open CASCADE Technology Public |
5 | // License Version 6.5 (the "License"). You may not use the content of this file |
6 | // except in compliance with the License. Please obtain a copy of the License |
7 | // at http://www.opencascade.org and read it completely before using this file. |
8 | // |
9 | // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its |
10 | // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. |
11 | // |
12 | // The Original Code and all software distributed under the License is |
13 | // distributed on an "AS IS" basis, without warranty of any kind, and the |
14 | // Initial Developer hereby disclaims all such warranties, including without |
15 | // limitation, any warranties of merchantability, fitness for a particular |
16 | // purpose or non-infringement. Please see the License for the specific terms |
17 | // and conditions governing the rights and limitations under the License. |
18 | |
7fd59977 |
19 | |
20 | #include <windows.h> |
21 | #include <WNT_WClass.ixx> |
22 | |
23 | #include <InterfaceGraphic_WNT.hxx> |
24 | |
25 | #include <string.h> |
26 | |
27 | //======================================================================= |
28 | //function : WNT_WClass |
29 | //purpose : |
30 | //======================================================================= |
31 | |
32 | WNT_WClass::WNT_WClass ( |
33 | const Standard_CString aClassName, |
34 | const Standard_Address aWndProc, |
35 | const WNT_Uint& aStyle, |
36 | const Standard_Integer aClassExtra, |
37 | const Standard_Integer aWindowExtra, |
38 | const Aspect_Handle aCursor, |
39 | const Aspect_Handle anIcon, |
40 | const Standard_CString aMenuName |
41 | ) { |
42 | |
43 | WNDCLASS wc; |
44 | |
45 | hInstance = GetModuleHandle ( NULL ); |
46 | |
47 | wc.style = aStyle; |
48 | wc.lpfnWndProc = ( aWndProc ) ? ( WNDPROC )aWndProc : DefWindowProc; |
49 | wc.cbClsExtra = aClassExtra; |
50 | wc.cbWndExtra = aWindowExtra + sizeof ( WINDOW_DATA* ); |
51 | wc.hInstance = ( HINSTANCE )hInstance; |
52 | wc.hIcon = ( anIcon ) ? ( HICON )anIcon : |
53 | LoadIcon ( NULL, IDI_APPLICATION ); |
54 | wc.hCursor = ( aCursor ) ? ( HCURSOR )aCursor : |
55 | LoadCursor ( NULL, IDC_NO ); |
56 | wc.hbrBackground = 0; |
57 | wc.lpszMenuName = aMenuName; |
58 | wc.lpszClassName = aClassName; |
59 | |
60 | if ( !RegisterClass ( &wc ) ) |
61 | |
62 | WNT_ClassDefinitionError :: Raise ( "Unable to register window class" ); |
63 | |
64 | lpszName = new char[ strlen ( aClassName ) + 1 ]; |
65 | strcpy ( (Standard_PCharacter)lpszName, aClassName ); |
66 | lpfnWndProc = wc.lpfnWndProc; |
67 | |
68 | } // end constructor |
69 | |
70 | //======================================================================= |
71 | //function : Destroy |
72 | //purpose : |
73 | //======================================================================= |
74 | |
75 | void WNT_WClass::Destroy () |
76 | { |
77 | |
78 | UnregisterClass ( lpszName, ( HINSTANCE )hInstance ); |
79 | delete [] (Standard_PCharacter)lpszName; |
80 | |
81 | } // end WNT_WClass :: Destroy |
82 | |