ShortCut (C++)

From RAD Studio Code Examples
Jump to: navigation, search

Description

This example creates a shortcut, Ctrl+O, at run time and assigns it to the Open command on a File menu.

Code

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

__fastcall TForm1::TForm1(TComponent* Owner)
  : TForm(Owner)
{
  OpenCommand->ShortCut =
    ShortCut(Word('O'), TShiftState() << ssCtrl);
}

Uses