怎么在启动时隐藏对话框

怎样在启动时隐藏对话框?
基于对话框的程序,不管是在OnInitDialog中加入ShowWindow(SW_HIDE);还是设置Visible=False都不能隐藏窗口,为什么啊?那怎么办呢?
------解决方案--------------------
重载PreCreateWindow(CREATESTRUCT&   cs)函数,
BOOL CXXDlg::PreCreateWindow(CREATESTRUCT& cs)
{
    cs.style &= ~WS_VISIBLE;
    return CDialog::PreCreateWindow(cs);
}
------解决方案--------------------
不想显示对话框,在app的instance里不要调dlg的domodal啊
------解决方案--------------------
引用:
不想显示对话框,在app的instance里不要调dlg的domodal啊


+1

使用 Create 来创建非模态对话框
创建成功后,不调用ShowWindow即可
------解决方案--------------------
在OnPaint() 函数中的最开始加上:
ShowWindow(SW_HIDE);
如下:

void CMyDlg::OnPaint() 
{
ShowWindow(SW_HIDE);
if (IsIconic())
{
CPaintDC dc(this); // device context for painting

SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);

// Center icon in client rectangle
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;

// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CDialog::OnPaint();
}
}