Solved

Indy: Using Event w/ Dynamically Created Control

Posted on 2002-05-24
3
286 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
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

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…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

760 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now