Solved

Giving components events code so they can run dynamically

Posted on 2003-10-21
1
139 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
ID: 9596245
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

ScreenConnect 6.0 Free Trial

Check out the updates in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI that improves session organization and overall user experience. See the enhancements for yourself!

Question has a verified solution.

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

Suggested Solutions

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
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…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

809 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