我正在使用MFC制作应用程序。当我单击该应用程序时,它必须全屏显示。我遵循该代码
CRect rcDesktop;
rcDesktop.left = GetSystemMetrics(SM_XVIRTUALSCREEN);
rcDesktop.right = rcDesktop.left + GetSystemMetrics(SM_CXVIRTUALSCREEN);
rcDesktop.top = GetSystemMetrics(SM_YVIRTUALSCREEN);
rcDesktop.bottom = rcDesktop.top + GetSystemMetrics(SM_CYVIRTUALSCREEN);
MoveWindow(rcDesktop, FALSE);
但是,它仅适用于多个显示器。如果我还有两台显示器,但我想在一台显示器上显示全屏应用程序。如何实现它。我跟着document,我尝试了
CRect rcDesktop;
rcDesktop.left = GetSystemMetrics(SM_CVSCREEN);
rcDesktop.right = rcDesktop.left + GetSystemMetrics(SM_CXFULLSCREEN);
rcDesktop.top = GetSystemMetrics(SM_CVSCREEN);
rcDesktop.bottom = rcDesktop.top + GetSystemMetrics(SM_CYFULLSCREEN);
MoveWindow(rcDesktop, FALSE);
然而,它不起作用。因为我需要把坐标放在
rcDesktop.right = rcDesktop.left + GetSystemMetrics(SM_CXFULLSCREEN);
你可以帮我修改我的代码吗?我正在使用visual studio 2012和MFC
答案 0 :(得分:2)
在您的视图中,执行以下操作:
SetParent(GetDesktopWindow());
CRect rect;
GetDesktopWindow()->GetWindowRect(&rect);
SetWindowPos(&wndTopMost,rect.left,rect.top,rect.right,rect.bottom,SWP_SHOWWINDOW);