Results 1 to 14 of 14

Thread: is there Timer in VC++??

  1. #1

    Thread Starter
    Member
    Join Date
    Sep 2002
    Location
    in e middle of nowhere..
    Posts
    40

    Question is there Timer in VC++??

    hello.
    may i know is there a Timer control in VC++ and how to use that??
    can provide me some code samples also? hehe..

    thanks..

  2. #2
    Addicted Member Bazza81's Avatar
    Join Date
    Apr 2001
    Location
    Nottingham, UK
    Posts
    203

    Unhappy Yes & No

    You may use the varius timer API functions. For instance, the SetTimer() function will create the timer and call your specified call-back function every n milliseconds. Hence, the KillTimer() function will destroy the timer you created when using the SetTimer() function.

    The best way I find is to just run through an infinate loop using GetTickCount() instead.
    Who needs rhetorical questions anyway?


    Bazza NET - The place you want to be!

  3. #3

    Thread Starter
    Member
    Join Date
    Sep 2002
    Location
    in e middle of nowhere..
    Posts
    40
    ok.. thanks.
    i'll try that out .
    so doesn't VC++ have something like a Timer Control, ?
    like in Borland C builder..

    thank you..

  4. #4
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    Do you actually *know* C++?

    I wouldn't recommend starting with MFC.

    C++ is *not* a RAD language, like VB or C++ Builder.
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  5. #5

    Thread Starter
    Member
    Join Date
    Sep 2002
    Location
    in e middle of nowhere..
    Posts
    40
    ok.. fine..
    thanks 4 ur advice..


  6. #6
    Hyperactive Member
    Join Date
    Aug 2002
    Posts
    416
    lol, why would you want to use a control? ... Just use SetTimer, and you can create a callback function. ... Works pretty much like the Timer control in VB, but better.

  7. #7
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    Actually all the VB timer control does is calling SetTimer...
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  8. #8
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    You're better off using timeSetEvent, it's far more reliable.
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  9. #9
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    what's timeSetEvent?
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  10. #10
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    The multimedia timers. Far more stable, and accurate to 1ms.
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  11. #11
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    I have a vague memory of using them in VB at sometime, and that they used to crash the IDE :S
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  12. #12
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    It's not difficult to crash VB. If you have pointers to things they get juggled around and then the callbacks don't work.
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  13. #13
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    hmm.. I dont care about VB anyway, so doesnt matter, probably going to be useful.
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  14. #14
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    But if accuracy or reliability is not needed (such as for an autosave, it doesn't need to come exactly to the millisecond), SetTimer is better because it's easier to use and doesn't require an answering thread. And timeSetEvent lays several restrictions on the user.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

Posting Permissions

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



Click Here to Expand Forum to Full Width