0027067: Avoid use of virtual methods for implementation of destructors in legacy...
[occt.git] / src / WNT / WNT_WClass.cxx
CommitLineData
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
42cf5bc1 17
eaf5c5e0 18#include <InterfaceGraphic.hxx>
42cf5bc1 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>
7fd59977 24
25#include <string.h>
92efcf78 26IMPLEMENT_STANDARD_RTTIEXT(WNT_WClass,MMgt_TShared)
27
7fd59977 28//=======================================================================
29//function : WNT_WClass
30//purpose :
31//=======================================================================
7fd59977 32WNT_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;
eaf5c5e0 50 wc.cbWndExtra = aWindowExtra;
7fd59977 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//=======================================================================
e6f550da 71//function : ~WNT_WClass
7fd59977 72//purpose :
73//=======================================================================
74
e6f550da 75WNT_WClass::~WNT_WClass ()
7fd59977 76{
77
78 UnregisterClass ( lpszName, ( HINSTANCE )hInstance );
79 delete [] (Standard_PCharacter)lpszName;
80
81} // end WNT_WClass :: Destroy
82