Hello. I am trying to add to a math game (Visual C++, MFC, dialog based app) that I have developed for my daughter. Trying to make it a little more graphics based, and thus, more entertaining for her. I am having a problem. I made a simple bitmap icon in the resource editor. I have associated the picture box with the bitmap icon (under picture box properties (IDC_ANSWERICON in my program, "image" property is set to corresponding bitmap). When the program starts, the idea is to hide the picture box with the following code:
this -> GetDlgItem (IDC_ANSWERICON) -> ShowWindow (SW_HIDE); // this part works
When she correctly answers the math problem, I un-hide the picture box:
this -> GetDlgItem (IDC_ANSWERICON) -> ShowWindow (SW_SHOW); // this part does NOT work
UpdateData (FALSE); // Update the dialog
wait (2); // wait 2 seconds to allow user time to see icon
Then I hide the icon again. However, the icon never appears. Additionally I have a message box that I want to phase out. Oddly enough, if I leave the code in for the message box, the icon appears. I'm not sure what I am doing wrong. I want to take out the message box because it covers up the icon and is wholly unnecessary at this point in my daughter's educational development.
Hopefully I have included enough information in my posting. If not, please let me know. I have taken college courses in C++, but I am pretty new at Visual C++- so take it easy on me. If there is a better way to do this, I would like to know but keep in mind I am a newbie and may need it broken down a little. Thanks for all of your help. It is greatly appreciated!
When you call wait it kicks in before the picture box gets a chance to draw itself. When wait expires you tell the picture box to hide itself again. So in effect, you never really give it a chance to draw itself. Try calling UpdateWindow on the picture box before the wait call.
Thanks for your input. Your solution was most helpful and solved my problem. It's very frustrating getting stuck, even on a simple program such as mine. By the way, what's the difference between UpdateDialogControl, UpdateWindow, and UpdateData??? UpdateWindow is the only one that worked in this case, as I had tried the other two and met only with utter hopelessness.
Thanks for your input. Your solution was most helpful and solved my problem. It's very frustrating getting stuck, even on a simple program such as mine. By the way, what's the difference between UpdateDialogControl, UpdateWindow, and UpdateData??? UpdateWindow is the only one that worked in this case, as I had tried the other two and met only with utter hopelessness.
Thanks again for the solution!
Glad I could help. MSDN would do a better job explaining those functions that I could, but basically UpdateWindow forces the target window to redraw itself immediately. UpdateData transfers information between controls and variables. I'm not familiar with UpdateDialogControl.
Bookmarks