-
Notifications
You must be signed in to change notification settings - Fork 0
/
Windows.cpp
82 lines (73 loc) · 1.69 KB
/
Windows.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
#include "Windows.h"
#include "Windows.h"
Window::Window(HINSTANCE hInstance, int Show)
{
this->hInst = hInstance;
this->nCmdShow = Show;
}
Window* Window::NewWindow(HINSTANCE hInstance, int Show)
{
Window* pWindow = new Window(hInstance, Show);
if (pWindow != NULL) return pWindow;
return NULL;
}
BOOL Window::MyRegisterClassEx(const char* WindowClassName, WNDPROC lpfnWndProc)
{
HBRUSH hBrush = ::CreateSolidBrush(RGB(62, 71, 98));
WNDCLASSEX wndclass;
this->WindowClassName = WindowClassName;
HINSTANCE Inst = this->hInst;
if (!Inst)
{
ErrorCode = 30001;
return FALSE;
}
wndclass.cbClsExtra = 0;
wndclass.cbSize = sizeof(wndclass);
wndclass.cbWndExtra = 0;
wndclass.hbrBackground = hBrush;
wndclass.hCursor = 0;
wndclass.hIcon = 0;
wndclass.hIconSm = 0;
wndclass.lpfnWndProc = lpfnWndProc;
wndclass.lpszClassName = WindowClassName;
wndclass.lpszMenuName = 0;
wndclass.style = CS_HREDRAW | CS_VREDRAW;
wndclass.hInstance = Inst;
return RegisterClassEx(&wndclass);
}
HWND Window::MyCreateWindow(const char* WindowName, int x, int y, int Width, int Hght, DWORD WinowStly)
{
MARGINS Margin = { -1, -1, -1, -1 };
HINSTANCE Inst = this->hInst;
if (!Inst)
{
ErrorCode = 30001;
return NULL;
}
HWND hWnd = CreateWindowExA(WS_EX_TOPMOST | WS_EX_TRANSPARENT | WS_EX_LAYERED | WS_EX_TOOLWINDOW,
this->WindowClassName,
WindowName,
WS_POPUP,
x, y, Width, Hght,
0,
0,
Inst,
0);
ShowWindow(hWnd, SW_SHOW);
GetWindowRect(hWnd, &MyRect);
if (!WinowStly)
{
SetLayeredWindowAttributes(hWnd, 0, 0, 1);
DwmExtendFrameIntoClientArea(hWnd, &Margin);
}
return hWnd;
}
int Window::GetErrorCode()
{
return this->ErrorCode;
}
RECT Window::GetMyRect()
{
return this->MyRect;
}