Blacktempel
Blacktempel

Reputation: 3995

Adding a tooltip to CMenu item(s)

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

Upvotes: 12

Views: 1549

Answers (1)

user1
user1

Reputation: 4131

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

Upvotes: 1

Related Questions