Event used to add extra items to in-built popup menus, such as the TImageEnView and TImageEnMView Popup Menus.
This event is called for each item that is added to the menu, allowing you to position your new button(s) before a specific button.
To add an extra item set AddButton and specify the properties of the popup menu item.
Value
Description
Sender
The popup menu
BeforeButtonID
Specifies the ID of an item being added. Your custom item will be positioned to BELOW this item. 0: Specifies the very top of the menu. -1 specifies the very bottom of the menu
AddButton
Set to true if you are adding a button at this position
Note: ◼Custom items cannot be added to sub-menus ◼Specify caption as '-' to add a separator ◼Ensure you reset this event before destroying your form, e.g. IEGlobalSettings().OnAddCustomPopupMenuItem := nil;
// Add a custom open button, and two other buttons to the bottom of the menu const MY_HOME_BUTTON_ID = IECustom_Button_ID + 1; MY_IMAGEINFO_BUTTON_ID = IECustom_Button_ID + 2; MY_LOADRECENT_BUTTON_ID = IECustom_Button_ID + 3;
procedure TMainForm.Form1CustomButtonExecute(Sender: TObject; ButtonID: Integer; var Handled: Boolean); begin // Button Clicked case ButtonID of MY_HOME_BUTTON_ID : ShellExecute(Handle, nil, PChar('http://www.imageen.com'), nil, nil, SW_SHOWNORMAL); MY_IMAGEINFO_BUTTON_ID : ShowMessage( Format( 'Image Size: %d x %d', [ ImageEnView1.IEBitmap.Width, ImageEnView1.IEBitmap.Height ])); MY_LOADRECENT_BUTTON_ID : ImageEnView1.IO.LoadFromFile( fLastUsedFile ); end; end;
procedure TMainForm.Form1AddCustomPopupMenuItem(Sender: TObject; BeforeButtonID: Integer; var AddButton: Boolean; var BtnID: Integer; var BtnCaption, BtnHint: string; var BtnImgID: Integer); begin // NOTE: For popup menus, items are added AFTER the item of BeforeButtonID
if BeforeButtonID = -1 then // Bottom of menu begin AddButton := True;
BtnID := MY_HOME_BUTTON_ID; BtnCaption := 'Home Page'; BtnImgID := ITBRES_HOMEOUTLINE_24; end else if ( ImageEnView1.IsEmpty = False ) and ( BeforeButtonID = MY_HOME_BUTTON_ID ) then // Below "Home" item begin AddButton := True;
BtnID := MY_IMAGEINFO_BUTTON_ID; BtnCaption := 'About this Image'; BtnImgID := ITBRES_INFORMATIONOUTLINE_24; end else if ( fLastUsedFile <> '' ) and ( BeforeButtonID = IEViewSave_Button_ID ) then // Below "Save" item begin AddButton := True;