-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathCWin.cpp
119 lines (98 loc) · 2.81 KB
/
CWin.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
#include "CWin.h"
#include <tchar.h>
//////////////////////////////////////////////////////////////////
// Static Initialisatie
//////////////////////////////////////////////////////////////////
static CWin * g_pCWin = NULL;
HINSTANCE CWin::m_hInstance = GetModuleHandle(NULL);
//////////////////////////////////////////////////////////////////
// Koppeling WIN32 -> Klasse
//////////////////////////////////////////////////////////////////
LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
return g_pCWin->MsgProc(hWnd, uMsg, wParam, lParam);
}
//////////////////////////////////////////////////////////////////
// Constructors/Destructors
//////////////////////////////////////////////////////////////////
CWin::CWin()
{
g_pCWin = this;
this->m_hWnd = NULL;
this->m_dwCreationFlags = 0L;
this->m_dwWindowStyle = WS_OVERLAPPEDWINDOW;
this->m_dwExWindowStyle = WS_EX_OVERLAPPEDWINDOW;
this->m_dwCreationFlags = SW_SHOW;
this->m_PosX = CW_USEDEFAULT;
this->m_PosY = CW_USEDEFAULT;
this->m_dwCreationWidth = CW_USEDEFAULT;
this->m_dwCreationHeight = CW_USEDEFAULT;
this->m_hbrWindowColor = (HBRUSH)(COLOR_WINDOW+1);
this->m_hIcon = LoadIcon(m_hInstance, (LPCTSTR)IDI_APPLICATION);
this->m_strWindowTitle = _T("Skelet Programma HI Blok 1.4");
this->m_hMenu = NULL;
}
CWin::~CWin()
{
}
//////////////////////////////////////////////////////////////////
// Methoden
//////////////////////////////////////////////////////////////////
int CWin::Run()
{
MSG msg;
while (GetMessage(&msg, NULL, 0, 0))
{
if (!TranslateAccelerator(msg.hwnd, m_hAccelTable, &msg))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
} return msg.wParam;
}
HRESULT CWin::Create()
{
WNDCLASSEX wcex;
wcex.cbSize = sizeof(WNDCLASSEX);
wcex.style = CS_HREDRAW | CS_VREDRAW;
wcex.lpfnWndProc = (WNDPROC)WndProc;
wcex.cbClsExtra = 0;
wcex.cbWndExtra = 0;
wcex.hInstance = m_hInstance;
wcex.hIcon = m_hIcon;
wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
wcex.hbrBackground = m_hbrWindowColor;
wcex.lpszMenuName = NULL;
wcex.lpszClassName = _T("window");
wcex.hIconSm = NULL;
::RegisterClassEx(&wcex);
m_hWnd = ::CreateWindowEx(m_dwExWindowStyle,_T("window"), m_strWindowTitle, m_dwWindowStyle,
m_PosX, m_PosY, m_dwCreationWidth, m_dwCreationHeight, NULL, m_hMenu, m_hInstance, NULL);
if (!m_hWnd)
{
return FALSE;
}
::ShowWindow(m_hWnd, m_dwCreationFlags);
::UpdateWindow(m_hWnd);
return TRUE;
}
LRESULT CWin::MsgProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
int wmId;
int wmEvent;
if (!m_hWnd)
m_hWnd = hWnd;
switch (uMsg)
{
case WM_COMMAND:
wmId = LOWORD(wParam);
wmEvent = HIWORD(wParam);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hWnd, uMsg, wParam, lParam);
}
return 0;
}