Skip to content

Commit

Permalink
・[fix] 高DPI環境で、スタートを押した瞬間ウィンドウの拡大スケーリングが解除される問題を修正
Browse files Browse the repository at this point in the history
  • Loading branch information
amate committed Oct 8, 2021
1 parent 7cd0ff5 commit 2211c9c
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 7 deletions.
2 changes: 1 addition & 1 deletion UmaCruise/AboutDlg.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class PreviewWindow;
#define DEBUG_STRING
#endif

constexpr LPCWSTR kAppVersion = L"v1.15" DEBUG_STRING;
constexpr LPCWSTR kAppVersion = L"v1.15.1" DEBUG_STRING;

class CAboutDlg : public CDialogImpl<CAboutDlg>, DarkModeUI<CAboutDlg>
{
Expand Down
8 changes: 4 additions & 4 deletions UmaCruise/DesktopDuplication.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,12 @@ class DesktopDuplication
m_lastHwndTarget = hwndTarget;
m_lastTargetHWNDMonitorName = monitorInfo.szDevice;

CComPtr<IDXGIFactory> factory;
CreateDXGIFactory(__uuidof(IDXGIFactory), reinterpret_cast<void**>(&factory));
CComPtr<IDXGIFactory1> factory;
CreateDXGIFactory1(__uuidof(IDXGIFactory1), reinterpret_cast<void**>(&factory));

// 全ディスプレイアダプタを調べる
CComPtr<IDXGIAdapter> adapter;
for (int i = 0; (factory->EnumAdapters(i, &adapter) != DXGI_ERROR_NOT_FOUND); ++i)
CComPtr<IDXGIAdapter1> adapter;
for (int i = 0; (factory->EnumAdapters1(i, &adapter) != DXGI_ERROR_NOT_FOUND); ++i)
{
// アウトプットを一通り調べてメインモニタを探す
CComPtr<IDXGIOutput> output;
Expand Down
9 changes: 9 additions & 0 deletions UmaCruise/UmaCruise.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,15 @@ int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/, LPTSTR lp
g_funcSetThreadDpiAwarenessContext(DPI_AWARENESS_CONTEXT_UNAWARE_GDISCALED);
}

// https://stackoverflow.com/questions/63855309/process-unexpectedly-dpi-aware
// DuplicateOutput が勝手に SetProcessDpiAwarenessContext を呼ぶ対策
using SetProcessDpiAwarenessContextFunc = BOOL(*)(_In_ DPI_AWARENESS_CONTEXT value);
auto funcSetProcessDpiAwarenessContext = (SetProcessDpiAwarenessContextFunc)::GetProcAddress(hModUser32, "SetProcessDpiAwarenessContext");
if (funcSetProcessDpiAwarenessContext) {
BOOL b = funcSetProcessDpiAwarenessContext(DPI_AWARENESS_CONTEXT_UNAWARE_GDISCALED);
}


InitDarkMode();

int nRet = Run(lpstrCmdLine, nCmdShow);
Expand Down
2 changes: 1 addition & 1 deletion UmaCruise/UmaTextRecognizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ std::unique_ptr<Gdiplus::Bitmap> UmaTextRecognizer::ScreenShot()
return nullptr;
}

CWindowDC dc(NULL/*hWndTarget*/); // desktop
//CWindowDC dc(NULL/*hWndTarget*/); // desktop

if (g_funcSetThreadDpiAwarenessContext) { // 高DPIモニターで取得ウィンドウの位置がずれるバグを回避するため
g_funcSetThreadDpiAwarenessContext(DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2);
Expand Down
2 changes: 1 addition & 1 deletion appversion.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v1.15
v1.15.1
3 changes: 3 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,9 @@ https://www.kiigo.jp/disp/CSfGoodsPage_001.jsp?GOODS_NO=9

<pre>

v1.15.1
・[fix] 高DPI環境で、スタートを押した瞬間ウィンドウの拡大スケーリングが解除される問題を修正

v1.15
・[change] ウマ娘ウィンドウの画面取り込みを GDIを使ったものから Desktop Duplication APIを使ったものに変更
・[change] レース予約の通知を、日付変更時ではなく、育成画面になったときに行うように変更 #78
Expand Down

0 comments on commit 2211c9c

Please sign in to comment.