ShortCutToKey (Delphi)
Description
The following code redefines the ShortCut of CloseCommand if the original shortcut uses the [ssCtrl] shift state.
Code
procedure TForm1.Button1Click(Sender: TObject);
var
TheKey: Word;
TheShiftState: TShiftState;
begin
Menus.ShortCutToKey(CloseCommand.ShortCut, TheKey, TheShiftState);
if TheShiftState = [ssCtrl] then
CloseCommand.ShortCut := ShortCut(Word('C'), [ssShift]);
end;
procedure TForm1.CloseCommandClick(Sender: TObject);
begin
MessageDlg('The Close command has been selected.', mtInformation, [mbOk], 0);
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
CloseCommand.ShortCut := Menus.ShortCut(Word('C'), [ssCtrl]);
end;
Uses
- Vcl.Menus.ShortCutToKey ( fr | de | ja )