How to open project files in my app, like in Visual Studio
-
My goal is similar to how Visual Studio opens Project and Workspace files: those file types are associated with VS, but they don't open up Views in the middle of the screen, they just fill in some information. I want to imitate this for opening Projects in my application.:~ Are they using a doc/hidden view for this, or something tricky? :wtf: Any suggestions are appreciated. thanks, Jake
-
My goal is similar to how Visual Studio opens Project and Workspace files: those file types are associated with VS, but they don't open up Views in the middle of the screen, they just fill in some information. I want to imitate this for opening Projects in my application.:~ Are they using a doc/hidden view for this, or something tricky? :wtf: Any suggestions are appreciated. thanks, Jake
It's very simple Override InitialUpdateFrame in your DocTemplate like that
void CProjectDocTemplate::InitialUpdateFrame(CFrameWnd* pFrame, CDocument* pDoc,BOOL bMakeVisible)
{
__super :: InitialUpdateFrame(pFrame, pDoc, /*!!!!*/false);
}Moreover, you can even write so:
void CProjectDocTemplate::InitialUpdateFrame(CFrameWnd* pFrame, CDocument* pDoc,BOOL bMakeVisible)
{
pFrame->DestroyWindow();
}just set m_bAutoDelete to false in CYourDocument class before (constructor is the best place for it).
-
It's very simple Override InitialUpdateFrame in your DocTemplate like that
void CProjectDocTemplate::InitialUpdateFrame(CFrameWnd* pFrame, CDocument* pDoc,BOOL bMakeVisible)
{
__super :: InitialUpdateFrame(pFrame, pDoc, /*!!!!*/false);
}Moreover, you can even write so:
void CProjectDocTemplate::InitialUpdateFrame(CFrameWnd* pFrame, CDocument* pDoc,BOOL bMakeVisible)
{
pFrame->DestroyWindow();
}just set m_bAutoDelete to false in CYourDocument class before (constructor is the best place for it).
Sounds great, but I am just using CMultiDocTemplates in my code. I tried to make a subclass and override InitialUpdateFrame, but I get errors with the constructor, because CMultiDocTemplate has no default constructor. It doesn't seem like MFC wants DocTemplates to be subclassed, since we can't create them in the New Class wizard. So, how did you get that CProjectDocTemplate class? thanks, Jake
-
Sounds great, but I am just using CMultiDocTemplates in my code. I tried to make a subclass and override InitialUpdateFrame, but I get errors with the constructor, because CMultiDocTemplate has no default constructor. It doesn't seem like MFC wants DocTemplates to be subclassed, since we can't create them in the New Class wizard. So, how did you get that CProjectDocTemplate class? thanks, Jake
Jake Palmer wrote: Sounds great, but I am just using CMultiDocTemplates in my code. It does not matter. Look:
class CProjectDocTemplate : public CMultiDocTemplate
{
public:
CProjectDocTemplate ( UINT nIDResource, CRuntimeClass* pDocClass, CRuntimeClass* pFrameClass, CRuntimeClass* pViewClass );
...
}CProjectDocTemplate ::CProjectDocTemplate ( UINT nIDResource, CRuntimeClass* pDocClass, CRuntimeClass* pFrameClass, CRuntimeClass* pViewClass ):
CMultiDocTemplate(nIDResource, pDocClass, pFrameClass, pViewClass){
}
....
// ------- CXXXApp.InitInstance() --------//
AddDocTemplate( new CProjectDocTemplate(
IDR_DOC_PROJECT,
RUNTIME_CLASS(CProjectDoc), // document class
RUNTIME_CLASS(CMDIChildWnd), // frame class
RUNTIME_CLASS(CProjectView) // view class
));Where is the problem?
-
My goal is similar to how Visual Studio opens Project and Workspace files: those file types are associated with VS, but they don't open up Views in the middle of the screen, they just fill in some information. I want to imitate this for opening Projects in my application.:~ Are they using a doc/hidden view for this, or something tricky? :wtf: Any suggestions are appreciated. thanks, Jake
I found a solution: returning FALSE in my document's OnOpenDocument. I get to deal with the file the user opened, but then I don't have to mess around with a doc or view hanging around. How come nobody told me about that? :cool: Jake