Reputation: 1485
I am using MFC to make a application. When I click that application, it must be show full screen. I follows that code
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);
However, it is only for multiple monitors. If I also have two monitor, but I want to display full screen application in one monitor. How to implement it. I follows that document and I tried
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);
However, it is does not work. Because I need put the coordinate for
rcDesktop.right = rcDesktop.left + GetSystemMetrics(SM_CXFULLSCREEN);
Could you help me fix my code. I am using visual studio 2012 and MFC
Upvotes: 0
Views: 2277
Reputation: 6556
In your view class do the following:
SetParent(GetDesktopWindow());
CRect rect;
GetDesktopWindow()->GetWindowRect(&rect);
SetWindowPos(&wndTopMost,rect.left,rect.top,rect.right,rect.bottom,SWP_SHOWWINDOW);
Upvotes: 2