简体   繁体   中英

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:

在此输入图像描述

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

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='*'\"")

在此输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM