size : 1561 uploaded_on : Thu Jan 28 00:00:00 1999 modified_on : Wed Dec 8 14:03:33 1999 title : Createing Popup Menu at Runtime org_filename : RuntimePopup.txt author : Mikko Isola authoremail : Mikko.Isola@systeemiratkaisu.fi description : How to create a popup menu dynamically at runtime keywords : tested : not tested yet submitted_by : The CKB Crew submitted_by_email : ckb@netalive.org uploaded_by : nobody modified_by : nobody owner : nobody lang : plain file-type : text/plain category : delphi-commoncontrols-menus __END_OF_HEADER__ >Does anyone have an example of creating a popup menu with subitems (with >their own event handlers) at runtime? Hi Here's an example witch would do the trick There are two procedures included Form1.FormClick witch creates the popupmenu and Button1Click to find it later; Hope this helps. procedure TForm1.FormClick(Sender: TObject); Var PopUpMenu : TPopUpMenu; MenuItem : TMenuItem; SubMenuItem : TMenuItem; begin PopUpMenu := TPopUpMenu.Create(Form1); With popupmenu do Begin Parent := Form1; Name := 'PopUpMenu'; // following lines create popupitem A and two submenus for it A1 and A2 // from here to PopUp (200,200) can be repeated as many times you need to create new popup items MenuItem := TMenuItem.Create(PopUpMenu); MenuItem.Caption := 'A'; PopUpMenu.Items.Add(Menuitem); SubMenuItem := TMenuItem.Create(MenuItem); SubMenuItem.Caption := 'A1'; SubMenuItem.OnCLick := Clicked; MenuItem.Add(SubMenuItem); SubMenuItem := TMenuItem.Create(MenuItem); SubMenuItem.Caption := 'A2'; SubMenuItem.OnCLick := Clicked; MenuItem.Add(SubMenuItem); PopUp(200,200); End; end; // This routine will find the created popupmenu and free it procedure TForm1.Button1Click(Sender: TObject); Var PopUpMenu : TPopUpMenu; begin PopUpMenu := Findcomponent('PopUpMenu') as TPopUpMenu; PopUpMenu.free; end;