Tooltips and UNICODE RRS feed

  • Question

  • In my tooltips handler:

    MyClass::OnToolTips(UINT id, NMHDR * pNMHDR, LRESULT * pResult)



    I use the standard assignment of a String Table ID (nID) below to assign the tooltip text:

    pTTT->lpszText = MAKEINTRESOURCE(nID);

    where the string associated with nID is of the form:

    <Status Line Prompt>\n<Tooltip Text>

    This worked fine until I tried using UNICODE. When using UNICODE, the Status line prompt text works fine, but now instead of just the Tooltip Text appearing, the ENTIRE string (sans the "\n" separator) appears as the tooltip. For example, if nID is associated with the string "Statusline Help\nTooltip", then the tooltip appears as "Statusline HelpTooltip" - not what I wanted!

    The only workaround I could find was to replace the assignment using the MAKEINTRESOURCE with the following:

    AssignToolTip(pTTT->lpszText, nID)

    where the function AssingToolTip is given below:

    void AssignToolTip(LPTSTR lpszText, UINT nID)
    #ifdef _UNICODE
     CString str((LPCTSTR)nID);
     int index=str.Find('\n');
     str = str.Mid(index+1);
     lstrcpy(lpszText, str);
     pTTT->lpszText = MAKEINTRESOURCE(nID);

    This works correctly for both MBCS and UNICODE builds, but I am wondering if this is a bug in the way MS VC 2005 is handling the MAKEINTRESOURCE resource ID. Or am I doing something else wrong?

    Thanks for any advice you can provide.

    Tuesday, August 23, 2011 1:32 PM