OnAnnMenu example for Delphi
// This Example is for also for:
// Count Property, ItemString Property, ItemID Property, ItemType Property,
// ItemChecked Property, ItemEnabled Property, DeleteItem method,
// AddItem method, GetSubMenu method, OnAnnUserMenu event.
Procedure TForm1.LEADAnn1AnnMenu (AnnMenu: TAnnMenu);
var
nID: Integer;
x: Integer;
PopupMenuItem: TAnnMenu;
Msg: String;
begin
Msg:= 'There are ' + IntToStr(AnnMenu.count) + ' Items';
ShowMessage (Msg);
Msg:= 'Original Text for item#2: ' + AnnMenu.ItemString [1];
ShowMessage (Msg);
//set new string
AnnMenu.ItemString [1]:= 'TestText';
Msg:= 'Custom Text for item#2: ' + AnnMenu.ItemString[1];
ShowMessage (Msg);
//make 3rd and 4th menu items have the same command id
nID:= AnnMenu.ItemID [3];
AnnMenu.ItemID [2]:= nID;
//check all unchecked menu items that are not popup submenus
//disable all enabled menu items that are not popup submenus
for x:= 0 to AnnMenu.count - 1 do
begin
if ( AnnMenu.ItemType [x] = ANNMENUITEMTYPE_NORMAL ) then
begin
if (AnnMenu.ItemChecked [x] = false) then
AnnMenu.ItemChecked[x]:= True;
if (AnnMenu.ItemEnabled [x]= True) then
AnnMenu.ItemEnabled[x]:= False
end;
end;
//insert 2 user-defined menu items
AnnMenu.AddItem ( '&Flip', ANNMENUITEMTYPE_NORMAL, LTANNEVENT_MENUFIRST, AnnMenu.count );
AnnMenu.AddItem ( 'Test&2', ANNMENUITEMTYPE_NORMAL, LTANNEVENT_MENUFIRST + 1, AnnMenu.count );
//delete the last menu item
AnnMenu.DeleteItem ( AnnMenu.count - 1 );
//delete the first menu item
AnnMenu.DeleteItem (0);
//insert a popup menu
AnnMenu.AddItem ( '&Popup1', ANNMENUITEMTYPE_SUBMENU, 0, AnnMenu.count );
//get the new item, and add some items to it
PopupMenuItem:= AnnMenu.GetSubMenu (AnnMenu.count - 1);
PopupMenuItem.AddItem ( 'Test&1', ANNMENUITEMTYPE_NORMAL, LTANNEVENT_MENUFIRST + 2, PopupMenuItem.count );
PopupMenuItem.AddItem ( 'Test&2', ANNMENUITEMTYPE_NORMAL, LTANNEVENT_MENUFIRST + 3, PopupMenuItem.count );
end;
procedure TForm1.LEADAnn1AnnUserMenu (nID: Integer);
var
Msg: String;
begin
if (nID = LTANNEVENT_MENUFIRST) then
LEADAnn1.AnnFlip ( False, 0, True )
else
begin
Msg:= 'nID = LTANNEVENT_MENUFIRST + ' + IntToStr (nID - LTANNEVENT_MENUFIRST);
ShowMessage ( Msg ) ;
end;
end;