Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>There is a standard Windows setting (under display properties) to normally hide those accelerators unless the Alt key is held down. That would explain why opening the menu with Alt+F10 shows them for you. Maybe that's the cause?</p> <p>[EDIT]: No, it's not. I just tried, and a simple TForm with a menu item shows the accelerator, but as soon as I add a TImageList and set the ImageIndex of the single menu item, or simply set OwnerDraw to true, then the accelerator underline disappears. I guess that really is a bug in the VCL.</p> <p>BTW, this is on Windows XP.</p> <p><strong>Workaround:</strong></p> <p>I have debugged this using Delphi 2009 on Windows XP 64, and the root cause for the missing accelerators seems to be that Windows sends <code>WM_DRAWITEM</code> messages with the <code>ODS_NOACCEL</code> flag set, which it shouldn't if the system is set to show accelerators at all times. So you could say that it is not a VCL bug, but a Windows problem which the VCL does not work around.</p> <p>However, you can work around it in your own code, you just need to reset the flag before passing the message to the VCL. Override the window proc</p> <pre><code>protected procedure WndProc(var Message: TMessage); override; </code></pre> <p>like so:</p> <pre><code>procedure TYourForm.WndProc(var Message: TMessage); const ODS_NOACCEL = $100; var pDIS: PDrawItemStruct; ShowAccel: BOOL; begin if (Message.Msg = WM_DRAWITEM) then begin pDIS := PDrawItemStruct(Message.LParam); if (pDIS^.CtlType = ODT_MENU) and SystemParametersInfo(SPI_GETKEYBOARDCUES, 0, @ShowAccel, 0) then begin if ShowAccel then pDIS^.itemState := pDIS^.itemState and not ODS_NOACCEL; end; end; inherited; end; </code></pre> <p>This is demonstration code only, you should not call <code>SystemParametersInfo()</code> every time a <code>WM_DRAWITEM</code> message is received, but once at program start, and then every time your program receives a <code>WM_SETTINGCHANGE</code> message. </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload