Closing initial Document in MDI
-
Hi, I'm wondering if anyone knows how I can get rid of the initial document window that displays when an MFC MDI program first starts up? I am writing a program that would acquire images from a scanner. It would not make sense to have an empty white canvas before acquring any scans. I believe there's a function OnDocumentClose function I can use, but I have no idea where I can place such a call. Also, how would I create a new canvas? Is there a "OnDocumentOpen" of sort? Thanks! Jerry
-
Hi, I'm wondering if anyone knows how I can get rid of the initial document window that displays when an MFC MDI program first starts up? I am writing a program that would acquire images from a scanner. It would not make sense to have an empty white canvas before acquring any scans. I believe there's a function OnDocumentClose function I can use, but I have no idea where I can place such a call. Also, how would I create a new canvas? Is there a "OnDocumentOpen" of sort? Thanks! Jerry
You can suppress this 'new file' action with
cmdInfo.m\_nShellCommand = CCommandLineInfo::FileNothing;
in your apps InitInstance. Doesn't work for SDI though.
-
Hi, I'm wondering if anyone knows how I can get rid of the initial document window that displays when an MFC MDI program first starts up? I am writing a program that would acquire images from a scanner. It would not make sense to have an empty white canvas before acquring any scans. I believe there's a function OnDocumentClose function I can use, but I have no idea where I can place such a call. Also, how would I create a new canvas? Is there a "OnDocumentOpen" of sort? Thanks! Jerry
To answer your second question the way I've always done it is as follows: 1) Find the document template (each template is a different doc/view class - you probably only have one in which case just ignore the last two lines)... POSITION DocPosition; DocPosition = GetFirstDocTemplatePosition(); CDocTemplate* first_template = GetNextDocTemplate(DocPosition); CDocTemplate* second_template = GetNextDocTemplate(DocPosition); CDocTemplate* third_template = GetNextDocTemplate(DocPosition); 2) Create a new file CSomethingDoc* newdoc = STATIC_DOWNCAST(CSomethingDoc, first_template->CreateNewDocument()); 3) Do any work in the Document class you need to and then show the new file CFrameWnd* newframe = first_template->CreateNewFrame(newdoc, NULL); newframe->InitialUpdateFrame(newdoc, TRUE); Hope that helps. -Dave
-
To answer your second question the way I've always done it is as follows: 1) Find the document template (each template is a different doc/view class - you probably only have one in which case just ignore the last two lines)... POSITION DocPosition; DocPosition = GetFirstDocTemplatePosition(); CDocTemplate* first_template = GetNextDocTemplate(DocPosition); CDocTemplate* second_template = GetNextDocTemplate(DocPosition); CDocTemplate* third_template = GetNextDocTemplate(DocPosition); 2) Create a new file CSomethingDoc* newdoc = STATIC_DOWNCAST(CSomethingDoc, first_template->CreateNewDocument()); 3) Do any work in the Document class you need to and then show the new file CFrameWnd* newframe = first_template->CreateNewFrame(newdoc, NULL); newframe->InitialUpdateFrame(newdoc, TRUE); Hope that helps. -Dave
Hi Dave, it's been a while, but thanks for your posted reply on how to create a new document in CWinApp. I didn't get a chance to implement it until now. I have a follow up question I hope you can help me with. The code you described to me is for CWinApp class. How would I be able to do the same thing inside MainFrm class? Obiously GetFirstDocTemplatePosition() is only exsistant in CWinApp, and I do not know of a way to acquire a pointer to CWinApp from MainFrm. Would you know a way to do that? I appreciate it. Thank you. Jerry
-
Hi Dave, it's been a while, but thanks for your posted reply on how to create a new document in CWinApp. I didn't get a chance to implement it until now. I have a follow up question I hope you can help me with. The code you described to me is for CWinApp class. How would I be able to do the same thing inside MainFrm class? Obiously GetFirstDocTemplatePosition() is only exsistant in CWinApp, and I do not know of a way to acquire a pointer to CWinApp from MainFrm. Would you know a way to do that? I appreciate it. Thank you. Jerry
-
Worked like a charm!! :-D Thank you thank you.
-
Hi Dave, it's been a while, but thanks for your posted reply on how to create a new document in CWinApp. I didn't get a chance to implement it until now. I have a follow up question I hope you can help me with. The code you described to me is for CWinApp class. How would I be able to do the same thing inside MainFrm class? Obiously GetFirstDocTemplatePosition() is only exsistant in CWinApp, and I do not know of a way to acquire a pointer to CWinApp from MainFrm. Would you know a way to do that? I appreciate it. Thank you. Jerry
No problem... Try looking into AfxGetApp() -Dave