🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: alt.comp.lang.borland-delphi
2 messages
2 total messages Started by Danny Sun, 23 Jan 2005 23:19
Object reference not set to an instance of an object
#723
Author: Danny
Date: Sun, 23 Jan 2005 23:19
64 lines
2498 bytes
Hi!

I have a really annoying problem. It's from a program I've done in Delphi 5 
but now tries to get it working in Delphi 8. I have reproduced the problem 
in the following extremly simple program, it has something to do with the 
StretchDraw routine. When i run the program and execute the event 
(formclick) an error occours:

"Object reference not set to an instance of an object"

Anyone have any ideas what to do. I have spent many hours on the internet 
trying to solve that problem, this is my last chance except installing 
Delphi 5 again.


Thanks

Daniel





------- The source code for the program that reproduces the error ------



unit Unit1;

interface

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

type
  TForm1 = class(TForm)
    procedure FormClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.nfm}

procedure TForm1.FormClick(Sender: TObject);

var n:integer;
    bild:TPicture;

begin
   bild.LoadFromFile('c:\testbild.jpg');
   Form1.Canvas.StretchDraw(TRect.Create(1,1,100,150), bild.Graphic);
   bild.Free;
end;

end.
Re: Object reference not set to an instance of an object
#724
Author: Jamie
Date: Mon, 24 Jan 2005 04:16
70 lines
2929 bytes
Danny wrote:

> Hi!
> 
> I have a really annoying problem. It's from a program I've done in Delphi 5 
> but now tries to get it working in Delphi 8. I have reproduced the problem 
> in the following extremly simple program, it has something to do with the 
> StretchDraw routine. When i run the program and execute the event 
> (formclick) an error occours:
> 
> "Object reference not set to an instance of an object"
> 
> Anyone have any ideas what to do. I have spent many hours on the internet 
> trying to solve that problem, this is my last chance except installing 
> Delphi 5 again.
> 
> 
> Thanks
> 
> Daniel
> 
> 
> 
> 
> 
> ------- The source code for the program that reproduces the error ------
> 
> 
> 
> unit Unit1;
> 
> interface
> 
> uses
>   Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
>   Dialogs, ExtCtrls;
> 
> type
>   TForm1 = class(TForm)
>     procedure FormClick(Sender: TObject);
>   private
>     { Private declarations }
>   public
>     { Public declarations }
>   end;
> 
> var
>   Form1: TForm1;
> 
> implementation
> 
> {$R *.nfm}
> 
> procedure TForm1.FormClick(Sender: TObject);
> 
> var n:integer;
>     bild:TPicture;
> 
> begin
>    bild.LoadFromFile('c:\testbild.jpg');
>    Form1.Canvas.StretchDraw(TRect.Create(1,1,100,150), bild.Graphic);
>    bild.Free;
> end;
> 
> end.
> 
> 
how about creating the object first before using it.
i really don't know how that could have worked in D5.
bild := TPicture.Create;
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads