• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 189
  • Last Modified:

Detect pop-up item

When click a standard button, I wish to detect what pop-up item is checked( selected ) and to go to OnSelect procedure of this item.
0
ginsonic
Asked:
ginsonic
1 Solution
 
alanwhincupCommented:
this should work:

procedure TForm1.Button1Click(Sender: TObject);
var
  I : Integer;
begin
  with PopupMenu1 do
  begin
    for I := 0 to Items.Count - 1 do
    begin
      if Items[I].Checked then
        Items[I].OnClick(Sender);
    end;
  end;
end;

Cheers,

Alan
0
 
djadjaCommented:
As above but don't use the OnClick; if the popup item doesn't have the event assigned it will give you an Access Violation - instead use:

if Items[I].Checked then
       Items[I].Click;
0

Featured Post

Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now