0027067: Avoid use of virtual methods for implementation of destructors in legacy...
[occt.git] / src / WNT / WNT_WClass.cxx
1 // Copyright (c) 1996-1999 Matra Datavision
2 // Copyright (c) 1999-2014 OPEN CASCADE SAS
3 //
4 // This file is part of Open CASCADE Technology software library.
5 //
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
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.
11 //
12 // Alternatively, this file may be used under the terms of Open CASCADE
13 // commercial license or contractual agreement.
14
15 #include <windows.h>
16
17
18 #include <InterfaceGraphic.hxx>
19 #include <Standard_PCharacter.hxx>
20 #include <Standard_Type.hxx>
21 #include <WNT_ClassDefinitionError.hxx>
22 #include <WNT_WClass.hxx>
23 #include <WNT_Window.hxx>
24
25 #include <string.h>
26 IMPLEMENT_STANDARD_RTTIEXT(WNT_WClass,MMgt_TShared)
27
28 //=======================================================================
29 //function : WNT_WClass
30 //purpose  : 
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;
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 : ~WNT_WClass
72 //purpose  : 
73 //=======================================================================
74
75 WNT_WClass::~WNT_WClass ()
76 {
77
78  UnregisterClass (  lpszName, ( HINSTANCE )hInstance  );
79  delete [] (Standard_PCharacter)lpszName;
80
81 }  // end WNT_WClass :: Destroy
82