
access to controls on main form from dialog form
Quote:
> I have a domument view class MFC project with the base class as a CFormView.
> Now when I start the application it reads a file and displays it in a
> comboBox. From the menu I can add or delete items to or from the file. I
> need to update the main combobox on the main form and I am unsure of exactly
> how to get access to the ComboBox on the CFormView form while I am in the
> dialog box in order to reload the main ComboBox.
> Roger
Are you sure you want to do this? A dialog should have OK and Cancel
buttons, and the way to make the Cancel button work is to not change any
real data until and unless OK is hit. When you do it this way you would
save all the changes in data members of the dialog, such as a list or
array. Then when OK is hit DoModal returns and you copy the changes
from dialog variables into main variables (your combo box).
If that's not right for your program, then the answer to your question
is that the dialog needs a member variable that is a pointer to the
view. Initialize that from the view when you create the dialog, before
calling DoModal. The dialog can use the pointer to call view member
functions. Create some member functions for it to call, such as
InsertToCombo and DeleteFromCombo.
--
Scott McPhillips [VC++ MVP]