EricTaylor
asked on
Passing procedure as parameter; Delphi 2012
In a Delphi 2010 library, I need to dynamically create a popupmenu (this part is fine), associate it with a control (also fine I think), and associate the created menu items with an OnClickEvent back in the calling program (this is the problem). I have a procedure that simplified is like this:
TMymenu.Create(aControl:TControl; onClickEvent:TProcedure;...)
This creates the menu and associates the procedure with the OnClick events for the created menu items. I try to call this with something like: MyMenu.create(anEdit, EditOnClickEvent...);
(MyMenu is an instance of TMyMenu, and object I created with various stuff needed for the menu to work.) When I compile, I get "Incompatible types: 'regular procedure and method pointer'". Need guidance on passing the procedure. Need guidance on how to correctly pass the procedure. Thanks.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
is your EditOnclick... procedure part of a main class? If not - should be.
ASKER
Sinisa, the procedure is correctly defined as part of a main class.
ASKER
Thanks