|
-
May 1st, 1999, 09:58 AM
#1
EXPERTS . . please explain . .
Please bear with me here. 1st, I'm not trying to short-cut the learning curve, but the (2) books I am studying really do not make it clear how doc data is kept up-to-date.
I understand the basis doc-view relationships & DDX to copy control data to member variables in the view class . . . but when & where do the variables in the doc class get updated? Is there anything automatic going on (similar to DDX)?
For example, assume your only data (in your doc class) is say, CString mystr . . . and you derive your view from a CFormView & initialize the view variable mystr & the user (by using an edit control in your MyFormView class enters data. The DDX copies the new data from your control to the variable in the view class. How does the mystr variable in the doc class get (updated) the new data? Seems like there should be something similar to the DDX mechanism to update the variables in the doc class.(?) Does the programmer have to copy the content of the variables contained in the view class to the variables contained in the doc class? If so, when is this normally done . . within what function of the view class?
Thanks alot for any simple explanations.
-
May 1st, 1999, 02:16 PM
#2
Re: EXPERTS . . please explain . .
Well, as far as i know there isn't a mechanism similar to the DDX that updates the
data in your document class.
You have to do it manually (at least i think so!).
I.e. you could do it after the user entered text into the edit control like this:
(assuming you stored the data of the edit control in m_mystr)
CMyDoc* pDoc = GetDocument ();
pDoc->m_DocStr = m_mystr;
It depends on what you want to do with the data, when to update the m_DocStr.
You could update it in an OnEditChange-Notification handler or an OnEditKillFocus or similar.
hope this helps.
regards.
Alan.
-
May 1st, 1999, 06:37 PM
#3
Re: EXPERTS . . please explain . .
...or you could use UpdateData(false) to get the data transferred to the data member from the control. Visa vi UpdateData(true) to get the control updated with member variable data.
-
May 1st, 1999, 09:59 PM
#4
Re: EXPERTS . . please explain . .
Of course, that updates the member variable in the view or dialog class, not the document. I now believe Alan (other response) is correct, in that the programmer must copy the data from his view to the corresponding member variables in his doc class manually, using the doc pointer. Thanks very much for your response!
-
May 1st, 1999, 10:01 PM
#5
Re: EXPERTS . . please explain . .
Thanks Alan! Your response has been very helpful . . . and I believe you are correct. Thanks again.
-
May 1st, 1999, 10:10 PM
#6
Re: EXPERTS . . please explain . .
Ooops, sorry. I'm still somewhat new, and thought I might take a crack at that one... I don't have a real clear understanding of the relationships between a view and a document. I am working on an SDI application, still in the beginning phase, but it almost sounds as if what your problem was will end up becoming a problem for me when I get to serializing the data. Am I correct in that? If you wouldn't mind, maybe you could shed a little light in the realm for me. Thanks much....
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
|