forked from ErectusTestus/ErectusExperimental
-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathWindow.hpp
45 lines (38 loc) · 1012 Bytes
/
Window.hpp
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
#pragma once
#include <map>
#include <Windows.h>
class App;
class Window
{
public:
enum class Styles
{
Unknown,
Standalone,
Attached,
Overlay
};
Window(App* appInstance, LPCSTR windowTitle);
~Window();
LRESULT __stdcall MsgProc(HWND hWnd, unsigned int msg, WPARAM wParam, LPARAM lParam) const;
[[nodiscard]] HWND GetHwnd() const { return mainWindow; }
void SetPosition(LONG x, LONG y) const;
[[nodiscard]] std::pair<LONG, LONG> GetSize() const;
void SetSize(LONG x, LONG y) const;
void SetStyle(Styles newStyle);
private:
void Init(LPCSTR windowTitle);
struct WndStyles
{
DWORD style;
DWORD styleEx;
};
const std::map<Styles, WndStyles> styles = {
{ Styles::Standalone, { WS_SYSMENU | WS_CAPTION, 0 } },
{ Styles::Attached, { WS_POPUP, WS_EX_TOPMOST } },
{ Styles::Overlay, { WS_POPUP, WS_EX_TOPMOST | WS_EX_LAYERED | WS_EX_TRANSPARENT } } //layered+transparent = clickthrough
};
Styles currentStyle = Styles::Unknown;
HWND mainWindow = nullptr;
App* const app;
};