View Single Post
  #1  
Old 12-20-2017, 10:09 PM
lexd lexd is offline
Senior Member
 
Join Date: Feb 2015
Posts: 268
Default A popupmenu on Myobject

I have a popup menu connected with code out of TToolBar (ComCtrls) line 2954
as I trace through the code its extremely complex to say the lest.

I feel like making a descendant menu and override the popup method
with its screen location add a Return: TControl to the popup Method as a
sow you type PopUp(x, y, Self); to activate the menu.
The return simply call a perform(CM_MENUCHANGED)
It still allows the menu to operate as a standard Menu but its beyond me why Delphi has to be so difficult with its code.

{ TTMenu }

procedure TTPopupMenu.MenuChanged(Sender: TObject; Source: TMenuItem;
Rebuild: Boolean);
begin
inherited;
if (Source = nil) and (FReturnMsg <> nil) then
FReturnMsg.Perform(CM_MENUCHANGED, 0, 0);
end;

procedure TTPopupMenu.PopUpMsg(X, Y: Integer; ReturnMsg: TControl);
begin
FReturnMsg := ReturnMsg;
inherited PopUp(X, Y);
end;

Does any one have a better idea

Last edited by lexd; 12-21-2017 at 02:53 AM.
Reply With Quote