Question about DockPane, CView & Document |
Post Reply |
Author | |
freesong
Newbie Joined: 30 June 2005 Status: Offline Points: 3 |
Post Options
Thanks(0)
Posted: 02 July 2005 at 5:44am |
I'd like to create two DocPanes at the begin of program starting up, and I intend to add the imbeded views to the doc's view list, thus I can manage all views more easily, but error was occured for the doc obj. itself was not initialized. who know how the MFC framework could concord the doctemplate, doc, MainFrame, and views, why I cannot associate my newly created views with the Doc? I tried to use CCreateContext, but at the time, I can use this->GetActiveDocument(), or use this->GetActiveView()->GetDocument() in MainFrame to obtain the right Doc ptr. I'm Waiting for the correct methods. Best Regards
Edited by freesong |
|
freesong
Newbie Joined: 30 June 2005 Status: Offline Points: 3 |
Post Options
Thanks(0)
|
Hi, Does anyone has ideas, don't hesitate, just reply it. I'm wondering how the virtual function of OnCreateClient can pass the CCreateContext object correctly. How to construct it, wow, I'm bothering with it. |
|
pascal
Groupie Joined: 07 February 2005 Location: Germany Status: Offline Points: 25 |
Post Options
Thanks(0)
|
Hi, Ok, just a simple example: in your Applic.h: in your Applic.cpp: m_pTemplate = new CMultiDocTemplate(IDR_MAINFRAME,RUNTIME_CLASS(CYourDocument), RUNTIME_CLASS(CYourFrame), RUNTIME_CLASS(CYourView)); AddDocTemplate(m_pTemplate); What happened? you have created a document template, which will help you to create some views (CYourView) inside some frame windows (CYourframe) which are linked to a document (CYourDocument) Now we will create programatically a new view attached to the document. We have saved the templates's pointer to use it anywhere in the application class. And a least, we call the InitialUpdate frame. You have now a new MDI window. If you want to create a view inside a docking pane, that is very easy and you will find in this site a lot of example. A simple example now (from the MainFrm.cpp): CXTPDockingPane* pwndPane = m_paneManager.CreatePane( ASSERT(pwndPane); pwndPane ->AttachView( this, RUNTIME_CLASS(CYourView), m_pDocument, NULL);//m_pDocument can be created from a template class Now you have a docking pane with a view attached to a document. If you need to use your own frame (and not a CFrameWnd), have a look at the method "AttachView".
I Hope I helped you regards
|
|
Pascal Verdier
Software Engineer Manager |
|
freesong
Newbie Joined: 30 June 2005 Status: Offline Points: 3 |
Post Options
Thanks(0)
|
Thank you, though I've implemented this days before. I don't know if your method could attach newly created view to the viewlist of the document. I use app_ptr to get existed doc_ptr, and existed view_ptr, so I can construct a context, by this way I succeed in completing one doc- severay view structure.
Edited by freesong |
|
stranzl
Newbie Joined: 28 November 2005 Status: Offline Points: 1 |
Post Options
Thanks(0)
|
This works fine. But if you open and close more than one document thus destroying and creating the pane with a new view/doc attached, the application crashes when you exit. What is the proper function call sequence for "unattaching" the view after call AttachView? I'm getting a crash in the DocumentTemplate class when my app closes. |
|
Post Reply | |
Tweet
|
Forum Jump | Forum Permissions You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |