Skip to content

Commit 3ccd471

Browse files
committed
fix: 修复DPI缩放导致的Win32截图裁切
1 parent b5972de commit 3ccd471

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

source/MaaWin32ControlUnit/Manager/Win32ControlUnitMgr.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,18 @@ Win32ControlUnitMgr::Win32ControlUnitMgr(
3131

3232
bool Win32ControlUnitMgr::connect()
3333
{
34+
#ifndef MAA_WIN32_COMPATIBLE
35+
// 设置 Per-Monitor DPI Aware V2,确保 GetClientRect/GetWindowRect 等 API 返回物理像素。
36+
// 修复高 DPI 缩放下 PrintWindow/FramePool 等截图方式只能截取部分区域的问题。
37+
auto prev_ctx = SetThreadDpiAwarenessContext(DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2);
38+
if (prev_ctx) {
39+
LogInfo << "SetThreadDpiAwarenessContext to PER_MONITOR_AWARE_V2 success" << VAR_VOIDP(prev_ctx);
40+
}
41+
else {
42+
LogWarn << "SetThreadDpiAwarenessContext failed, error:" << GetLastError();
43+
}
44+
#endif
45+
3446
if (hwnd_) {
3547
if (!IsWindow(hwnd_)) {
3648
LogError << "hwnd_ is invalid";

0 commit comments

Comments
 (0)