【问题标题】:MFC CMenu tooltip not being displayedMFC CMenu 工具提示未显示
【发布时间】:2011-09-30 10:35:32
【问题描述】:

我尝试使用类似这样的方法来设置 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。

感谢任何帮助!

【问题讨论】:

  • 尝试在 Visual Studio 设计器中设置菜单属性中的文本。我不是 100% 清楚完整的上下文,但似乎这可能是 MFC 问题。
  • 您是否也尝试过添加MF_STRING 位?例如。 menu->ModifyMenu( id, MF_BYCOMMAND | MF_STRING, id, "Click here\nThis is the tooltip for the menu item ...");
  • 感谢您的 cmets。 @JonathanWood:我已经尝试过了(请参阅我的原始帖子)并且效果相同。 @JonasGulle:MF_STRING 位也没有任何作用。
  • 我认为 \r\n 可能会这样做。 MFC 总是\r\n

标签: c++ windows mfc tooltip cmenu


【解决方案1】:

Looks like an duplicate

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

【讨论】:

  • 不起作用。结果与单独使用\n 相同。文本显示在一行中并完全忽略换行符。 (请注意,\r\n 仍在文本中,因为使用 GetMenuString 获取确实会复制字符串中的两个字符)
【解决方案2】:

也许你还没有将 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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-01-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多