Go4Expert (http://www.go4expert.com/)
-   MFC (http://www.go4expert.com/forums/mfc/)
-   -   Timer Help, Message box help (http://www.go4expert.com/forums/timer-help-message-box-help-t3871/)

John Miogi 15Apr2007 04:58

Timer Help, Message box help
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 15Apr2007 08:49

Re: Timer Help, Message box help
All you need to be doing is add the WM_ON_TIMER and have a function OnTimer in the class.

shabbir 15Apr2007 08:49

Re: Timer Help, Message box help
Of course you need to be calling the SetTimer for starting the timer.

John Miogi 16Apr2007 04:36

Re: Timer Help, Message box help
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 16Apr2007 06:07

Re: Timer Help, Message box help
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.

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 16Apr2007 18:40

Re: Timer Help, Message box help
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..


John Miogi

shabbir 16Apr2007 18:46

Re: Timer Help, Message box help
Are you lost in the text I have written.

John Miogi 16Apr2007 18:48

Re: Timer Help, Message box help
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.

void CTest69View::OnTimer(UINT nIDEvent)
        // TODO: Add your message handler code here and/or call default
    //afx_msg OnTimer(UINT nIDEvent)


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


John Miogi 16Apr2007 18:58

Re: Timer Help, Message box help
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 16Apr2007 19:01

Re: Timer Help, Message box help
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.

All times are GMT +5.5. The time now is 05:34.