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;
}
本文介绍了一种简单的方法来创建全屏对话框,通过移除窗口标题栏和边框,并使用SetWindowPos调整窗口位置及大小以覆盖整个屏幕。这种方法适用于需要全屏显示对话框的应用场景。
2829

被折叠的 条评论
为什么被折叠?



