IdleBrain

I am a newbie to VC++ and I am trying to use a win32 timer (with MFC
and VS 2005) . The problem is that the OnTimer function is never
called. Here is part of the code that I've been trying to implement:

void CxxDlg:SurprisenBnClickedStart()
{
//Create a Timer
utmrTx = SetTimer(1, 1000, NULL);

}

void CxxDlg:SurprisenBnClickedStop()
{
// To Stop the timer
KillTimer(utmrTx);

}

void CxxDlg:SurprisenTimer(UINT nIDEvent)
{

}

I do not get any compile time error and when I debug the code, I see
that uTmrTx is set to 1. Only issue is that the OnTimer function is
never called. What am I doing wrong

Thanks,
IdleBrain.




Re: Visual C++ Language Win 32 timer - OnTimer not called

Pintu Shukla

Did you called WM_TIMER messages in your code.

Thanx






Re: Visual C++ Language Win 32 timer - OnTimer not called

IdleBrain

Thankyou Shukla for ur reply.

Looks like I havent called WM_TIMER messages. How do I do that

I am a newbie to VC++ and haven't implemented a timer before.






Re: Visual C++ Language Win 32 timer - OnTimer not called

Pintu Shukla

First thing Please let me know whether you are using win32 Application or win32 Console Application.

if win32 Application then have a look on this article

http://www.mini.pw.edu.pl/~mossakow/materials/presentations/win32.en/index.html

if win32 Console Application then Simply betwee your BEGIN_MESSAGE_MAP() and END_MESSAGE_MAP() put ON_WM_TIMER()

like

Code Block

BEGIN_MESSAGE_MAP(CTestAppaDlg, CDialog)

//other messages
ON_WM_TIMER()

END_MESSAGE_MAP()

and remember you had puted your code under some button click .so be sure that you clicked the button before debugging the code. and for more info have a look in MSDN

Thanx






Re: Visual C++ Language Win 32 timer - OnTimer not called

IdleBrain

Thanks Shukla again.

I'm working on a win32 application.

I blindly copied code from http://www.functionx.com/visualc/controls/timer.htm to execute the timer.

I would go through your reference article and see if that helps..will let u know pretty soon.

I appreciate ur help.






Re: Visual C++ Language Win 32 timer - OnTimer not called

Pintu Shukla

anytime you welcome.

thanx