0024166: Unable to create file with "Save" menu of voxeldemo Qt sample
[occt.git] / src / WNT / WNT_WClass.cxx
CommitLineData
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
dc3fe572 23#include <Standard_PCharacter.hxx>
7fd59977 24#include <InterfaceGraphic_WNT.hxx>
25
26#include <string.h>
27
28//=======================================================================
29//function : WNT_WClass
30//purpose :
31//=======================================================================
32
33WNT_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;
51 wc.cbWndExtra = aWindowExtra + sizeof ( WINDOW_DATA* );
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 );
67 lpfnWndProc = wc.lpfnWndProc;
68
69} // end constructor
70
71//=======================================================================
72//function : Destroy
73//purpose :
74//=======================================================================
75
76void WNT_WClass::Destroy ()
77{
78
79 UnregisterClass ( lpszName, ( HINSTANCE )hInstance );
80 delete [] (Standard_PCharacter)lpszName;
81
82} // end WNT_WClass :: Destroy
83