Changing the SDI documents titles using PreCreateWindow as suggested by documentations RRS feed

  • 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.


    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());

    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;


    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=


    • 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


All replies

  • AFX_IDS_APP_TITLE is defined in the String Table as:

    "Hermes %s"


    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


    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
  • 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:





    Friday, December 14, 2018 10:32 AM