Click to See Complete Forum and Search --> : KeyBoard and timer Event


Acalo
November 25th, 2004, 07:18 AM
HEllo, i have to write an application wich has an infinite loop

while(1){
updateScreen();
}

and i have to call 2 function in this whay:
interrupt_key() when a key is pressed
update_var() when timer event occurred (at least every 20 ms)

so i have to implement an event oriented managing

i tryed to create a simple program for timer events only :

#include <stdio.h>
#include <windows.h>

VOID CALLBACK TimerProc( HWND hwnd, // handle of window for timer messages
UINT uMsg, // WM_TIMER message
UINT idEvent, // timer identifier
DWORD dwTime // current system time
){
printf("\nCucù");

}


MSG theMsg;


int main(){

if((SetTimer( NULL,0,2000,(TIMERPROC)TimerProc))==0){
printf("Timer non settato\n");
}



while(1){
DispatchMessage(&theMsg) ;
}

return 0;
}

But the string "cucu" is'nt printed on to the screen.

I have to use necessary the console windows because next time i will have to build executable file for a microcontroller.

Help me please......