CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 9 of 9
  1. #1
    Join Date
    Jan 2005
    Posts
    126

    Cool A Question about SDI

    When file open is selected by the user the method,
    CMyProgDoc::Serialize(CArchive& ar) is called.

    I have in my application a LeftView class which is
    derived from CTreeView...

    My question is how do I pass the data in to the LeftView
    class from the Doc Class?

    I mean I could call a method of the LeftView class with the CArchive
    as a parameter, but how do I get the instance of the LeftView class
    within the Doc Class so that I can call the method?

    Where should the data object that was read in from a file be stored
    ie.. which class?

    TIA
    B
    Last edited by bobbob; January 30th, 2005 at 09:59 PM.

  2. #2
    Join Date
    Jun 2004
    Posts
    170

    Re: A Question about SDI

    If i right understand you:

    MSDN:
    "When data in a document changes, the view responsible for the changes typically calls the CDocument::UpdateAllViews function for the document, which notifies all the other views by calling the OnUpdate method for each. The default implementation of OnUpdate invalidates the entire client area of the view. You can override it to invalidate only those regions of the client area that map to the modified portions of the document."

    So in you document add data to some class and call UpdateAllViews(), then in view OnUpdate call GetDocument() and check data in document.

  3. #3
    Join Date
    May 1999
    Location
    ALABAMA, USA
    Posts
    9,917

    Re: A Question about SDI

    Quote Originally Posted by TOMNKZ
    So in you document add data to some class and call UpdateAllViews(), then in view OnUpdate call GetDocument() and check data in document.
    Of course providing that view is wired to a document and document serves as repository of the view’s data and view does not hold any data that should be persistent outside of the document.
    There are only 10 types of people in the world:
    Those who understand binary and those who do not.

  4. #4
    Join Date
    Jan 2005
    Posts
    126

    Re: A Question about SDI

    My view doesn't have an OnUpdate member function...
    Can I simply add one or is there a message map that also needs to go along with this?

  5. #5
    Join Date
    May 1999
    Location
    ALABAMA, USA
    Posts
    9,917

    Re: A Question about SDI

    OnUpdate is one of virtual overrides not a message handler. Simply choose add virtual function and wizard will insert it for you.
    You will have to have GetDocument overridden too, and all data that is to be serialized should be in a document object, if you do not want to call view’s Serialize.
    There are only 10 types of people in the world:
    Those who understand binary and those who do not.

  6. #6
    Join Date
    Jan 2005
    Posts
    126

    Re: A Question about SDI

    Why does OnUpdate get called twice.
    Is there something in the parameters to tell me why its being called?
    How should I handle them so that I only have to display once per physical change?

  7. #7
    Join Date
    Feb 2000
    Location
    San Diego, CA
    Posts
    10,354

    Re: A Question about SDI

    It can get called any number of times. If you want to distinguish between updates, you can send your own lHint , pHint in UpdateAllViews

  8. #8
    Join Date
    Jan 2005
    Posts
    126

    Cool Re: A Question about SDI

    Quote Originally Posted by TOMNKZ
    If i right understand you:

    MSDN:
    "When data in a document changes, the view responsible for the changes typically calls the CDocument::UpdateAllViews function for the document, which notifies all the other views by calling the OnUpdate method for each. The default implementation of OnUpdate invalidates the entire client area of the view. You can override it to invalidate only those regions of the client area that map to the modified portions of the document."

    So in your document add data to some class and call UpdateAllViews(), then in view OnUpdate call GetDocument() and check data in document.
    This makes sence except that I want to get the CTreeView and I can only find a method to get the TreeCntrl. I want to update the tree. Do I use the CTreeView or do I use the CTreeCtrl?

    CUPnPTKDoc* pDoc = GetDocument();
    CTreeCtrl& Tree = GetTreeCtrl();
    Last edited by bobbob; February 7th, 2005 at 06:30 PM.

  9. #9
    Join Date
    May 1999
    Location
    ALABAMA, USA
    Posts
    9,917

    Re: A Question about SDI

    Tree view is a tree view control.

    It is window created using window class SysTreeView32 class.
    As any other window it processed messages.

    Tree view control is wrapped by CTreeCtrl class and CTreeView class to make tree view control behaving like a view.

    If you want to access functionality specific to the CTreeCtrl class then call GetTreeCtrl. To expose underlying tree view control wrapper.
    There are only 10 types of people in the world:
    Those who understand binary and those who do not.

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