Solved

Giving components events code so they can run dynamically

Posted on 2003-10-21
1
137 Views
Last Modified: 2010-04-03
I have just started designing components, that i want the user to create dynamically, however i can not work out how to give them specific code in their events, eg. so that the ContextPopup will display a message
0
Comment
Question by:KiwiGraeme
1 Comment
 
LVL 3

Accepted Solution

by:
philly_tee earned 250 total points
Comment Utility
Hi,

I am not exactly sure what you are asking - You want the user to create the component in code and then place code on the Context Popup event that will display a message, as well as having the user able to use the event?

If this is so you can override the contextpopup event, adding your code before the user's event handler is called:

{*************}

unit Memo1;

interface

uses
  SysUtils, Classes, Controls, StdCtrls, types, dialogs;

type
  TMemo1 = class(TMemo)
  private
    { Private declarations }
    FOnContextPopup : TContextPopupEvent;
  protected
    { Protected declarations }
 public
    { Public declarations }
  procedure DoContextPopup(MousePos: TPoint; var Handled: Boolean); override;
  published
    { Published declarations }

  end;

procedure Register;

implementation

procedure Register;
begin
  RegisterComponents('Samples', [TMemo1]);
end;

{ TMemo1 }

procedure TMemo1.DoContextPopup(MousePos: TPoint; var Handled: Boolean);
begin
    ShowMessage('Hello');
      if Assigned(FOnContextPopup) then FOnContextPopup(Self, MousePos, Handled);

end;

end.

{**********}

HTH,

Philip
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Thread safe  opinion 7 110
Multiple image collision 13 42
creating threads in delphi 1 52
When i run adoquery my application freezes 26 91
The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
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…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

744 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

15 Experts available now in Live!

Get 1:1 Help Now