Microsoft KB Archive/217208

= FIX: The CMenu::GetMenuString method truncates menu strings that longer than 256 characters =

Article ID: 217208

Article Last Modified on 11/21/2006

-

APPLIES TO

 Microsoft Foundation Class Library 4.2, when used with:  Microsoft Visual C++ 6.0 Enterprise Edition

 Microsoft Visual C++ 6.0 Professional Edition

 Microsoft Visual C++ 6.0 Standard Edition 

-

<div class="notice_section">

This article was previously published under Q217208

<div class="symptoms_section">

SYMPTOMS
The CMenu::GetMenuString method truncates menu strings longer than 256 characters. This problem is most commonly seen when retrieving a file name from the "most recently used" list on the File menu. These file names are occasionally longer than 256 characters.

<div class="cause_section">

CAUSE
The CMenu member function int CMenu::GetMenuString(UINT nIDItem, CString& rString, UINT nFlags) const, hard codes the maximum length for a retrieved menu string at 256 characters. See VC98\MFC\Include\Afxwin.h, line 1043.

<div class="resolution_section">

RESOLUTION
To work around this problem, use the LPTSTR version of this function; for example, int CMenu::GetMenuString(UINT nIDItem, LPTSTR lpString, int nMaxCount, UINT nFlags) const.

<div class="status_section">

STATUS
Microsoft has confirmed that this is a bug in the Microsoft products that are listed in the "Applies to" section.

This bug was corrected in Visual Studio 6.0 Service Pack 3. For more information about Visual Studio service packs, click the following article numbers to view the articles in the Microsoft Knowledge Base:

194022 Visual Studio 6.0 service packs, what, where, why

194295 How to tell that a Visual Studio service pack is installed

<div class="moreinformation_section">

Steps to reproduce the behavior

 * 1) Use CMenu::AppendMenu(UINT nFlags, UINT nIDNewItem, LPCTSTR lpszNewItem) to append a menu item longer than 256 characters in length.
 * 2) Retrieve the menu item using CMenu::GetMenuString(UINT nIDItem, CString& rString, UINT nFlags).

RESULTS: Note that the string is truncated to a length of 255 characters.

Keywords: kbfunctions kbqfe kbtshoot kbbug kbfix kbnoupdate kbuidesign kbvs600sp3fix KB217208

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.