Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VCL-Styles menu hotkey inconsistency

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).

Normal: Pressing "A" does not activate the main menu (Alt + A does).

Styled: Pressing "A" activates the main menu. Note: no Alt key.

Styled: Pressing "A" activates the main menu.

My test project is here in case anyone wants to try it out.

like image 836
Ville Krumlinde Avatar asked Apr 02 '12 14:04

Ville Krumlinde


1 Answers

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.

like image 104
RRUZ Avatar answered Nov 02 '22 02:11

RRUZ