views:

163

answers:

1

I have a win32/MFC application with a context menu that I build programatically:

CPoint pt;
GetMenuPopupPos(&pt);
CAtlString csItem = _T("&Example");
CMenu menu;
menu.CreatePoupMenu();
menu.AppendMenu(MF_STRING, IDM_EXAMPLE_COMMAND, csItem);
menu.TrackPopupMenuEx(TPM_LEFTALIGN|TPM_LEFTBUTTON, pt.x, pt.y, this, NULL);

I've omitted the rest of the menu items for brevity. The menu works, including the keyboard shortcuts, but the problem is that I can't see the underlined shortcuts in the final menu.

This menu has a single entry:

Example

While I would expect the entry (where the bold letter would be underlined).

Example

How do I get the underlines to show up?

+3  A: 

By default, Windows doesn't show underlines when a context menu is invoked using the mouse -- only when it is invoked using the keyboard. You can't override this behaviour short of owner-drawing the menu.

Your shortcuts will show if the user has selected the "underline menu shortcut keys" option, or if the user invokes the context menu via Shift+F10 or the Windows context menu key.

itowlson