Hey everyone,
I have multiple timers set up for a dialog (MFC) using SetTimer and OnTimer. This works great when I'm on the dialog but if I move away from the dialog and go back to it, the timers get reset, using the following code:
ShowWindow(SW_HIDE);
test testDialog;
testDialog.DoModal();
CTimersDlg main;
main.DoModal();
OnOK(); // Close test dialog
The timer probably gets reset because of 'main.DoModal()' instead of main.ShowWindow(SW_SHOW).
Hiding the dialog works ok, but, if I use 'main.ShowWindow(SW_SHOW)' then I get a 'Debug Assertion Failed!' error. More info:
+ m_hWnd 0x00000000 {unused=??? } HWND__ *
stops at this line:
ASSERT(::IsWindow(m_hWnd) || (m_pCtrlSite != NULL));
I think I'm getting this error because m_hWnd is 0x00000000 when it runs the code 'CTimersDlg main', so it creates a new dialog instead of looking at the one that was hidden? So how would I get the dialog that was hidden to re-appear? and will the timer still be running, without restarting?
My aim is to have the timer run in the background of that dialog even when I'm on another dialog so I thought I could hide the dialog and then show it when I want to get back to it, is this possible? Many thanks.