dcsimg
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 9 of 9

Thread: SetTimer

  1. #1
    Join Date
    May 2000
    Posts
    45

    SetTimer

    Hi,

    I'm getting an assertion error with my Timer. When I use the debugger, it didn't go into the timer function ... it crashed at SetTimer. Just wondering what's wrong with my statement:

    int timeInBetween=1000/20;
    SetTimer(1,timeInBetween,NULL);

    Does the first parameter of SetTimer matters ... it's the nIDEvent? I used 1 ... could this cause the error?

    Thanks,
    Alex



  2. #2
    Join Date
    Aug 1999
    Location
    Memphis, TN, USA
    Posts
    159

    Re: SetTimer

    Are you using the CWnd version of SetTimer? What does the assertion say? I don't think using the number one should be a problem though, unless you already started a timer with that ID.


  3. #3
    Join Date
    May 2000
    Posts
    45

    Re: SetTimer

    I am using it in a class that is inherited from CView. i.e.
    class fcClassublic CView

    The assertion didn't say much:
    "Debug Assertion Failed!
    Program: ... exe
    File: afxwin2.inl
    Line: 168
    ..."

    I did include Afxwin.h as said in MSDN. So, I'm clueless.

    Thanks,
    Alex


  4. #4
    Join Date
    Aug 1999
    Location
    Memphis, TN, USA
    Posts
    159

    Re: SetTimer

    Ok, what I did was actually dig up that afxwin2.inl file (you could have also stepped through the procedure and came to the same line of code) and went to the specified line of code. It is asserting because your view hasn't become an actual window yet. If you're setting the timer in the constructor or something, this will happen. If you need a timer for each view, set it in the OnInitialUpdate function.


  5. #5
    Join Date
    Feb 2019
    Posts
    3

    Re: SetTimer

    Hi Michael, I have similar issue and you explained it very well. Thank you.
    I am using visual studio 2017. How to dig up and step into afxwin2.inl file?

  6. #6
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    19,423

    Re: SetTimer

    Doesn't F11 work?
    Or you could open it in VS and set the break point somewhere you'd like to "dig up".
    Victor Nijegorodov

  7. #7
    Join Date
    Feb 2019
    Posts
    3

    Re: SetTimer

    Victorn, thanks.
    F11 works for my source code well.
    As for SetTimer, it is not my source code. How to find way to step into it?

  8. #8
    Arjay's Avatar
    Arjay is offline Moderator / MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,033

    Re: SetTimer

    Quote Originally Posted by ForestWang View Post
    Victorn, thanks.
    F11 works for my source code well.
    As for SetTimer, it is not my source code. How to find way to step into it?
    You have to use MFC and need to have installed the MFC when you installed Visual Studio (or rerun the VS setup and install the MFC sources).

    Once you have the MFC sources you can step into its code.

  9. #9
    Join Date
    Feb 2019
    Posts
    3

    Re: SetTimer

    Quote Originally Posted by Arjay View Post
    You have to use MFC and need to have installed the MFC when you installed Visual Studio (or rerun the VS setup and install the MFC sources).

    Once you have the MFC sources you can step into its code.
    Thank you.
    I installed MFC and loaded the symbol. then I can debug into it.

Posting Permissions

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


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)