2
votes

Language: C++

Development Environment: Microsoft Visual C++

Libraries Used: MFC

Problem: I have created a preference configuration application. To the left is a list box with the "parent" categories of settings they can change, and when they click one, the settings they can change appear to the right of the list box, like in many large preference dialogs. (See screenshot from the creator)

Here's my issue. I'm having a hard time using UpdateData because I never actually call DoModal() on the preference boxes because they're children of the parent dialog container, and they are just bound to the picture control in the dialog. I perform a combination of setting focus and showing/hiding the sub-dialogs.

When the user selects "Save These" they're presented with another dialog that allows them to check which specific preference panes they want to save (to generate XML configuration files). Obviously I need to scrape the dialog for their inputs, but when I call UpdateData, I'm always yelled at for calling UpdateData before calling DoModal().

Now I'm not really sure how to go about getting the values. It doesn't help either that I'm very new to MFC. So there's that. Anyhow, I would appreciate any help that anyone can offer.

~ Jon

1

1 Answers

2
votes

You don't have to call DoModal() in order to use UpdateData(). I am not sure what you mean by "Yelled at". To use UpdateData() you do need to use DDX (see also code project article). It is not clear from your question if you already use DDX by associating dlg control ids with data members.

In your scenario you will probably need to call UpdateData() when you move away from a specific dialog, to save the values on the screen to the data members.

A possible alternative you can consider is to use CTreePropSheet, a tree control based on CPropertySheet. You can also google CTreePropertySheet to find more implementations of a tree control for dialogs.