|
-
November 27th, 2009, 04:27 PM
#1
MFC, invisible dialog app with timer
Hello
I'm making a MFC program that needs to start invisible, with a timer running. Then on timer expiry, if certain conditions are met, a dialog is supposed to display. I am trying a Dialog based application because that seems the most straightforward. I have been able to get roughly what I want with the standard modal dialog code generated by Visual Studio, by putting ShowWindow(SW_HIDE) in the dialog's OnPaint method. That approach causes a flicker of the dialog when the program is starting and I think there is a more correct way.
I have also tried:
Code:
BOOL CMyApp::InitInstance()
{
InitCommonControls();
CWinApp::InitInstance();
m_pMainWnd = new CMyDlg;
UINT_PTR uTimerId = SetTimer(NULL, 0, 2000, &TimerCallback);
return (m_pMainWnd != NULL);
}
But this causes an assertion failure in CDialog at
Code:
BOOL CDialog::PreTranslateMessage(MSG* pMsg)
{
// for modeless processing (or modal)
ASSERT(m_hWnd != NULL);
}
It makes sense that m_hWnd is NULL because I haven't called the dailog's DoModal method but I don't know what to do about it.
What is the correct technique for this kind of application?
Thanks.
Last edited by BertAndErnie; November 27th, 2009 at 04:32 PM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|