OSDN Git Service

[U] 高DPIモニター対応の強化
[dokopop/dokopop.git] / DCHook64 / dchk64 / dchk64.cpp
index 8812dd7..8fe8595 100644 (file)
@@ -35,6 +35,7 @@ void Cleanup();
 LRESULT CALLBACK       WndProc(HWND, UINT, WPARAM, LPARAM);
 
 int atox( const TCHAR *str, TCHAR **next );
+void SetDpiAware();
 
 int APIENTRY _tWinMain(HINSTANCE hInstance,
                      HINSTANCE hPrevInstance,
@@ -47,6 +48,8 @@ int APIENTRY _tWinMain(HINSTANCE hInstance,
        MSG msg;
        HACCEL hAccelTable;
 
+       SetDpiAware();
+
        // \83O\83\8d\81[\83o\83\8b\95\8e\9a\97ñ\82ð\8f\89\8aú\89»\82µ\82Ä\82¢\82Ü\82·\81B
        LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
        LoadString(hInstance, IDC_DCHK64, szWindowClass, MAX_LOADSTRING);
@@ -334,3 +337,21 @@ HANDLE WinExecEx( const char *cmd, int show, const char *dir, const char *title
                return NULL;
        return pi.hProcess;
 }
+
+typedef WINUSERAPI BOOL (WINAPI *FNSetProcessDpiAwarenessContext)(UINT_PTR vaule);
+#define        DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2      ((UINT_PTR)-4)
+void SetDpiAware()
+{
+       HINSTANCE hDll = LoadLibrary( _T("user32") );
+       if (!hDll)
+               return;
+       FNSetProcessDpiAwarenessContext fnSetProcessDpiAwarenessContext = (FNSetProcessDpiAwarenessContext)GetProcAddress(hDll, "SetProcessDpiAwarenessContext");
+       if (fnSetProcessDpiAwarenessContext){
+               if (fnSetProcessDpiAwarenessContext(DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2)){
+               } else {
+                       DBW("x64-SetDpiAware failed: %d", GetLastError());
+               }
+       }
+       FreeLibrary(hDll);
+}
+