Solved

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

Posted on 2009-07-13
2
219 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
[X]
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
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

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

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 my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
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…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

730 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