Click to See Complete Forum and Search --> : How are the new forms indexed in an MDI???????????


cmontano
June 4th, 1999, 10:30 AM
I have figured out how to initially create multiple form documents. When I created the new forms in the MDI, I simply used OnFileNew() to create separate instances of that form. What I need to know now is how those different forms are indexed so that each one can be carrying out a different function than the others.

For example, my program will eventually be controlling four sensors through an A/D converter, all of which will need this same form, but if I want to control each sensor separately, I need to know how each form is indexed so that if I want to turn one sensor on, while the others stay off, I can do this.

Thanks for any suggestions
Dr_Confused

June 4th, 1999, 07:24 PM
You can access each formview in turn via CDocument::GetFirstViewPosition followed by CDocument::GetNextView. AFAIAA there is no reliable index for the views (the position returned by GetNextView for a particular view may change if views are deleted).

If you need to know which view is which, you can provide your own data member to hold a view state or suchlike. You can get one view to notify all the other views of a change in state via CDocument::UpdateAllViews(). CDocument passes on the details of this to the other views via CView::OnUpdate(). This provides user-defined arguments ('hints') and a pointer to the originating view, so the receiving views can act appropriately.

For example if one view sensor is turned on, it can call UpdateAllViews passing the code for 'Sensor Activated', and all views receiving this code in their OnUpdate method can then turn their sensors off, or whatever...

Dave

vlim
June 18th, 1999, 06:20 PM
Do you have any sample code using OnUpdate() ? I can't find anything in MS SDK.