Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Timer

Timer

Scheduled Pinned Locked Moved C / C++ / MFC
question
5 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Mavrock
    wrote on last edited by
    #1

    Hi I would like my program to pull up a message box once a day on it's own. From what I understand I need to use a timer function. I would like it to give me a message box when the clock on my computer reaches 12pm everyday. Does anyone know a simple way of doing this? thanks Mavrock

    A L D 3 Replies Last reply
    0
    • M Mavrock

      Hi I would like my program to pull up a message box once a day on it's own. From what I understand I need to use a timer function. I would like it to give me a message box when the clock on my computer reaches 12pm everyday. Does anyone know a simple way of doing this? thanks Mavrock

      A Offline
      A Offline
      alex barylski
      wrote on last edited by
      #2

      Check out SetTimer() and WM_TIMER "An expert is someone who has made all the mistakes in his or her field" - Niels Bohr

      1 Reply Last reply
      0
      • M Mavrock

        Hi I would like my program to pull up a message box once a day on it's own. From what I understand I need to use a timer function. I would like it to give me a message box when the clock on my computer reaches 12pm everyday. Does anyone know a simple way of doing this? thanks Mavrock

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #3

        Basically, use liek this, with ON_WM_TIMER() SetTimer(1, 3600 000, NULL); 3600 000 here indicates an hour... it's in msec. so the code would look like..... int iTimer = 0; //global variable to count time //this will get invoked every hour YourClass::OnTimer(UINT nIDEvent) { iTimer=iTimer+1; if(iTimer == 12){ //do your processing.... } if (iTimer == 24){ iTimer = 0; } }//end of fn hope this helps dude. jey

        M 1 Reply Last reply
        0
        • M Mavrock

          Hi I would like my program to pull up a message box once a day on it's own. From what I understand I need to use a timer function. I would like it to give me a message box when the clock on my computer reaches 12pm everyday. Does anyone know a simple way of doing this? thanks Mavrock

          D Offline
          D Offline
          Daniel Lohmann
          wrote on last edited by
          #4

          For this waitable timers are best, because (as opposite to WM_TIMER) they do not work only with relative time, but also with absolute time and therefore fire at the right moment even if the machine was down in the mean time, the clock was adjusted or something else. Check out CreateWaitableTimer() for more info about waitable timers. -- Daniel Lohmann http://www.losoft.de (Hey, this page is worth looking! You can find some free and handy NT tools there :-D )

          1 Reply Last reply
          0
          • L Lost User

            Basically, use liek this, with ON_WM_TIMER() SetTimer(1, 3600 000, NULL); 3600 000 here indicates an hour... it's in msec. so the code would look like..... int iTimer = 0; //global variable to count time //this will get invoked every hour YourClass::OnTimer(UINT nIDEvent) { iTimer=iTimer+1; if(iTimer == 12){ //do your processing.... } if (iTimer == 24){ iTimer = 0; } }//end of fn hope this helps dude. jey

            M Offline
            M Offline
            Mavrock
            wrote on last edited by
            #5

            Thanks very much for the direction. I don't suppose you have some small source files you could send me. I'm new to programming and I have a hard time putting the code in the right place. usually when I see the source files I can just duplicate what was done before and make it work. Thank again. Mavrock my email is stonematthies@hotmail.com

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups