CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Jun 1999
    Posts
    14

    How are the new forms indexed in an MDI???????????

    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


  2. #2
    Guest

    Re: How are the new forms indexed in an MDI???????????

    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


  3. #3
    Join Date
    Jun 1999
    Posts
    42

    Re: How are the new forms indexed in an MDI???????????

    Do you have any sample code using OnUpdate() ? I can't find anything in MS SDK.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured