11

I tried using something like this to set the tool tip of a CMenu item (as described here) but it is just being displayed in a single line and the line break is not visible.

// 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 ...");

I also tried to set the caption directly in the visual studio resource designer of the menu item with the same effect. Can you give me any hints on whats wrong? I am using VS2008 on windows 7.

Any help is appreciated!

Community
  • 1
  • 1
Norman
  • 123
  • 5
  • Trying setting the text in the menu properties, in the Visual Studio designer. I'm not 100% clear on the full context but it seems like this might be an MFC issue. – Jonathan Wood Jul 07 '11 at 12:46
  • Have you tried adding the `MF_STRING` bit too? E.g. `menu->ModifyMenu( id, MF_BYCOMMAND | MF_STRING, id, "Click here\nThis is the tooltip for the menu item ...");` – Jonas Engström Jul 07 '11 at 15:12
  • Thanks for your comments. @JonathanWood : I already tried that (see my original post) and it had the same effect. @JonasGulle : The MF_STRING bit also did not have any effect. – Norman Jul 08 '11 at 11:00
  • I assume \r\n might do it. MFC is alway \r\n – Totonga Aug 17 '15 at 14:31

2 Answers2

1

Looks like an duplicate

Mainly you should use \r\n instead of \n because this is what mfc expects.

Community
  • 1
  • 1
Totonga
  • 4,236
  • 2
  • 25
  • 31
  • Does not work. The result is the same as if `\n` alone is used. The text displays in one line and ignores the newline character(s) completely. (Note that the `\r\n` are still in the text as fetching with [`GetMenuString`](https://msdn.microsoft.com/en-us/library/windows/desktop/ms647983%28v=vs.85%29.aspx) does copy both characters in the string) – Blacktempel Aug 18 '15 at 09:53
1

Perhaps you have not added the windows xp common controls to your application.

Try adding the common controls to your 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
Tom Chakam
  • 41
  • 5