UnfitElf
January 24th, 2006, 12:39 AM
Hi ppl.
I did search for this problem and i couldnt find one like it. If i overlooked it sorry.
My problem is when using SetTimer() in a function it doesnt work, yet when its not in the function it does work..
The following code will help you to see the strange probelm.
This does not work
HWND hwnd; // Global handle for our window
void timer(void)
{
SetTimer(hwnd, 1, 5000, (TIMERPROC)NULL);
}
// setting up the window etc.. has been omitted for ease of posting code
switch (message) /* handle the messages */
{
case WM_TIMER:
MessageBox(NULL, "Timer", "Timer", MB_OK);
break;
case WM_CREATE:
timer();
break;
case WM_DESTROY:
PostQuitMessage (0); /* send a WM_QUIT to the message queue */
break;
default: /* for messages that we don't deal with */
return DefWindowProc (hwnd, message, wParam, lParam);
}
This Does work
HWND hwnd; // Global handle for our window
// setting up the window etc.. has been omitted for ease of posting code
switch (message) /* handle the messages */
{
case WM_TIMER:
MessageBox(NULL, "Timer", "Timer", MB_OK);
break;
case WM_CREATE:
SetTimer(hwnd, 1, 5000, (TIMERPROC)NULL);
break;
case WM_DESTROY:
PostQuitMessage (0); /* send a WM_QUIT to the message queue */
break;
default: /* for messages that we don't deal with */
return DefWindowProc (hwnd, message, wParam, lParam);
}
I cannot understand this at all, any help?
Thanks
I did search for this problem and i couldnt find one like it. If i overlooked it sorry.
My problem is when using SetTimer() in a function it doesnt work, yet when its not in the function it does work..
The following code will help you to see the strange probelm.
This does not work
HWND hwnd; // Global handle for our window
void timer(void)
{
SetTimer(hwnd, 1, 5000, (TIMERPROC)NULL);
}
// setting up the window etc.. has been omitted for ease of posting code
switch (message) /* handle the messages */
{
case WM_TIMER:
MessageBox(NULL, "Timer", "Timer", MB_OK);
break;
case WM_CREATE:
timer();
break;
case WM_DESTROY:
PostQuitMessage (0); /* send a WM_QUIT to the message queue */
break;
default: /* for messages that we don't deal with */
return DefWindowProc (hwnd, message, wParam, lParam);
}
This Does work
HWND hwnd; // Global handle for our window
// setting up the window etc.. has been omitted for ease of posting code
switch (message) /* handle the messages */
{
case WM_TIMER:
MessageBox(NULL, "Timer", "Timer", MB_OK);
break;
case WM_CREATE:
SetTimer(hwnd, 1, 5000, (TIMERPROC)NULL);
break;
case WM_DESTROY:
PostQuitMessage (0); /* send a WM_QUIT to the message queue */
break;
default: /* for messages that we don't deal with */
return DefWindowProc (hwnd, message, wParam, lParam);
}
I cannot understand this at all, any help?
Thanks