OnTimer() not being fired up.

hey guys, i have timer set like follows:
UINT TimerVal;
TimerVal = SetTimer(406, 50, NULL);

and i added in header file:
afx_msg void OnTimer(UINT nIDEvent);

and in cpp file i have:
void CEditorDlg::OnTimer(UINT nIDEvent)
{
char finalFps[100];
strcpy(finalFps, NConvert::IntToChar( _entityEngine->getFPS() ));
m_lblFPS.SetWindowText( _T( finalFps ) );

CDialog::OnTimer(nIDEvent);
}
and :
ON_WM_TIMER().

so when i put a break point int he ontimer function, it doesnt stop at it. therefore i understood that the timer wasnt started, but the TimerVal result i got had value 406, so i assumed that it already started.

does anybody know why


Answer this question

OnTimer() not being fired up.

  • Siric

    its ok, everything is all right now.
  • Einat

    oh, where do i call that function
  • Claudio Perrone

    ohh, so i call the setcapture funtion in my main dialog after creating the static control.

    and in my static control in the mouse events i call the ReleaseCapture()

    i think yeah i have to call the "ReleaseCapture()" somewhere cause its giving my the busy mouse cursor everything i load the app. i have to alt tab another program and back to my app for the mouse cursor changes back to normal.

    sorry for the newbie questions.


  • deyanp

    sorry for being annoying, but i understand where to put the set and release capture.

    i did so and everything seems to work fine. except the paint event for the static control.it only gets fired when i open a messagebox or opena color dialog box. any clues

    althought i tried CStatic::OnPaint() and BeginPaint() and EndPaint().


  • Martin Knotek

    egyptian_bean wrote:
    oh, where do i call that function

    Depends on how you create your static control. Do you create it by code If so call SetCapture once you are done creating it, else if it's part of the dialog template, call it in OnInitDialog.



  • Mark_Evans

    well im trying to do a 3D tool. therefore inside my dialog i have a static control which i render the 3D on it. so i inherited from the CStatic class to place my 3D rendering game related stuff in it.

    so i am using :

    OnPaint() to draw the 3d on.

    OnCreate() to do the reation stuff.

    OnSize() to get the size of static control.

    OnMouseMove, OnLButtonDown, OnLButtonUp functions for handling the mouse events in the static control for mouse movements and rotating my 3d model.

    in the onpaint override i have in my derived class, i called CStatic::OnPaint() function and then i implemented the paint related stuff.

    that line i added made the tooltips i did in the dialog appear, and messageboxes and color dialogs in the main dialog that get drawn below the static control (as i posted in a previous post) got drawn above as they should be.

    but now the problem is, the mouse events in my dervied static class rnt fired!


  • Harry CC

    egyptian_bean wrote:
    i just solved it, it had to do with my OnPaint(). lol i seriously dont know why does timer and paint got to do with each other but apperently after adding CStatic::OnPaint() the timer worked correctly.

    i feel very sad.

    I don't see how not calling the base class implementation of OnPaint should mess up your timer. Also, why are you calling CStatic::OnPaint when this is a CDialog derived class

    Just because something works doesn't mean, you ignore the weird scenario and move ahead. A hidden bug that shows its face in future would be a 100 times harder to fix than it'd be now.



  • johnsumner

    egyptian_bean wrote:

    well in the main dialog class i do _myStatic->Create();

    so im kinda confused where to put it.

    Okay, put it after the call to Create(). Note that, all mouse messages will now go to this static control. Once you are done (whatever it is you need), remember to call ReleaseCapture().



  • TazmanianDevil

    well in the main dialog class i do _myStatic->Create();

    so im kinda confused where to put it.


  • John Rice

    You need to call SetCapture if you want to handle mouse events in the static control.

    [Mod]I assume you want all mouse messages to be handled by your 3d rendering static class[/Mod]



  • oktek2002

    i just solved it, it had to do with my OnPaint(). lol i seriously dont know why does timer and paint got to do with each other but apperently after adding CStatic::OnPaint() the timer worked correctly.

    i feel very sad.

  • OnTimer() not being fired up.