MFC 窗体默认隐藏

缘起:mfc窗体程序改成命令行版本,不需要显示窗体
方法:重载 PreInitDialog 方法

修改属性代码:

void CxxDlg::PreInitDialog()
{
	// TODO: 在此添加专用代码和/或调用基类
	if (__argc > 1)
	{ 
		ModifyStyleEx(WS_EX_APPWINDOW, WS_EX_TOOLWINDOW);
		WINDOWPLACEMENT wp; wp.length = sizeof(WINDOWPLACEMENT);
		wp.flags = WPF_RESTORETOMAXIMIZED;
		wp.showCmd = SW_HIDE;
		SetWindowPlacement(&wp);
	}
	__super::PreInitDialog();
}

猜你喜欢

转载自blog.csdn.net/glc22/article/details/131937225
MFC