Fix remote desktop window restore size issue

This commit is contained in:
yuanyuanxiang
2026-01-12 16:00:20 +01:00
parent dd5fe2cde1
commit 4e79d20828

View File

@@ -300,7 +300,27 @@ BOOL CScreenSpyDlg::OnInitDialog()
SysMenu->CheckMenuItem(IDM_ADAPTIVE_SIZE, m_bAdaptiveSize ? MF_CHECKED : MF_UNCHECKED);
SetClassLongPtr(m_hWnd, GCLP_HCURSOR, m_bIsCtrl ? (LONG_PTR)m_hRemoteCursor : (LONG_PTR)LoadCursor(NULL, IDC_NO));
ShowScrollBar(SB_BOTH, !m_bAdaptiveSize);
ShowWindow(SW_MAXIMIZE);
// 设置合理的"正常"窗口大小(屏幕的 80%),否则还原时窗口极小
int cxScreen = GetSystemMetrics(SM_CXSCREEN);
int cyScreen = GetSystemMetrics(SM_CYSCREEN);
int normalWidth = cxScreen * 80 / 100;
int normalHeight = cyScreen * 80 / 100;
int normalX = (cxScreen - normalWidth) / 2;
int normalY = (cyScreen - normalHeight) / 2;
// 使用 WINDOWPLACEMENT 确保 rcNormalPosition 被正确设置
WINDOWPLACEMENT wp = { sizeof(WINDOWPLACEMENT) };
GetWindowPlacement(&wp);
wp.rcNormalPosition.left = normalX;
wp.rcNormalPosition.top = normalY;
wp.rcNormalPosition.right = normalX + normalWidth;
wp.rcNormalPosition.bottom = normalY + normalHeight;
wp.showCmd = SW_MAXIMIZE;
SetWindowPlacement(&wp);
// 同时初始化 m_struOldWndpl供全屏退出时使用
m_struOldWndpl = wp;
m_Settings.FullScreen ? EnterFullScreen() : LeaveFullScreen();
SendNext();