-
January 30th, 2005, 09:51 PM
#1
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.
-
January 31st, 2005, 03:35 AM
#2
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.
-
January 31st, 2005, 01:54 PM
#3
Re: A Question about SDI
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.
-
January 31st, 2005, 07:22 PM
#4
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?
-
January 31st, 2005, 08:56 PM
#5
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.
-
February 1st, 2005, 05:25 PM
#6
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?
-
February 1st, 2005, 06:10 PM
#7
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
-
February 7th, 2005, 06:23 PM
#8
Re: A Question about SDI
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.
-
February 7th, 2005, 06:42 PM
#9
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|