Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 3 of 3 total
Thread TImageElement onLoad event..
Wed, May 6 2020 7:59 AMPermanent Link

R&D team @ Environment Canada

Hi

I'm having trouble compiling a small test project where I try to assign an event handler to TImageElement.onLoad.

Below is a sample project which compiles in EWB v2, but gives an error in EWB v3.

Note in particular the line:

imgTemp.OnLoad := onLoadImage;

gives an error: "Expected a variable, parameter, constant, property, or type reference, instead found onLoadImage"


////////////////// sample project below //////////////

unit Unit1;

interface

uses WebCore, WebUI, WebForms, WebCtrls, WebBtns, WebPaint, WebDom;

type

  TForm1 = class(TForm)
     Button1: TButton;
     Paint1: TPaint;
     procedure Button1Click(Sender: TObject);
     procedure onLoadImage(sender: TObject);
  private
     { Private declarations }
  public
     { Public declarations }
  end;

var
  Form1: TForm1;

implementation

procedure TForm1.Button1Click(Sender: TObject);
var
imgTemp: TImageElement;
begin

imgTemp := TImageElement.create('',nil,HTML_TAG_IMG);

imgTemp.URL := 'apple.png';
imgTemp.OnLoad := onLoadImage;

end;

procedure Tform1.onLoadImage(sender: TObject);
begin
// do something with the image..
end;

end.
Wed, May 6 2020 4:30 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

<< I'm having trouble compiling a small test project where I try to assign an event handler to TImageElement.onLoad.

Below is a sample project which compiles in EWB v2, but gives an error in EWB v3. >>

This is the probably a case of the EWB 2 compiler being "not so great". Smile

The signature for the TImageElement.OnLoad event type is this:

  TWebElementEvent = procedure (AElement: TWebElement) of object;

(WebUI unit)

This is the fixed source code:

unit Unit1;

interface

uses WebCore, WebUI, WebForms, WebCtrls, WebBtns, WebPaint, WebDom;

type

 TForm1 = class(TForm)
    Button1: TButton;
    Paint1: TPaint;
    procedure Button1Click(Sender: TObject);
    procedure onLoadImage(AElement: TWebElement);
 private
    { Private declarations }
 public
    { Public declarations }
 end;

var
 Form1: TForm1;

implementation

procedure TForm1.Button1Click(Sender: TObject);
var
imgTemp: TImageElement;
begin

imgTemp := TImageElement.create('',nil,HTML_TAG_IMG);

imgTemp.URL := 'apple.png';
imgTemp.OnLoad := onLoadImage;

end;

procedure TForm1.onLoadImage(AElement: TWebElement);
begin
// do something with the image..
end;

end.

Tim Young
Elevate Software
www.elevatesoft.com
Wed, May 6 2020 5:13 PMPermanent Link

R&D team @ Environment Canada

Thanks Tim!

.. Bruno


procedure TForm1.onLoadImage(AElement: TWebElement);
begin
// do something with the image..
end;

end.

Tim Young
Elevate Software
www.elevatesoft.com
Image