How to remove the accelerator hot key '&' character?

780 views Asked by At

I'm using the '&' character for using accelerator keys with my TLabel controls. In this way, the user can press Alt+Character after the & in order to focus controls on the form.

Example:

var
  MyLabel : TLabel;
  MyEdit : TEdit;
begin
  MyEdit := TEdit.Create(Self);
  MyEdit.Left := 20;
  MyEdit.Top := 40;
  MyEdit.Parent := Self;

  MyLabel := TLabel.Create(Self);
  MyLabel.FocusControl := MyEdit;
  MyLabel.Caption := '&Test';
  MyLabel.Left := 20;
  MyLabel.Top := 20;
  MyLabel.Parent := Self;
end;

In this case, MyLabel appears with the 'T' character underlined and pressing Alt+T causes MyEdit to be focused.

enter image description here

How can I get MyLabel.Caption without the '&' character? Is there any built in function for doing this?

I'm expecting to get 'Test' string instead of '&Test'

1

There are 1 answers

0
David Heffernan On BEST ANSWER

You are looking for the StripHotkey function.