We help IT Professionals succeed at work.
Get Started

Popup menu onclick doesn't fire event

Robert Laird
Robert Laird asked
on
1,121 Views
Last Modified: 2012-08-14
I have a popup menu which dynamically creates captions based on the value in a grid (asg2), and it works like I want it to... except.... the OnClick event doesn't fire.

procedure TForm1.asg2MouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
  var ts :string;
      mi1,mi2 : TMenuItem;
begin
  if Button = mbRight then
    begin
      asg2.Row := ASG2.MouseCoord(X,Y).Y;
      AdvPopupMenu1.Items.Clear;

      mi1 := TMenuItem.Create(AdvPopupMenu1);
      mi1.Caption := 'Ping '+asg2.cells[0,asg2.row];
      mi1.OnClick := Ping2Click;

      mi2 := TMenuItem.Create(AdvPopupMenu1);
      mi2.Caption := 'Check '+asg2.cells[0,asg2.row];
      mi2.OnClick := Check1Click;
      AdvPopupMenu1.Items.Add([mi1,mi2]);

      if  ((ASG2.MouseCoord(X,Y).X=0)) then
          AdvPopupMenu1.PopupAtCursor;
      mi1.Destroy;
      mi2.Destroy;
    end;
end;

Open in new window


Neither Ping2Click nor Check1Click will fire when the respective menu item is selected.

Any ideas?
Comment
Watch Question
Commented:
This problem has been solved!
Unlock 1 Answer and 3 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE