Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SetTimer not working with visible CDialog.

Status
Not open for further replies.

mp4771

Programmer
Mar 5, 2001
2
GB
Background
---------------
I have an SDI application.
from a menu selection the application does this:
CMyDialog dialog;
int response = dialog.DoModal();

the CMyDialog class overrides the OnInitDialog function to:
{
CDialog::OnInitDialog();
int result = this->SetTimer (1, 100, NULL);
}

The CMyDialog::OnTimer function receives the WM_TIMER messages and checks the elapsed time on each activation and "timesout" if appropriate, causing the dialog to close automatically with a call to KillTimer(1) and then OnCancel().
This means the user has a certain period of time to hit ok otherwise cancel is assumed.

Problem
----------
Now the problem is that the dialog does not show itself until KillTimer is called. If I call KillTimer at the end of OnInitDialog then the dialog shows. (but obviously then I have no Timer running).

I have the dialog template attribute "visible" set to false. If I set this to true the dialog shows itself immediately but the WM_TIMER messages from SetTimer are not received anywhere.
I have put OnTimer functions in the main application, the main window and in my class, but none of these are receiving them and so it makes me wonder if SetTimer is working.

How do I get both the WM_TIMER messages and the dialog visible ?

Thanks in advance for all suggestions.
 
It seems to me that the call :
int result = this->SetTimer (1, 100, NULL);

creates a timer with an intervall time of "100 ms" and not "100 s". And so you don't have the time to see the dialog box to get open since it is closed within 0.1s.

Try : SetTimer (1, 100000, NULL);
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top