Solved

Giving components events code so they can run dynamically

Posted on 2003-10-21
1
140 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

828 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