开发者

MFC: Creating modeless dialog box without displaying

I'm trying to create a simple modeless dialog box which I'm creating from my CWinApp derived InitInstance() function.

BOOL CMyApp::InitInstance()
{
    ...
    m_pMyDialog = new CMyDialog();
    m_pMyDialog->Create(CMyDialog::IDD);
    ...
    retrun TRUE;
}

I've created the dialog template in the resource edi开发者_运维技巧tor and the WS_VISIBLE bit is unset. My intention is to avoid showing the dialog until I explicitly call ShowWindow(SW_SHOW) but for some reason the call to Create displays the dialog.

I've tried to change the return value of OnInitDialog() to FALSE but that doesn't work.

I've even tried to call ModifyStyle() in case something else is setting the WS_VISIBLE bit.

int CMyDialog::OnCreate(LPCREATESTRUCT lpCreateStruct) 
{
   if (CDialog::OnCreate(lpCreateStruct) == -1)
      return -1;

   ModifyStyle(WS_VISIBLE, 0);   

   return 0;

 }

That doesn't work either. In all cases, after I call Create the dialog is displayed which isn't how I've read it should work.


The problem was with AnimateWindow() which was causing the dialog to display prematurely.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜