RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
Menus.ShortCutToText Function

Converts a menu shortcut into a string that describes the shortcut.

Pascal
function ShortCutToText(ShortCut: TShortCut): string;
C++
AnsiString ShortCutToText(TShortCut ShortCut);

Call ShortCutToText to obtain a text description of the shortcut associated with a menu item. Use this function when the application needs to display a description of a shortcut to the user.  

C++ Examples: 

 

/*
This line creates a shortcut, Ctrl+O, at run time and
assigns it to the Open command on a File menu.
*/
void __fastcall TForm1::Button1Click(TObject *Sender)
{
  Edit1->Text = ShortCutToText(OpenCommand->ShortCut);}

void __fastcall TForm1::FormCreate(TObject *Sender)
{
  OpenCommand->ShortCut =
    ShortCut(Word('O'), TShiftState() << ssCtrl);
}

void __fastcall TForm1::OpenCommandClick(TObject *Sender)
{
  MessageDlg(
    "The Open command has been selected.",
    mtInformation,
    TMsgDlgButtons() << mbOK,
    0);
}

 

Delphi Examples: 

{
This line creates a shortcut, Ctrl+O, at run time and
assigns it to the Open command on a File menu.
}
procedure TForm1.Button1Click(Sender: TObject);
begin
  Edit1.Text := Menus.ShortCutToText(OpenCommand.ShortCut);
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  OpenCommand.ShortCut := Menus.ShortCut(Word('O'), [ssCtrl]);
end;

procedure TForm1.OpenCommandClick(Sender: TObject);
begin
  MessageDlg('The Open command has been selected.', mtInformation, [mbOk], 0);
end;

 

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!