Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

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

Posted on 2009-07-13
2
218 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Delphi XE10, DigitalPersona Fingerprint reader and MySQL 6 323
How to fill array with TArray.Create? 14 94
RESTRequest Parameter 4 42
Wincontrol not (correctly) drawn 15 40
A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
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…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

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