access to controls on main form from dialog form 
Author Message
 access to controls on main form from dialog form

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



Sat, 05 Nov 2005 09:11:15 GMT  
 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]



Sat, 05 Nov 2005 11:47:18 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. EASY: Access FORM As controls From FORM B ???

2. Access a running form (3 forms playing)

3. Adding controls(mainly buttons) to SDI main form!?!

4. Program to convert simple html forms to aspx form controls

5. Displaying XML in a System.Windows.Forms.Form control

6. Access mdiChild Form Control ???

7. accessing controls in onr form from another from

8. Create ActiveX Control for MS Access 2000 Forms

9. I'm looking for a control witch work like Access sub forms

10. dialog, form view, and control layout on different system

11. dialog, form view, and control layout on different systems

12. dialog, form view, and control layout on different systems

 

 
Powered by phpBB® Forum Software