Solved

Passing procedure as parameter; Delphi 2012

Posted on 2014-10-06
4
305 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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

805 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