• R/O
  • HTTP
  • SSH
  • HTTPS

dokopop: Commit

dokopop source repository


Commit MetaInfo

Revision732ffbdb4ea0caeaf438f23a4612f597982de0b2 (tree)
Time2021-08-27 10:28:22
Authortnishi <sgm00353@nift...>
Commitertnishi

Log Message

[U] 高DPIモニター対応の強化

Change Summary

Incremental Difference

--- a/DCHook64/dchk64/dchk64.cpp
+++ b/DCHook64/dchk64/dchk64.cpp
@@ -35,6 +35,7 @@ void Cleanup();
3535 LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
3636
3737 int atox( const TCHAR *str, TCHAR **next );
38+void SetDpiAware();
3839
3940 int APIENTRY _tWinMain(HINSTANCE hInstance,
4041 HINSTANCE hPrevInstance,
@@ -47,6 +48,8 @@ int APIENTRY _tWinMain(HINSTANCE hInstance,
4748 MSG msg;
4849 HACCEL hAccelTable;
4950
51+ SetDpiAware();
52+
5053 // グローバル文字列を初期化しています。
5154 LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
5255 LoadString(hInstance, IDC_DCHK64, szWindowClass, MAX_LOADSTRING);
@@ -334,3 +337,21 @@ HANDLE WinExecEx( const char *cmd, int show, const char *dir, const char *title
334337 return NULL;
335338 return pi.hProcess;
336339 }
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+
--- a/DCHookTest/DCHookTest.cpp
+++ b/DCHookTest/DCHookTest.cpp
@@ -23,8 +23,11 @@ USEUNIT("MonitorScale.cpp");
2323 #include "DCHookMain.h"
2424 //---------------------------------------------------------------------------
2525
26+void SetDpiAware();
27+
2628 WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
2729 {
30+ SetDpiAware();
2831 #if __PROTO
2932 SYSTEMTIME st;
3033 GetSystemTime(&st);
@@ -65,4 +68,21 @@ WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
6568 }
6669 //---------------------------------------------------------------------------
6770
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+
6888
Show on old repository browser