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
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?
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.
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
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) }
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..
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.
I want to show you my code structure, but how do I put code in blocks? lol, I am useless... I got the call to work, but I need to print out the timer in Int values, I have a drop-down menu which I have start, and stop. I start with a flag true, and stop with flag false. could you please help me with how I could get the timer to go to window and count in int value? and where would I put this code.. Thanks agian..
I want to show you my code structure, but how do I put code in blocks? lol, I am useless... I got the call to work, but I need to print out the timer in Int values, I have a drop-down menu which I have start, and stop. I start with a flag true, and stop with flag false. could you please help me with how I could get the timer to go to window and count in int value? and where would I put this code.. Thanks agian.. Code: void CDrawMFCView::OnTimer(UINT nIDEvent) { // TODO: Add your message handler code here and/or call default if(flag6) { CView::OnTimer(nIDEvent); } } void CDrawMFCView::OnTimerStart() { // TODO: Add your command handler code here flag6=1; SetTimer(2,5000,NULL); MessageBox("100"); } void CDrawMFCView::OnTimerStop() { // TODO: Add your command handler code here flag6=0; }
Ok make up a variable, private, or public? and put the variable in the function and increament it with the timer? Ok how could I set that up.. and while you are in the mood to help(hehe), is it easy to get mouse coordinated when clicked (left or rt button) anywhere on screen to to show y, and x location? This is a bonus part us my lab, but I need this bonus to pass the course cause I am borderline.. Thanks Shabbir..
Yes getting the mouse point location is very much possible but I would suggest you to go one step at a time. Is the Timer thing working.
I am sorry I did not get back to you, I was waiting for an e-mail reply to tell me that I revieved a reply.. Anyhow, yes I got the counter(timer) thing working. I have been on the coordinates of the mouse for the last three hours. I need to click on screen after prog executes and it will show x, and y coordinates. I have not figured it out, except that I have been messing around with getcursorposition. I dont know if this is what I am suppose to use, but at this time, I am just going around in circles.. BTW, Thanks alot for your help earlier and just to note that This is not from a lack of trying.. I have been in from of my laptop for three straight days trying to do these things and I am almost done, except for the mouse thingy.
Did you get the email reply. We have moved to another hosting and server and is just curious if anything is not functioning as expected. Thats good. Thats the best way to be doing but what you can do is have some variable of type point which stores the mouse position for the WM_MOUSEMOVE event and updates in mouse move. My pleasure