-
August 23rd, 2009, 08:09 PM
#1
Help with picture box
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!
-
August 23rd, 2009, 11:41 PM
#2
Re: Help with picture box
What's with the wait function?
Does it have a loop in it?
Try Sleep(2000) to wait for 2 seconds.
-
August 24th, 2009, 05:47 AM
#3
Re: Help with picture box
Any thoughts on my actual problem????
-
August 24th, 2009, 07:36 AM
#4
Re: Help with picture box
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.
-
August 24th, 2009, 07:15 PM
#5
Re: Help with picture box
GCDEF,
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!
-
August 24th, 2009, 08:43 PM
#6
Re: Help with picture box
Originally Posted by abollmeyer
GCDEF,
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.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|