-
Notifications
You must be signed in to change notification settings - Fork 0
/
WinClass.cpp
65 lines (58 loc) · 2.58 KB
/
WinClass.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#include "WinClass.h"
#include "resource.h"
#include <iostream>
void WinClass::SetDefaults ()
{
///Provide Reasonable default values
_class.cbSize = sizeof(WNDCLASSEX);
_class.style = 0;
_class.lpszClassName = GetName();
_class.hInstance = GetInstance();
_class.hIcon = ::LoadIcon(NULL, IDI_APPLICATION);;
_class.hIconSm = ::LoadIcon(NULL, IDI_APPLICATION);;
_class.lpszMenuName = 0;
_class.cbClsExtra = 0;
_class.cbWndExtra = 0;
_class.hbrBackground = reinterpret_cast<HBRUSH> (COLOR_WINDOW + 1);
_class.hCursor = ::LoadCursor(NULL, IDC_ARROW);
}
WinClass::WinClass(char const* className, HINSTANCE hInst, WNDPROC wndProc): WinSimpleClass(className, hInst)
{
_class.lpfnWndProc = wndProc;
SetDefaults();
}
WinClass::WinClass(int resId, HINSTANCE hInst, WNDPROC wndProc): WinSimpleClass(resId, hInst)
{
_class.lpfnWndProc = wndProc;
SetDefaults();
}
void WinClass::SetMenu(int resId)
{
_class.lpszMenuName = MAKEINTRESOURCE(resId);
}
void WinClass::SetResIcons(int resId)
{
_class.hIcon = reinterpret_cast<HICON>(::LoadImage(_class.hInstance,
MAKEINTRESOURCE(resId),
IMAGE_ICON,
::GetSystemMetrics (SM_CXICON), //The default width of an icon, in pixels. The LoadIcon function can load only icons with the dimensions that SM_CXICON and SM_CYICON specifies
::GetSystemMetrics(SM_CYICON),
0));
///Small icon can be loaded from the same resource
_class.hIconSm = reinterpret_cast<HICON>(::LoadImage(_class.hInstance,
MAKEINTRESOURCE(resId),
IMAGE_ICON,
::GetSystemMetrics(SM_CXSMICON), //The recommended width of a small icon, in pixels. Small icons typically appear in window captions and in small icon view
::GetSystemMetrics(SM_CYSMICON),
0));
}
void WinClass::setCursor(int ID)
{
_class.hCursor = (HCURSOR) ::LoadImage(_class.hInstance ,MAKEINTRESOURCE(ID),IMAGE_ICON, 190,301, LR_LOADTRANSPARENT);
if(_class.hCursor == NULL)
MessageBox(NULL,"Image for card not loaded","Cursor not loaded", MB_ICONEXCLAMATION | MB_OK);
}
bool WinClass::Register()
{
return ::RegisterClassEx(&_class);
}