-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.h
executable file
·86 lines (72 loc) · 1.99 KB
/
App.h
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#ifndef _H_APP
#define _H_APP
#include <windows.h>
class CGenericProc;
class CClass
{
public:
CClass (char const * szClassName, HINSTANCE hInst);
void SetCursor(int idCursor)
{
_class.hCursor = LoadCursor(_class.hInstance, (char*)idCursor);
}
void SetIcon(int idIcon)
{
_class.hIcon = LoadIcon(_class.hInstance, (char*)idIcon);
}
void SetMenu(int idMenu)
{
_class.lpszMenuName = (char*)idMenu;
}
void Register ()
{
::RegisterClass (&_class);
}
private:
WNDCLASS _class;
static LRESULT CALLBACK Procedure
(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);
};
class CWindow
{
public:
CWindow () : _hWnd(0)
{ }
CWindow (char const * szCaption, char const * szClass, HINSTANCE hInstance);
bool Create(CGenericProc* proc);
bool ProcessMessage();
void AttachAccelerator(int idAccel);
void Show (int iShowCmd = SW_SHOW)
{
::ShowWindow(_hWnd, iShowCmd);
::UpdateWindow(_hWnd);
}
void SetDimentions (int width, int height, bool bIsMenu = false)
{
RECT client = {0, 0, width, height};
AdjustWindowRect(&client, _style, bIsMenu);
_width = client.right - client.left;
_height = client.bottom - client.top;
}
HWND GetWnd()
{
return _hWnd;
}
protected:
void AddCreationData (void * data) { _data = data; }
HWND _hWnd;
HACCEL _hAccel;
HINSTANCE _hInstance;
char const * _szCaption;
char const * _szClass;
DWORD _exStyle; // extended window style
DWORD _style; // window style
int _x; // horizontal position of window
int _y; // vertical position of window
int _width; // window width
int _height; // window height
HWND _hWndParent; // handle to parent or owner window
HMENU _hMenu; // handle to menu, or child-window ID
void * _data; // pointer to window-creation data
};
#endif