user3051460
user3051460

Reputation: 1485

Full screen window in MFC

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

Answers (1)

Andrew Komiagin
Andrew Komiagin

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

Related Questions