dokopop source repository
Revision | 732ffbdb4ea0caeaf438f23a4612f597982de0b2 (tree) |
---|---|
Time | 2021-08-27 10:28:22 |
Author | tnishi <sgm00353@nift...> |
Commiter | tnishi |
[U] 高DPIモニター対応の強化
@@ -35,6 +35,7 @@ void Cleanup(); | ||
35 | 35 | LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); |
36 | 36 | |
37 | 37 | int atox( const TCHAR *str, TCHAR **next ); |
38 | +void SetDpiAware(); | |
38 | 39 | |
39 | 40 | int APIENTRY _tWinMain(HINSTANCE hInstance, |
40 | 41 | HINSTANCE hPrevInstance, |
@@ -47,6 +48,8 @@ int APIENTRY _tWinMain(HINSTANCE hInstance, | ||
47 | 48 | MSG msg; |
48 | 49 | HACCEL hAccelTable; |
49 | 50 | |
51 | + SetDpiAware(); | |
52 | + | |
50 | 53 | // グローバル文字列を初期化しています。 |
51 | 54 | LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING); |
52 | 55 | LoadString(hInstance, IDC_DCHK64, szWindowClass, MAX_LOADSTRING); |
@@ -334,3 +337,21 @@ HANDLE WinExecEx( const char *cmd, int show, const char *dir, const char *title | ||
334 | 337 | return NULL; |
335 | 338 | return pi.hProcess; |
336 | 339 | } |
340 | + | |
341 | +typedef WINUSERAPI BOOL (WINAPI *FNSetProcessDpiAwarenessContext)(UINT_PTR vaule); | |
342 | +#define DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2 ((UINT_PTR)-4) | |
343 | +void SetDpiAware() | |
344 | +{ | |
345 | + HINSTANCE hDll = LoadLibrary( _T("user32") ); | |
346 | + if (!hDll) | |
347 | + return; | |
348 | + FNSetProcessDpiAwarenessContext fnSetProcessDpiAwarenessContext = (FNSetProcessDpiAwarenessContext)GetProcAddress(hDll, "SetProcessDpiAwarenessContext"); | |
349 | + if (fnSetProcessDpiAwarenessContext){ | |
350 | + if (fnSetProcessDpiAwarenessContext(DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2)){ | |
351 | + } else { | |
352 | + DBW("x64-SetDpiAware failed: %d", GetLastError()); | |
353 | + } | |
354 | + } | |
355 | + FreeLibrary(hDll); | |
356 | +} | |
357 | + |
@@ -23,8 +23,11 @@ USEUNIT("MonitorScale.cpp"); | ||
23 | 23 | #include "DCHookMain.h" |
24 | 24 | //--------------------------------------------------------------------------- |
25 | 25 | |
26 | +void SetDpiAware(); | |
27 | + | |
26 | 28 | WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int) |
27 | 29 | { |
30 | + SetDpiAware(); | |
28 | 31 | #if __PROTO |
29 | 32 | SYSTEMTIME st; |
30 | 33 | GetSystemTime(&st); |
@@ -65,4 +68,21 @@ WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int) | ||
65 | 68 | } |
66 | 69 | //--------------------------------------------------------------------------- |
67 | 70 | |
71 | +typedef WINUSERAPI BOOL (WINAPI *FNSetProcessDpiAwarenessContext)(UINT_PTR vaule); | |
72 | +#define DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2 ((UINT_PTR)-4) | |
73 | +void SetDpiAware() | |
74 | +{ | |
75 | + HINSTANCE hDll = LoadLibrary( _T("user32") ); | |
76 | + if (!hDll) | |
77 | + return; | |
78 | + FNSetProcessDpiAwarenessContext fnSetProcessDpiAwarenessContext = (FNSetProcessDpiAwarenessContext)GetProcAddress(hDll, "SetProcessDpiAwarenessContext"); | |
79 | + if (fnSetProcessDpiAwarenessContext){ | |
80 | + if (fnSetProcessDpiAwarenessContext(DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2)){ | |
81 | + } else { | |
82 | + DBW("SetDpiAware failed: %d", GetLastError()); | |
83 | + } | |
84 | + } | |
85 | + FreeLibrary(hDll); | |
86 | +} | |
87 | + | |
68 | 88 |