Menu Accelerator Keys (underline) for Owner-Draw m

2019-07-25 09:30发布

问题:

I am try to use Owner-Draw menu. The only problem I can not solve is that I don't know how to implement (or enable?) the Menu Accelerator Keys (underline). I am using Win32, and what I am concerning is the main menu, not the submenu. How can I implement or enable underlines when I use Owner-Draw menu?

p.s. The Menu Accelerator Keys is a letter with a underline, which is used when users press Alt to access menu items. It is created by & character such as Save &As.

回答1:

Use DrawTextEx() to draw the text, it takes care of it automatically. Use the DT_HIDEPREFIX option if you need to hide the underline, DT_NOPREFIX if you need to display the & for some reason.



回答2:

The & before a char to underline it works also for DrawText(); the DT_HIDEPREFIX works as well. At least this works fine for an owner-draw button control.



标签: winapi menu