-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
50 lines (41 loc) · 1.64 KB
/
main.cpp
File metadata and controls
50 lines (41 loc) · 1.64 KB
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 <Windows.h>
#include "GDIWindow.h"
#include "DWriteWindow.h"
#include "UWPWindow.h"
#include <wil/result_macros.h>
#include "WinUI3Window.h"
#include "SettingsWindow.h"
static auto getPrimaryMonitorRect()
{
MONITORINFO info{ .cbSize = sizeof(info) };
winrt::check_bool(GetMonitorInfo(MonitorFromPoint({}, MONITOR_DEFAULTTOPRIMARY), &info));
return info.rcWork;
}
int main()
{
THROW_IF_WIN32_BOOL_FALSE(SetProcessDpiAwarenessContext(DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2));
winrt::init_apartment(winrt::apartment_type::single_threaded);
winrt::hstring text{ L"微软雅黑" };
//WinUI3 window must be created before UWP window
WinUI3Window winui3Window{ text };
SettingsWindow settings;
GDIWindow gdiWindow{ text };
DWriteWindow dwriteWindow{ text};
UWPWindow uwpWindow{ text };
settings << gdiWindow << dwriteWindow << uwpWindow << winui3Window;
//Set all display windows to 4 quadrants
auto const monitorRect = getPrimaryMonitorRect();
auto const halfWidth = (monitorRect.right - monitorRect.left) / 2;
auto const halfHeight = (monitorRect.bottom - monitorRect.top) / 2;
gdiWindow.SetPosition(0, 0, halfWidth, halfHeight, 0);
dwriteWindow.SetPosition(halfWidth, 0, halfWidth, halfHeight, 0);
uwpWindow.SetPosition(0, halfHeight, halfWidth, halfHeight, 0);
winui3Window.SetPosition(halfWidth, halfHeight, halfWidth, halfHeight, 0);
settings.SetPosition((monitorRect.right - monitorRect.left - halfWidth) / 2, (monitorRect.bottom - monitorRect.top) / 2 + 200, halfWidth, (monitorRect.bottom - monitorRect.top) / 3, 0);
MSG msg = { };
while (GetMessage(&msg, NULL, 0, 0) > 0)
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}