Solved

Indy: Using Event w/ Dynamically Created Control

Posted on 2002-05-24
3
290 Views
Last Modified: 2012-05-04
In my application I'm dynamically creating the TIdHTTP component and I would like to use the OnWork and OnWorkBegin events.  How do I do this when the component is created dynamically?  I've tried adding:

procedure httpWorkBegin(Sender: TObject; AWorkMode: TWorkMode; const
AWorkCountMax: Integer);
begin
  //
end;

to the procedure that creates and uses the http component but when I try to assign it to the http component using:  http.OnWorkBegin := httpWorkBegin; it gives me the error "Incompatible types: method pointer and regular procedure".

Anyone know what's wrong or how I should be doing this?
0
Comment
Question by:dokken
[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
3 Comments
 
LVL 4

Accepted Solution

by:
nestorua earned 300 total points
ID: 7033265
HI,
You must declare your "procedure httpWorkBegin" as a method of
for example your Form "procedure TMyForm.httpWorkBegin", not as a simple procedure, because an event is a pointer to some procedure OF OBJECT not simple procedure type.
TWorkBeginEvent = procedure(Sender: TObject; AWorkMode: TWorkMode; const AWorkCountMax: Integer) OF OBJECT;

Sincerely,
Nestorua.
0
 
LVL 12

Expert Comment

by:Lee_Nover
ID: 7034389
so it should look like this :

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs;

type
  TForm1 = class(TForm)
  private
    { Private declarations }
    procedure httpWorkBegin(Sender: TObject; AWorkMode: TWorkMode;
      const AWorkCountMax: Integer);
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

{ TForm1 }

procedure TForm1.httpWorkBegin(Sender: TObject; AWorkMode: TWorkMode;
  const AWorkCountMax: Integer);
begin

end;

end.
0
 

Author Comment

by:dokken
ID: 7036461
That worked.  For some reason I thought I needed to add the event code in the procedure that was creating the HTTP component.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Multiple image collision 13 106
creating threads in delphi 1 201
DBCtrlGrid, Delphi, Scroll 8 86
Delphi Firemonkey: if the Sms contain special characters it won't send it 3 82
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…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
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…

734 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