Answered by:
Changing the SDI documents titles using PreCreateWindow as suggested by documentations

Question
-
I want to connect the main SDI window with a CDockablePane. I thought a GUID might do the trick. In order to see the result I want to change the title of the current document to include the GUID, but it seems that when PreCreateWindow (ANY PrecreateWindow, ChilFrm, CMainFrame, you name it) is called, the Document isnt created yet and the I want to use the GUID to identify the document.
[CODE]
BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
{
if( !CMDIFrameWndEx::PreCreateWindow(cs) )
return FALSE;
cs.style &= ~(LONG)FWS_ADDTOTITLE;
CMainFrame *pFrm = GetMainFrame();
CHermesDoc *pDoc = reinterpret_cast<CHermesDoc *>(GetMainFrame()->GetActiveDocument());
ASSERT(pDoc);
ASSERT(pDoc->IsKindOf(RUNTIME_CLASS(CHermesDoc)));
GUID *pGUID = pDoc->GetID();
TRACE("\t%s\n", GUIDAsString(*pGUID));
CString strName;
strName.Format(AFX_IDS_APP_TITLE, GUIDAsString(*pGUID));
_tprintf(_T("%s"), (LPCTSTR)strName);
TRACE("\t%s\n", strName);
return TRUE;
}[/CODE]
This fails because the CDocument hasn´t been created yet, and as such the GetDocument call returns a nullptr.
I´ve tried doing this after OnCreate has been cak'lled but with the same result. How can I change the caption of the CView-derivative based on an ID created in the CDocument=
Regards.
- Edited by sbrothy Friday, December 14, 2018 3:36 AM
- Moved by May Luo-MSFT Friday, December 14, 2018 8:20 AM its WFC issue
Friday, December 14, 2018 3:35 AM
Answers
-
Hello,
you should ask here: https://social.msdn.microsoft.com/Forums/en-US/home?forum=vcgeneral
Regards, Guido
- Proposed as answer by May Luo-MSFT Friday, December 14, 2018 9:35 AM
- Marked as answer by Richard MuellerMVP, Banned Friday, December 21, 2018 12:56 PM
Friday, December 14, 2018 8:57 AM
All replies
-
AFX_IDS_APP_TITLE is defined in the String Table as:
"Hermes %s"
Regards.
Friday, December 14, 2018 3:37 AM -
Hi sbrothy,
Welcome to the MSDN forum.
Since our forum is mainly discussing with VS IDE. As you said, you want to connect the main SDI window with a CDockablePane. This question has no more knowledge here that could help you. So I will help you to move it to Where is the Forum for…? Forum, there is someone who can help you to redirect it to an appropriate forum for a more professional supporting!
Thank you for your understanding,
Best Regards
May
MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com
Friday, December 14, 2018 8:19 AM -
Hello,
you should ask here: https://social.msdn.microsoft.com/Forums/en-US/home?forum=vcgeneral
Regards, Guido
- Proposed as answer by May Luo-MSFT Friday, December 14, 2018 9:35 AM
- Marked as answer by Richard MuellerMVP, Banned Friday, December 21, 2018 12:56 PM
Friday, December 14, 2018 8:57 AM -
Sorry I mistook IDE as meaning "use of Visual Studio". Ie.: Programming. :)
The thread should go in VC++ Programming, if some such exists.
For completeness sake, this is where the answers are:
https://docs.microsoft.com/en-us/cpp/mfc/creating-new-documents-windows-and-views?view=vs-2017
https://docs.microsoft.com/en-us/cpp/mfc/documents-views-and-the-framework?view=vs-2017
Regards,
Søren
Friday, December 14, 2018 10:32 AM