RAD Studio
ContentsIndex
PreviousUpNext
Specifying Menu Items

Override the GetVerbCount method to return the number of commands you are adding to the context menu. Override the GetVerb method to return the strings that should be added for each of these commands. When overriding GetVerb, add an ampersand (&) to a string to cause the following character to appear underlined in the context menu and act as a shortcut key for selecting the menu item. Be sure to add an ellipsis (...) to the end of a command if it brings up a dialog. GetVerb has a single parameter that indicates the index of the command. 

The following code overrides the GetVerbCount and GetVerb methods to add two commands to the context menu.

function TMyEditor.GetVerbCount: Integer;
begin
  Result := 2;
end;
function TMyEditor.GetVerb(Index: Integer): String;
begin
  case Index of
    0: Result := '&DoThis ...';
    1: Result := 'Do&That';
  end;
end;

 

int __fastcall TMyEditor::GetVerbCount(void)
{
return 2;
}
System::AnsiStringBase __fastcall TMyEditor::GetVerb(int Index)
{
switch (Index)
{
case 0: return "&DoThis ..."; break;
case 1: return "Do&That"; break;
}
}

Note: Be sure that your GetVerb method returns a value for every possible index indicated by GetVerbCount.

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