-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathExample.cpp
50 lines (41 loc) · 1.47 KB
/
Example.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
#include "EasyHWND.h"
class MyAngryWindow : public EasyHWND::Window {
public:
// Make it construct
MyAngryWindow(EasyHWND::WindowClass& refWndClass, EASYHWND_STR windowTitle, INT posX, INT posY, UINT width, UINT height,
DWORD style, DWORD exStyle = NULL, HMENU menue = NULL, HWND parentWindow = NULL, HINSTANCE hInstance = NULL) :
EasyHWND::Window(refWndClass, windowTitle, posX, posY, width, height, style, exStyle, menue, parentWindow, hInstance)
{}
protected:
virtual bool handleWindowMessage(LRESULT* ptrLRESULT, HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) override {
// I hate to be closed and will yell at you
if (msg == WM_CLOSE) {
MessageBox(hwnd, L"DONT YOU CLOSE ME", L"FU** NO", MB_ICONEXCLAMATION | MB_OK);
return true;
}
// Call parent!
return EasyHWND::Window::handleWindowMessage(ptrLRESULT, hwnd, msg, wParam, lParam);
}
};
// Main entry point
int main(int argc, char** argv) {
EasyHWND::WindowClass wc(L"MyWindowClass", CS_OWNDC, NULL, NULL, CreateSolidBrush(RGB(255, 0, 0)));
if (wc) {
MyAngryWindow w(wc, L"MyWindow", 100, 100, 500, 500, WS_OVERLAPPEDWINDOW);
if (w) {
unsigned int width = 500;
unsigned int height = 500;
w.adjustSizeForWindow(&width, &height);
w.setWindowSize(width, height);
w.setWindowVisibility(true);
MSG msg = {};
while (!w.checkWindowCloseFlag()) {
if (PeekMessage(&msg, (HWND)w, 0, 0, PM_REMOVE)) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
}
}
return 0;
}