Login ProductsSalesSupportDownloadsAbout |
Home » Technical Support » Elevate Web Builder Technical Support » Support Forums » Elevate Web Builder General » View Thread |
Messages 1 to 3 of 3 total |
TCanvasImage : loading an image at runtime.. |
Sat, May 31 2014 1:46 PM | Permanent Link |
Bruno Larochelle | hi
i'm trying to load an image into the TCanvasImage object, but seem to be having difficulty with this when I run the page and press 'button1' (example below) to load the image at runtime.. I get an application error : "unable to get property 'tcanvasimage_setname' of undefined or null reference" I do have a 'hello.png' in the same location as the loader file somehow i'm misunderstanding how to use the 'name' property of the TCanvasImage, or maybe i'm misunderstanding something about the object creation thanks, still fairly new at EWB (v1.03, build 4) .. Bruno ///////////////////////////////////////////////// EXAMPLE BELOW /////////////////////////////////////// unit Unit1; interface uses WebCore, WebForms, WebCtrls; type TForm1 = class(TForm) Paint1: TPaint; Button1: TButton; Button2: TButton; procedure Button1Click(Sender: TObject); procedure Button2Click(Sender: TObject); private { Private declarations } public { Public declarations } canvasImage1: TCanvasImage; end; var Form1: TForm1; implementation procedure TForm1.Button1Click(Sender: TObject); begin canvasImage1.name := 'hello.png'; //this is in the 'output' folder end; procedure TForm1.Button2Click(Sender: TObject); begin if canvasImage1.loaded = true then begin paint1.canvas.drawImage(canvasImage1,0,0); end else begin showMessage('it is not loaded yet!'); end; end; end. ///////////////////////////////////////////////////////////////////////////////////////// |
Sat, May 31 2014 6:37 PM | Permanent Link |
Bruno Larochelle | ok, I decided to use my brain, I was forgetting to create the object dynamically
duh! procedure TForm1.Button1Click(Sender: TObject); begin canvasImage1 := TCanvasImage.create(); canvasImage1.name := 'hello.png'; //this is in the 'output' folder end; ////////// resolved! ///////////// Bruno Larochelle wrote: hi i'm trying to load an image into the TCanvasImage object, but seem to be having difficulty with this when I run the page and press 'button1' (example below) to load the image at runtime.. I get an application error : "unable to get property 'tcanvasimage_setname' of undefined or null reference" I do have a 'hello.png' in the same location as the loader file somehow i'm misunderstanding how to use the 'name' property of the TCanvasImage, or maybe i'm misunderstanding something about the object creation thanks, still fairly new at EWB (v1.03, build 4) .. Bruno ///////////////////////////////////////////////// EXAMPLE BELOW /////////////////////////////////////// unit Unit1; interface uses WebCore, WebForms, WebCtrls; type TForm1 = class(TForm) Paint1: TPaint; Button1: TButton; Button2: TButton; procedure Button1Click(Sender: TObject); procedure Button2Click(Sender: TObject); private { Private declarations } public { Public declarations } canvasImage1: TCanvasImage; end; var Form1: TForm1; implementation procedure TForm1.Button1Click(Sender: TObject); begin canvasImage1.name := 'hello.png'; //this is in the 'output' folder end; procedure TForm1.Button2Click(Sender: TObject); begin if canvasImage1.loaded = true then begin paint1.canvas.drawImage(canvasImage1,0,0); end else begin showMessage('it is not loaded yet!'); end; end; end. ///////////////////////////////////////////////////////////////////////////////////////// |
Mon, Jun 2 2014 4:33 AM | Permanent Link |
Matthew Jones | Bruno Larochelle wrote:
> "unable to get property 'tcanvasimage_setname' of undefined or null > reference As you found, the clue is in the "undefined or null reference" part. Pretty much always means you didn't assign a value to an object variable. -- Matthew Jones |
This web page was last updated on Friday, November 1, 2024 at 07:01 PM | Privacy PolicySite Map © 2024 Elevate Software, Inc. All Rights Reserved Questions or comments ? E-mail us at info@elevatesoft.com |