12

A while ago, I have tried to add a tooltip for testing purposes on a CMenu item. Now I would need it, and I'm facing the same issue again.

This question and answer(s): MFC : How to add tooltip in Cmenu items?
doesn't help me at all, as this "newline magic" is simply not working.

Also, it seems like I'm not the only one having problems with it: MFC CMenu tooltip not being displayed

void CTextListCtrl::CreateMenu(void)
{
    m_Menu.CreateMenu();
    CMenu submenu;
    submenu.CreatePopupMenu();
    submenu.AppendMenuW(MF_STRING, IDC_RESEND_POPUP, L"&Resend\nShow me the tooltip");
    //Other menu items...
    m_Menu.AppendMenuW(MF_POPUP, reinterpret_cast<UINT_PTR>(submenu.m_hMenu), L"");
    submenu.Detach();
}

The result is this:

enter image description here

However, increasing the letters of the text results in a bigger pop-up menu, not a menu tooltip.

I have seen the other links in this answer, and checked them and the projects. But these are not what I want.

Does someone know what I did wrong, or is there another solution/source which could be helpful ?


Edit: As I have mentioned before in a comment, here is a sample solution with minimum requirements to reproduce the problem. (See CMenuListCtrl.cpp(100))
Tested with VS2010 & VS2015 (same result).

Community
  • 1
  • 1
Blacktempel
  • 3,935
  • 3
  • 29
  • 53

1 Answers1

1

Here's trick that will fix your problem, "newline magic" will work for sure.

Ensure that you are using version 6 of ComCtl32.dll.

Add below block in stdafx.h file and rebuild your project.

#pragma comment(linker, "\"/manifestdependency:type='win32'\
name='Microsoft.Windows.Common-Controls' version='6.0.0.0' \
processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")

enter image description here

user1
  • 4,031
  • 8
  • 37
  • 66
  • This is in `stdafx.h` by default and it does not work. – Blacktempel Aug 17 '15 at 09:27
  • Can you share with me your VC++ solution? – user1 Aug 17 '15 at 09:28
  • [Solution uploaded](http://s000.tinyupload.com/index.php?file_id=07597732216098941519) with minimum requirements to reproduce the problem. Assume `CMenu` can be in any other class or control too. – Blacktempel Aug 17 '15 at 10:19
  • visit http://www.codeproject.com/Articles/217588/Porting-a-legacy-MFC-app-to-MFC-Feature-Pack, sample includes CMenuToolTip class, See how it is used. See OnMenuSelect() – user1 Aug 17 '15 at 11:34
  • This is for a document based MFC application and I have seen this easier done in the Microsoft samples before. However, this is a dialog based application. There's just a plain `CMenu` and submenu(s). The `CMenu` can either be a system-menu as in your screenshot, or a pop-up on a `CListCtrl`, `CComboBox` or on an other control. I have also seen and checked [the project with a similar dialog](http://www.codeguru.com/cpp/controls/controls/tooltipcontrols/article.php/c5233/Tooltips-for-Menu-Items-and-Popup-Menu-Items.htm) - the delivered `.exe` in the project works. Compiling it does not. (no TT) – Blacktempel Aug 18 '15 at 07:51