FIX: CFrameWnd::UpdateFrameTitle() Removes Text after Hyphen

Last reviewed: September 18, 1997
Article ID: Q113294
1.00    | 1.00
WINDOWS | WINDOWS NT kbprg kbfixlist kbbuglist

The information in this article applies to:

  • The Microsoft Foundation Classes (MFC) included with:

        - Microsoft Visual C++ for Windows, version 1.0
        - Microsoft Visual C++ 32-bit Edition, version 1.0
    

SYMPTOMS

When an SDI or MDI application is created using AppWizard, the CFrameWnd::UpdateFrameTitle function normally inserts the document name into the title of the corresponding application's frame window. If a hyphen is inserted into the title of the application, however, the title will be truncated at the inserted hyphen and the document name will be appended to the right of the hyphen.

For example, if the application has the name "My-WinApp" and the document name is FIDO.DOC, when the document is opened, the resulting text will appear in the caption bar as "My - FIDO.DOC".

CAUSE

The following code is an excerpt from WINFRM.CPP, beginning on line 857:

void CFrameWnd::UpdateFrameTitleForDocument(const char* pszDocName)
{
    ...

    // keep the original title up to first '-'
    LPSTR pchDash = _AfxStrChr(szText, '-');
    LPSTR pchPrev;
    if (pchDash != NULL &&
       *(pchPrev = AnsiPrev(szText, pchDash)) == ' ')
          pchDash = pchPrev;

    //  remove anything after "-" or " -"
    if (pchDash != NULL)
          *pchDash = '\0';

    // get name of currently active view
    if (pszDocName != NULL)
    {
        lstrcat(szText, " - ");
        lstrcat(szText, pszDocName);
        // add current window # if needed
        if (m_nWindow > 0)
            wsprintf(szText + lstrlen(szText), ":%d", m_nWindow);
    }
}

The cause of the problem is line 871, where a NULL character replaces the first hyphen found in the title.

STATUS

Microsoft has confirmed this to be a problem with version 2.0 of the Microsoft Foundation Class Libraries for Windows and Windows NT. This problem was corrected in the Microsoft Foundation Classes version 2.5.


Additional reference words: 1.00 2.00 2.10
KBCategory: kbprg kbfixlist kbbuglist
KBSubcategory: MfcUI
Keywords : MfcUI kbbuglist kbfixlist kbprg
Technology : kbMfc
Version : 1.00 | 1.00
Platform : NT WINDOWS
Solution Type : kbfix


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: September 18, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.