Full screen dialogs
Sometimes you might feel the need to make a full screen dialog - means a dialog that fills up the entire monitor. Well it's rather easy to achieve this. You need to remove the caption and the border which we do by removing the WS_CAPTION
and the WS_BORDER
styles. Then we call SetWindowPos
with HWND_TOPMOST
and resize the dialog to fill up the entire screen. Just put the following code into your OnInitDialog
function.
BOOL CFullScrDlgDlg::OnInitDialog() { CDialog::OnInitDialog(); //... int cx, cy; HDC dc = ::GetDC(NULL); cx = GetDeviceCaps(dc,HORZRES) + GetSystemMetrics(SM_CXBORDER); cy = GetDeviceCaps(dc,VERTRES) + GetSystemMetrics(SM_CYBORDER); ::ReleaseDC(0,dc); // Remove caption and border SetWindowLong(m_hWnd, GWL_STYLE, GetWindowLong(m_hWnd, GWL_STYLE) & (~(WS_CAPTION | WS_BORDER))); // Put window on top and expand it to fill screen ::SetWindowPos(m_hWnd, HWND_TOPMOST, -(GetSystemMetrics(SM_CXBORDER)+1), -(GetSystemMetrics(SM_CYBORDER)+1), cx+1,cy+1, SWP_NOZORDER); //... return TRUE; }