Get notified when a TPopupMenu closes?

How can I get notified when a TPopupMenu closes? (Not just by clicking on a menu item but also when closing the popup menu with the Esc key or by clicking elsewhere).

It MUST be a TPopupMenu.

Delphi XE8
PeterDelphinAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

PeterDelphinAuthor Commented:
Found the solution here.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
PeterDelphinAuthor Commented:
Will give 500 points to whom can tell me how I can get the popup menu NAME in one of these procedures:

procedure TForm1.CM_MenuClosed(var Msg: TMessage);
begin
  Caption := 'PopMenu closed';
  // Name of the popup menu?
end;

procedure TForm1.CM_ExitMenuLoop(var Msg: TMessage);
begin
  Caption := 'PopMenu exited';
  // Name of the popup menu?
end;

Open in new window

0
jimyXCommented:
type
  TForm1 = class(TForm)
...
  private
    ActivePopup: TPopupMenu;

    procedure CM_MenuClosed(var msg: TMessage) ; message CM_MENU_CLOSED;
    procedure CM_EnterMenuLoop(var msg: TMessage) ; message CM_ENTER_MENU_LOOP;
    procedure CM_ExitMenuLoop(var msg: TMessage) ; message CM_EXIT_MENU_LOOP;
  public
    { Public declarations }
  end;

procedure TForm1.CM_ExitMenuLoop(var msg: TMessage);
begin
  Caption := 'PopMenu exited';

  if not Assigned(ActivePopup) then Exit; {safety}

  showmessage(ActivePopup.Name);

  ActivePopup:= nil;
end;

//All the PopupMenus shall share this OnPopup event
procedure TForm1.PopupMenu1Popup(Sender: TObject);
begin
  ActivePopup:= (Sender AS TPopupMenu);
end;

Open in new window

1
PeterDelphinAuthor Commented:
I want to give you the 500 points. However, there is no button to accept this as part of the solution with 500 points. How can I do this?
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.