I've noticed that when VCL-Styles is enabled, items in menu will be selected with hotkeys even without Alt-key is pressed.
This interferes with the rest of my user interface and I find it very strange that a styles library change the behavior of hotkeys.
Can I remove this inconsistency somehow?
Normal: Pressing "A" does not activate the main menu (Alt + A does).
Styled: Pressing "A" activates the main menu. Note: no Alt key.
My test project is here in case anyone wants to try it out.
This issue it seems related to the TFormStyleHook.CMDialogChar
method which handle the message CM_DIALOGCHAR, the original method is not checking if the key Alt is pressed.
I wrote this style hook, which resolves the issue.
type
TFormStyleHookFix= class (TFormStyleHook)
procedure CMDialogChar(var Message: TWMKey); message CM_DIALOGCHAR;
end;
TFormStyleHookHelper= class helper for TFormStyleHook
private
function CheckHotKeyItem(ACharCode: Word): Boolean;
end;
{ TFormStyleHookFix }
procedure TFormStyleHookFix.CMDialogChar(var Message: TWMKey);
begin
if ((Message.KeyData and $20000000) <> 0 ) and (CheckHotKeyItem(Message.CharCode)) then
begin
Message.Result := 1;
Handled := True;
end
end;
{ TFormStyleHookHelper }
function TFormStyleHookHelper.CheckHotKeyItem(ACharCode: Word): Boolean;
begin
Result:=False;
if Self.FMainMenuBarHook<>nil then
Result:=Self.FMainMenuBarHook.CheckHotKeyItem(ACharCode);
end;
use in this way
TStyleManager.Engine.RegisterStyleHook(TForm9, TFormStyleHookFix);
Remeber report this case to the Quality Central Page.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With