Results 1 to 3 of 3

Thread: Timer

  1. #1
    Addicted Member
    Join Date
    May 01
    Location
    Québec, Canada
    Posts
    131

    Timer

    Hello, I was wandering how I could make a timer with an intervall of a minute and the message it send every minutes?
    Khavoerm Irithyl

  2. #2
    PowerPoster abdul's Avatar
    Join Date
    Dec 00
    Location
    Ontario,Canada
    Posts
    2,827

    I don't wanna write the whole program but...

    Use "SetTimer" API to create a new timer when you have create your window under "WinMain()" or any other place.
    Then, you will get a message called "WM_TIMER" after each time that you specified.
    So if you want to create a timer that sends the "WM_TIMER" message after each second, then it would look like this:

    PHP Code:
    SetTimer(winhwnd,1,1000,NULL);
    /*winhwnd = handle of the window which will receive the WM_TIMER message*/
    //1 = the timer ID
    /*1000 = after the time in milliseconds,each time, you want to send a WM_TIMER message*/
    /*NULL = if you want to have your own procedure for the timer then you can specify that here, otherwise, it will send your window a WM_TIMER message*/

    //.................

    //Received a WM_TIMER message
    case WM_TIMER
    MessageBox
    (NULL,"After every second","A",MB_OK);
    //When we are done with the timer, we kill it using...
    KillTimer(winhwnd1)
    //1 = the timer ID 
    Hope that helps
    Baaaaaaaaah

  3. #3
    Addicted Member
    Join Date
    May 01
    Location
    Québec, Canada
    Posts
    131
    Thank you for the help
    Khavoerm Irithyl

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •