Solved

How can I access the events of a component created at run time.

Posted on 2009-07-13
2
217 Views
Last Modified: 2012-05-07
I have created indy idSmtp atb runtime but need to display the status supplied by the onstatus event
0
Comment
Question by:gerhard9121
2 Comments
 
LVL 14

Accepted Solution

by:
SteveBay earned 500 total points
ID: 24842570
You will need to subclass it in order to have access to the protected event procedures
It should look something like this:
unit Unit1;
 
interface
 
uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, IdBaseComponent, IdComponent, IdTCPConnection, IdTCPClient,
  IdExplicitTLSClientServerBase, IdMessageClient, IdSMTPBase, IdSMTP;
 
type TMySmtp = class(TIdSMTP);
 
type
  TForm1 = class(TForm)
    procedure FormCreate(Sender: TObject);
  private
     MySMTP : TMySmtp;
    procedure MySMTPStatus(ASender: TObject; const AStatus: TIdStatus; const AStatusText: string);
    { Private declarations }
  public
 
    { Public declarations }
  end;
 
var
  Form1: TForm1;
 
implementation
 
{$R *.dfm}
 
procedure TForm1.FormCreate(Sender: TObject);
begin
     MySMTP := TMySmtp.Create(Self);
     MySMTP.OnStatus := MySMTPStatus;
end;
 
procedure TForm1.MySMTPStatus(ASender: TObject; const AStatus: TIdStatus;  const AStatusText: string);
begin
     // do Status stuff
end;
 
end.

Open in new window

0
 

Author Closing Comment

by:gerhard9121
ID: 31602901
Thanks a lot. Easy as falling of a log - as long as you know how to
0

Featured Post

Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Newbie Thread Programming 1 155
Delphi: how to implement a User Shortcut mapper? 1 110
Convert MS Word document to a PDF file 9 83
Wincontrol not (correctly) drawn 15 38
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…
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…

832 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