Advertisement Jump to content


This topic is now archived and is closed to further replies.


Updating Fields On A Dialog Box

This topic is 6394 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey ppl, Can anyone help? I''m not a newbie (I have been using C++ at Uni for some time) but I don''t know much more than the basics. I am trying to get into Visual C++ (using MFC''s). Does anyone know how to update a text field on a dialog box with a char* field. I know I can use the SetDlgItemText() function to update fields in a window, but this doesn''t seem to work (or I can''t get it to work) with a dialog box. It will compile fine, but the field is left blank. If anyone can help, I would appreciate it greatly. Cheers Wizzard

Share this post

Link to post
Share on other sites
First, you must attach a member variable to the edit box. To do this go into Class Wizard, select the Member Variables tab, select the ID of the edit box, and click Add Variable. Enter a name, select the type, etc.

Now, if you want the variable to have an initial value that is displayed when the dialog box is created go to the dialog classes constructor. Find your variable and enter your initial value.

OK, so you now have a variable and it has a value. I''m not sure if this value will be displayed right away or not. If not what you need to do is add the line UpdateData(FALSE); to the dialog''s OnInitDialog() function.

That ought to do it. Whenever you want to change the text in the program change the variable''s value and call UpdateData(FALSE); If you want to set the value of the variable to be the text in the edit box call UpdatData(TRUE); Whenever either changes you must call UpdateData() to keep them synchronized. Hope that answers your question.

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!