How do I dynamically bind event handlers? - Delphi

How do I dynamically bind event handlers in Delphi?

Date Entered: 05/12/2000    Last Updated: 06/07/2004

To dynamically instantiate our controls you will need to declare the control and bind the events. Something like this:
	unit Unit1;

	interface

	uses
	  Windows, Messages, SysUtils, Classes, 
Graphics, Controls, Forms, Dialogs, StdCtrls, ipwCore, ipwIPPort;

	type

	  TForm1 = class(TForm)
	    Button1: TButton;
	 procedure xConnected(Sender: TObject; 
StatusCode: Integer;
	  const Description: String);

	    procedure Button1Click(Sender: TObject);
	  private
	    { Private declarations }
	  public
	    { Public declarations }
	  end;

	var
	  Form1: TForm1;

	implementation

	{$R *.DFM}
	procedure TForm1.xConnected(Sender: 
TObject; StatusCode: Integer;
	  const Description: String);
	begin
	        Application.MessageBox('hi','hi', 0);
	end;

	procedure TForm1.Button1Click(Sender: TObject);
	var
	        x : TipwIPPort;
	begin
	      x := TipwIPPort.Create(nil);
	      x.FOnConnected :=   xConnected;
	      x.RemoteHost := '10.0.1.254';
	      x.RemotePort := 25;
	      x.Connected := true;
	      while not x.Connected do x.DoEvents;
	      x.Destroy;
	end;
	end.


We appreciate your feedback.  If you have any questions, comments, or suggestions about this entry please contact our support team at kb@nsoftware.com.