MDI File Open
-
Hi. Where should I put the codes for reading binary files if I have created a MDI application with CFormView? Do I need to use the serialize function?
ReturnRain wrote:
Do I need to use the serialize function?
Yes. That's what document view architecture is all about?
Nibu thomas A Developer Programming tips[^] My site[^]
-
ReturnRain wrote:
Do I need to use the serialize function?
Yes. That's what document view architecture is all about?
Nibu thomas A Developer Programming tips[^] My site[^]
okay.. so I use this? if(ar.IsStoring()) ... else ... where do I put this then? if (m_ldFile.DoModal() == IDOK) { // Get the pathname selected m_filePath = m_ldFile.GetPathName(); ... I just don't get on how to use the serialize function to open file. And how do I have this data to the view part?
-
okay.. so I use this? if(ar.IsStoring()) ... else ... where do I put this then? if (m_ldFile.DoModal() == IDOK) { // Get the pathname selected m_filePath = m_ldFile.GetPathName(); ... I just don't get on how to use the serialize function to open file. And how do I have this data to the view part?
ReturnRain wrote:
okay.. so I use this? if(ar.IsStoring()) ... else ...
You misunderstood Serialize function. Serialize function is the place where you do the writing to a file to make your document data persistent. if( ar.IsStoring() ) // Write here code for saving your data else // Write here code for loading data You don't have to worry about opening and closing the file it's done for you by Doc/View architecture.
CArchive
contains a valid open file. So you need to just use the overloaded << and >> operators. Well if you have a byte array you have to useCArchive::Write
. Since you said you have an MDI application, you should have File, Edit and other menus.
Nibu thomas A Developer Programming tips[^] My site[^]
-
ReturnRain wrote:
okay.. so I use this? if(ar.IsStoring()) ... else ...
You misunderstood Serialize function. Serialize function is the place where you do the writing to a file to make your document data persistent. if( ar.IsStoring() ) // Write here code for saving your data else // Write here code for loading data You don't have to worry about opening and closing the file it's done for you by Doc/View architecture.
CArchive
contains a valid open file. So you need to just use the overloaded << and >> operators. Well if you have a byte array you have to useCArchive::Write
. Since you said you have an MDI application, you should have File, Edit and other menus.
Nibu thomas A Developer Programming tips[^] My site[^]
-
okay.. thanks! and since MDI have a different class for doc and view, how do I get the data from doc to view? i want to store the data in an array that I have declared in view.
ReturnRain wrote:
and since MDI have a different class for doc and view, how do I get the data from doc to view? i
Call
CYourDocument::UpdateAllViews
. From MSDN: Call this function after the document has been modified. You should call this function after you call the SetModifiedFlag member function. This function informs each view attached to the document, except for the view specified by pSender, that the document has been modified. You typically call this function from your view class after the user has changed the document through a view.
Nibu thomas A Developer Programming tips[^] My site[^]
-
Hi. Where should I put the codes for reading binary files if I have created a MDI application with CFormView? Do I need to use the serialize function?
ReturnRain wrote:
Do I need to use the serialize function?
You can, but it's certainly not a requirement. The document holds the data, regardless of how it is acquired. The view renders said data.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne