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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SetTimer() does not work

Status
Not open for further replies.

tchouch

Programmer
Apr 18, 2001
300
0
0
DE
I write a non-MFC Win32 application and try to use Timer to redraw some controls. But callback function TimerProc is not called. I have often used timers before and all have worked fine.
I start timer with the code

UINT g_Timer = 0; //global
void CALLBACK TimerProc(HWND hWnd, UINT nMsg, UINT nIDEvent, DWORD dwTime)
{
....
}

void Dlg_OnCommand()
{
...
UINT TimerID = 1005; //local
while((g_Timer = SetTimer(g_hDlg, TimerID, 1000, (TIMERPROC)MyTimerProc )) == 0)
TimerID++;
...
}

After this call g_Timer is the same as TimerID (1005, and it is right, i think). g_hDlg is a valid window (Dialog in Dialog - based application, and I start the timer with a button - g_hDlg is visible, another features are started fine with this button).

{
...
if(g_Timer)
KillTimer(g_hDlg, g_Timer);
...
}
works too, only MyTimerProc() is not called (in Debug and Release)...
Does anybody know a solution?
 
Add an OnTimer event in your code and make it call what you need. in the OnInitDialog set the timer.

Kill the timer when you need to

Matt
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top