MFC doc/view with non-file-based documents
-
I've got a doc/view app where my document contains data *not* stored in a file. How do I create a new document/view pair without passing in a filename to CWinApp::OpenDocumentFile()? I need to attach my in-memory data to the document early on enough in the process for the view to be able to retrieve it in OnInitialUpdate(). Right now I store a pointer to the in-memory data in a global before calling OpenDocumentFile() and the document class constructor picks it up from there but obviously this is not real pretty :-)
he he he. I like it in the kitchen! - Marc Clifton (on being flamed) Awasu v0.4a[^]: A free RSS reader with support for Code Project.
-
I've got a doc/view app where my document contains data *not* stored in a file. How do I create a new document/view pair without passing in a filename to CWinApp::OpenDocumentFile()? I need to attach my in-memory data to the document early on enough in the process for the view to be able to retrieve it in OnInitialUpdate(). Right now I store a pointer to the in-memory data in a global before calling OpenDocumentFile() and the document class constructor picks it up from there but obviously this is not real pretty :-)
he he he. I like it in the kitchen! - Marc Clifton (on being flamed) Awasu v0.4a[^]: A free RSS reader with support for Code Project.
Just process on new document and populate the data in the document. As for the file name just forget it, only visible trace that it is still being used it in the main frame, you can remove it by removing the bit FW_ADDTOTITLE in the mainframe's OnCreate.
-
Just process on new document and populate the data in the document. As for the file name just forget it, only visible trace that it is still being used it in the main frame, you can remove it by removing the bit FW_ADDTOTITLE in the mainframe's OnCreate.
Thanks for the reply. But... 1) Since OpenDocumentFile() only takes a LPCTSTR (the filename), I guess I was asking what is the correct way to pass a pointer to my in-memory data so that the document object gets it when it is eventually created. 2) FWS_ADDTOTITLE only controls whether the MDI child window's title gets included in the main window's title. Clearing it in my document frame class stops the "filename" from appearing in the MDI child windows but MFC uses my application name instead! I haven't yet figured out a way to put *my* title in there.
he he he. I like it in the kitchen! - Marc Clifton (on being flamed) Awasu v0.4a[^]: A free RSS reader with support for Code Project.
-
Thanks for the reply. But... 1) Since OpenDocumentFile() only takes a LPCTSTR (the filename), I guess I was asking what is the correct way to pass a pointer to my in-memory data so that the document object gets it when it is eventually created. 2) FWS_ADDTOTITLE only controls whether the MDI child window's title gets included in the main window's title. Clearing it in my document frame class stops the "filename" from appearing in the MDI child windows but MFC uses my application name instead! I haven't yet figured out a way to put *my* title in there.
he he he. I like it in the kitchen! - Marc Clifton (on being flamed) Awasu v0.4a[^]: A free RSS reader with support for Code Project.
If you have a pointer the document template class you can do something like:
// create an empty document/view
CMyDocument *pDoc = (CMyDocument*)pDocTemplate->OpenDocumentFile(NULL);// make it use my non file data
pDoc->UseThisData(pYourData);
pDoc->UpdateAllViews();Roger Allen Sonork 100.10016 In case you're worried about what's going to become of the younger generation, it's going to grow up and start worrying about the younger generation. - Roger Allen, but not me!
-
If you have a pointer the document template class you can do something like:
// create an empty document/view
CMyDocument *pDoc = (CMyDocument*)pDocTemplate->OpenDocumentFile(NULL);// make it use my non file data
pDoc->UseThisData(pYourData);
pDoc->UpdateAllViews();Roger Allen Sonork 100.10016 In case you're worried about what's going to become of the younger generation, it's going to grow up and start worrying about the younger generation. - Roger Allen, but not me!
Tried that. I was hoping to be able to use CWinApp::OpenDocumentFile() since it takes care of the case where the document is already open. Doesn't like a NULL or empty filename, though. I jst thought there might be a Better Way. Oh well :-( Thanks
he he he. I like it in the kitchen! - Marc Clifton (on being flamed) Awasu v0.4a[^]: A free RSS reader with support for Code Project.