Timer Help, Message box help

John Miogi's Avatar
Go4Expert Member
Hello all, I have posted a message before, but I cant see it so I will post agian..

I am having such a hard time with MFC SDI . I have have to make a simple timer that goes every second and I have tried everything. I also have to make a message box, and most of all, I have to get the location of the mouse when I click on the screen to print out the corordinates to the screen. I have been on thiese things for sometime and I am not getting anywhere. The only thing I made was a menu that I have to use for these things.

Please help, and if you can, could you please help me step by step cause I am so confused with this and I have tried online google help and cannot get it..

Thanks so much..

John Miogi
shabbir's Avatar, Join Date: Jul 2004
Go4Expert Founder
All you need to be doing is add the WM_ON_TIMER and have a function OnTimer in the class.
shabbir's Avatar, Join Date: Jul 2004
Go4Expert Founder
Of course you need to be calling the SetTimer for starting the timer.
John Miogi's Avatar
Go4Expert Member
ok, but thats my problem, I dont know how to call these things and where to get them.. I know that the class wizard will let me choose the timer, but how do I actually get it to work?
shabbir's Avatar, Join Date: Jul 2004
Go4Expert Founder
If you depend on Class Wizard for MFC you will know very little of how things are working. I will tell you what needs to be done.

Add the Following in the Message Map.
ON_WM_TIMER()

Now add the afx_msg OnTimer(UINT nIDEvent) function in the class where you have added the above line.

And in the InitDialog or Constructor you can call the SetTimer(ID) function to start the Timer.

This is just the pseudo code type of thing and the function may parameter may not be correct but as far as I remember they are.
John Miogi's Avatar
Go4Expert Member
I put that code : afx_msg OnTimer(UINT nIDEvent) in the constrcutor, and added a meeage OPn_WM_Timer to the view class and I am lost after that,, I am sorry Shabbir, but I am having a hard time with it..

Thanks

John Miogi
shabbir's Avatar, Join Date: Jul 2004
Go4Expert Founder
Are you lost in the text I have written.
John Miogi's Avatar
Go4Expert Member
here is a few functions, I am using the bot one to call the timer from a drop-down menu start..
most of it it commented off because I was getting errors
I did not add the constrcutor here.
Code:
void CTest69View::OnTimer(UINT nIDEvent) 
{
	// TODO: Add your message handler code here and/or call default
	
	CView::OnTimer(nIDEvent);
    //afx_msg OnTimer(UINT nIDEvent) 

}

void CTest69View::OnTimerStart() 
{
	// TODO: Add your command handler code here
     //afx_msg OnTimer(UINT nIDEvent) 
    // SetTimer(ID)

   
}

Last edited by shabbir; 16Apr2007 at 18:59.. Reason: Code formatting.
John Miogi's Avatar
Go4Expert Member
Sorry man for being such a pain.. This summer I am going to catch up on this programming, I really want to make this work.. I am almost done the first year at colllege, have another 2 years to go..
shabbir's Avatar, Join Date: Jul 2004
Go4Expert Founder
Please put the code blocks when having code snippets in the post.

Also I could not get what you have done.

Now you need to SetTimer somewhere in constructor of the view class.

Also after doing that please tell me if your OnTimer function is called. If yes I would assume you have the message map step done.