Recent

Author Topic: Use codes to add submenus of PopupMenu  (Read 4891 times)

asdf

  • Sr. Member
  • ****
  • Posts: 310
Use codes to add submenus of PopupMenu
« on: October 26, 2012, 09:31:30 am »
I need to use 'options' in a dialog box like InputBox. Is it possible? ( I don't need to create a new form for it.)

Or if I apply by using PopupMenu, how can I write codes to add a new submenu?
And how can I use double click instead of right click on the control?
« Last Edit: October 26, 2012, 10:51:04 am by asdf »
Lazarus 1.2.4 / Win 32 / THAILAND

Blaazen

  • Hero Member
  • *****
  • Posts: 3241
  • POKE 54296,15
    • Eye-Candy Controls
Re: Use codes to add submenus of PopupMenu
« Reply #1 on: October 26, 2012, 11:43:20 am »
Hi,
Quote
I need to use 'options' in a dialog box like InputBox. Is it possible? ( I don't need to create a new form for it.)
I don't understand well.

Quote
Or if I apply by using PopupMenu, how can I write codes to add a new submenu?
Code: [Select]
var MI: TMenuItem;
begin
  MI:=TMenuItem.Create(self);
  with MI do
    begin
      Caption:='My New Item '+inttostr(PopupMenu1.Items.Count);
      //also do not forget to assign some action or event
    end;
  PopupMenu1.Items.Add(MI); 
end;
Quote
And how can I use double click instead of right click on the control?
Let's say you have Image1 and Image1Click event. In code you can switch:
Code: [Select]
      Image1.OnClick:=nil;
      Image1.OnDblClick:=@Image1Click;
or
Code: [Select]
      Image1.OnClick:=@Image1Click;
      Image1.OnDblClick:=nil;
Lazarus 2.3.0 (rev main-2_3-2863...) FPC 3.3.1 x86_64-linux-qt Chakra, Qt 4.8.7/5.13.2, Plasma 5.17.3
Lazarus 1.8.2 r57369 FPC 3.0.4 i386-win32-win32/win64 Wine 3.21

Try Eye-Candy Controls: https://sourceforge.net/projects/eccontrols/files/

User137

  • Hero Member
  • *****
  • Posts: 1791
    • Nxpascal home
Re: Use codes to add submenus of PopupMenu
« Reply #2 on: October 26, 2012, 11:44:21 am »
Rather than adding new menus (which you can do with TMenuItem.Create), you can change their visibility. Give your menuitems some relevant names like mnuOptions, and then use
mnuOptions.Visible:=true;
or
mnuToggle1.Caption:='Something';

 

TinyPortal © 2005-2018