Solved

Passing procedure as parameter; Delphi 2012

Posted on 2014-10-06
4
302 Views
Last Modified: 2014-10-08
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;...)

Open in new window

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...);

Open in new window

(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.
0
Comment
Question by:EricTaylor
  • 2
4 Comments
 
LVL 19

Accepted Solution

by:
MerijnB earned 500 total points
ID: 40365474
Try changing to:

TMymenu.Create(aControl:TControl; onClickEvent:TNotifyEvent;...)

Open in new window


TNotifyEvent is defined in Classes, so you might need to add that to your uses, it's probably already there though.
0
 
LVL 26

Expert Comment

by:Sinisa Vuk
ID: 40365482
is your EditOnclick... procedure part of a main class? If not - should be.
0
 

Author Comment

by:EricTaylor
ID: 40369028
Sinisa, the procedure is correctly defined as part of a main class.
0
 

Author Closing Comment

by:EricTaylor
ID: 40369029
Thanks
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Simple Delphi Question 9 83
can't find the executable in Simulator 1 80
How to load 2 images in same column in Delphi 2 34
Multi-layered image in FireMonkey 9 18
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

896 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now