MFC 对话框去边框最大化全屏
BOOL CMFCApplication1Dlg::OnInitDialog()
{
CDialogEx::OnInitDialog();
// 1. 移除边框样式(无标题栏、无边框)
DWORD dwStyle = GetStyle();
dwStyle &= ~(WS_CAPTION | WS_THICKFRAME | WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_SYSMENU);
SetWindowLong(m_hWnd, GWL_STYLE, dwStyle);
// 2. 更新窗口样式(必须调用)
SetWindowPos(NULL, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED);
// 3. 最大化到全屏(覆盖整个屏幕)
int nScreenWidth = GetSystemMetrics(SM_CXSCREEN);
int nScreenHeight = GetSystemMetrics(SM_CYSCREEN);
SetWindowPos(NULL, 0, 0, nScreenWidth, nScreenHeight, SWP_NOZORDER);
return TRUE;
}
不包括任务栏:
// 使用屏幕尺寸,不包括任务栏
int nScreenWidth = GetSystemMetrics(SM_CXSCREEN);
int nScreenHeight = GetSystemMetrics(SM_CYSCREEN);
// 或者使用虚拟屏幕(支持多显示器)
// int nScreenWidth = GetSystemMetrics(SM_CXVIRTUALSCREEN);
// int nScreenHeight = GetSystemMetrics(SM_CYVIRTUALSCREEN);
覆盖任务栏:
// 获取屏幕尺寸(覆盖任务栏)
int nScreenWidth = GetSystemMetrics(SM_CXSCREEN);
int nScreenHeight = GetSystemMetrics(SM_CYSCREEN);
SetWindowPos(NULL, 0, 0, nScreenWidth, nScreenHeight, SWP_NOZORDER);
浙公网安备 33010602011771号