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. Abut timers

Abut timers

Scheduled Pinned Locked Moved C / C++ / MFC
question
8 Posts 5 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.
  • Z Offline
    Z Offline
    Zeeshan Bilal
    wrote on last edited by
    #1

    I wanaa to start timer on clicking button Btn_Start and here i will disable button Btn_Start (GetDlgItem(BTN_START ))->EnableWindow (FALSE); SetTimer( 21, 1000 * 60 * 180, NULL); as my calculations 1000 * 60 * 180 = 3 hours or 180 mint is it ? after expiry of 180 minuts in ON_TIMER Event I will Enable Start Button GetDlgItem(BTN_START ))->EnableWindow (TRUE); KillTimer( 21 ); But it not complete its time of 180 mint ,, it enable it early ,,,, Y?? any reason thanx

    B A V 3 Replies Last reply
    0
    • Z Zeeshan Bilal

      I wanaa to start timer on clicking button Btn_Start and here i will disable button Btn_Start (GetDlgItem(BTN_START ))->EnableWindow (FALSE); SetTimer( 21, 1000 * 60 * 180, NULL); as my calculations 1000 * 60 * 180 = 3 hours or 180 mint is it ? after expiry of 180 minuts in ON_TIMER Event I will Enable Start Button GetDlgItem(BTN_START ))->EnableWindow (TRUE); KillTimer( 21 ); But it not complete its time of 180 mint ,, it enable it early ,,,, Y?? any reason thanx

      B Offline
      B Offline
      bryce
      wrote on last edited by
      #2

      not sure what you're on about but are you catching the OnTimer event? and making sure you deal with only the correct timer event (21) cheers bryce --- Publitor, making Pubmed easy. http://www.sohocode.com/publitor

      Z 1 Reply Last reply
      0
      • B bryce

        not sure what you're on about but are you catching the OnTimer event? and making sure you deal with only the correct timer event (21) cheers bryce --- Publitor, making Pubmed easy. http://www.sohocode.com/publitor

        Z Offline
        Z Offline
        Zeeshan Bilal
        wrote on last edited by
        #3

        Wts is timers life time ,, means i wanaa say its maximum limit to set it.. if i set a timer for 24 hours ,, will work or SetTimer (...) have any time range for timer thanx

        B T V 3 Replies Last reply
        0
        • Z Zeeshan Bilal

          Wts is timers life time ,, means i wanaa say its maximum limit to set it.. if i set a timer for 24 hours ,, will work or SetTimer (...) have any time range for timer thanx

          B Offline
          B Offline
          bryce
          wrote on last edited by
          #4

          mate, i have no idea what you're on about you have not provided enough information for anyone to give you any decent answer bryce --- Publitor, making Pubmed easy. http://www.sohocode.com/publitor

          1 Reply Last reply
          0
          • Z Zeeshan Bilal

            I wanaa to start timer on clicking button Btn_Start and here i will disable button Btn_Start (GetDlgItem(BTN_START ))->EnableWindow (FALSE); SetTimer( 21, 1000 * 60 * 180, NULL); as my calculations 1000 * 60 * 180 = 3 hours or 180 mint is it ? after expiry of 180 minuts in ON_TIMER Event I will Enable Start Button GetDlgItem(BTN_START ))->EnableWindow (TRUE); KillTimer( 21 ); But it not complete its time of 180 mint ,, it enable it early ,,,, Y?? any reason thanx

            A Offline
            A Offline
            Anonymous
            wrote on last edited by
            #5

            Set timer interval to 1000 (1 second) when creating timer. You will need to create a member data and then increment it in the timer: CMyDialog::OnTimer(...) { m_seconds++; // then you can calculate m_seconds and do whatever // other code }

            1 Reply Last reply
            0
            • Z Zeeshan Bilal

              I wanaa to start timer on clicking button Btn_Start and here i will disable button Btn_Start (GetDlgItem(BTN_START ))->EnableWindow (FALSE); SetTimer( 21, 1000 * 60 * 180, NULL); as my calculations 1000 * 60 * 180 = 3 hours or 180 mint is it ? after expiry of 180 minuts in ON_TIMER Event I will Enable Start Button GetDlgItem(BTN_START ))->EnableWindow (TRUE); KillTimer( 21 ); But it not complete its time of 180 mint ,, it enable it early ,,,, Y?? any reason thanx

              V Offline
              V Offline
              vcplusplus
              wrote on last edited by
              #6

              You should use the value returned by SetTimer for KillTimer. From MSDN ========= Return Value from SetTimer(...) The timer identifier of the new timer if the function is successful. An application passes this value to the KillTimer member function to kill the timer. Nonzero if successful; otherwise 0.

              1 Reply Last reply
              0
              • Z Zeeshan Bilal

                Wts is timers life time ,, means i wanaa say its maximum limit to set it.. if i set a timer for 24 hours ,, will work or SetTimer (...) have any time range for timer thanx

                T Offline
                T Offline
                ThatsAlok
                wrote on last edited by
                #7

                According ot MSDN,Maximum limit is 0x7fffffff or 597 hr. for setting Timer ----------------------------- "I Think It will Work" Formerly Known As "Alok The Programmer" at CP ----------------------------- Alok Gupta visit me at http://www.thisisalok.tk

                1 Reply Last reply
                0
                • Z Zeeshan Bilal

                  Wts is timers life time ,, means i wanaa say its maximum limit to set it.. if i set a timer for 24 hours ,, will work or SetTimer (...) have any time range for timer thanx

                  V Offline
                  V Offline
                  vcplusplus
                  wrote on last edited by
                  #8

                  I have no idea what "wts" and "wanaa" mean. If you are looking for the max value for SetTime(...), look at the function prototype. SetTimer( HWND hWnd , UINT nIDEvent, UINT uElapse, TIMERPROC lpTimerFunc); It looks like uElapse is of type UNIT, so probably the max number of milliseconds is UINT_MAX. Details on UINT_MAX can be found at msdn.microsoft.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