RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
Menus.ShortCutToKey Function

Returns the key code and shift state of a menu shortcut.

Pascal
procedure ShortCutToKey(ShortCut: TShortCut; var Key: Word; var Shift: TShiftState);
C++
ShortCutToKey(TShortCut ShortCut, Word Key, TShiftState Shift);

Menus

Call ShortCutToKey to parse a menu shortcut into its virtual key code and shift state parts. 

ShortCut is the value of the menu shortcut. 

Key returns the virtual key code (Menus version) or Qt key code (QMenus version) for the key. 

Shirt returns the associated combination of Shift, Ctrl, and Alt keys.  

Delphi Examples: 

 

{
The following code redefines the ShortCut of CloseCommand if
the original short cut used the [ssCtrl] shift state.
} 
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;

 

Copyright(C) 2008 CodeGear(TM). All Rights Reserved.
What do you think about this topic? Send feedback!