X-Git-Url: http://git.osdn.net/view?p=dokopop%2Fdokopop.git;a=blobdiff_plain;f=DCHookTest%2FDCHookTest.cpp;fp=DCHookTest%2FDCHookTest.cpp;h=59a035b29ef5ee8e873211ab7db108ebfbcd4236;hp=eec638cdb15a824dd4c435623725e2a0f3170b6a;hb=732ffbdb4ea0caeaf438f23a4612f597982de0b2;hpb=3d28ff4de645576add43272844f55b3f47b53a8d diff --git a/DCHookTest/DCHookTest.cpp b/DCHookTest/DCHookTest.cpp index eec638c..59a035b 100644 --- a/DCHookTest/DCHookTest.cpp +++ b/DCHookTest/DCHookTest.cpp @@ -23,8 +23,11 @@ USEUNIT("MonitorScale.cpp"); #include "DCHookMain.h" //--------------------------------------------------------------------------- +void SetDpiAware(); + WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int) { + SetDpiAware(); #if __PROTO SYSTEMTIME st; GetSystemTime(&st); @@ -65,4 +68,21 @@ WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int) } //--------------------------------------------------------------------------- +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("SetDpiAware failed: %d", GetLastError()); + } + } + FreeLibrary(hDll); +} +