MFC CMenu工具提示未显示

时间:2011-07-07 12:36:45

标签: c++ windows mfc tooltip cmenu

我尝试使用类似这样的东西设置CMenu项目的工具提示(如here所述),但它只显示在一行中,并且换行符不可见。

// read control id
UINT id = menu->GetMenuItemID(1235);
// modify caption and add tooltip?
menu->ModifyMenu( id, MF_BYCOMMAND, id, "Click here\nThis is the tooltip for the menu item ...");

我还尝试直接在菜单项的visual studio资源设计器中设置标题,效果相同。 你能给我任何关于什么错误的提示吗?我在Windows 7上使用VS2008。

感谢任何帮助!

2 个答案:

答案 0 :(得分:1)

也许您还没有将windows xp常用控件添加到您的应用程序中。

尝试将常用控件添加到stdafx.h:

#ifdef UNICODE
#if defined _M_IX86
#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'\"")
#elif defined _M_IA64
#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='ia64' publicKeyToken='6595b64144ccf1df' language='*'\"")
#elif defined _M_X64
#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='amd64' publicKeyToken='6595b64144ccf1df' language='*'\"")
#else
#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")
#endif
#endif

答案 1 :(得分:1)

Looks like an duplicate

主要是你应该使用\ r \ n而不是\ n,因为这是mfc所期望的。