Object reference not set to an instance of an object

From: Danny (dc_at_mbox303.swipnet.se)
Date: 01/24/05


Date: Mon, 24 Jan 2005 00:19:43 +0100


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.



Relevant Pages

  • Re: GetComputerName
    ... > - Delphi allows us to send it to APIs as a PChar ... > Some APIs perform differently between versions of Windows ... > Reporting the result of GetLastError is a pretty generic task ...
    (alt.comp.lang.borland-delphi)
  • Re: Question: how to read any one character from keyboard
    ... Doesn't anyone use Delphi anymore? ... the user at one point to "press any key" (it's a console app and this ... The help says that if you use Read with a Char var, ...
    (alt.comp.lang.borland-delphi)
  • Re: Generics for Delphi
    ... fVaribale: Array of Integer; ... Unfortunately, I can see the similarity, but that doesn't mean I have to like it :-) This is the point I am trying to make about matching generic delegate types to handlers; I can see unwanted complexity about to rear its ugly head :-( I must admit that things like this have always put me off Pascal from before I ever saw Delphi; it was only the superb Delphi IDE that "encouraged" me to use Pascal in the first place. ... public class MyClass<typeT>: MyClass ...
    (borland.public.delphi.non-technical)
  • Re: C++ to Delphi, HELP !!!
    ... I think this is a Delphi implementation of the BluffTitler C++ ... PtrData: PCopyDataStruct; ...
    (alt.comp.lang.borland-delphi)
  • Re: C++ to Delphi, HELP !!!
    ... I think this is a Delphi implementation of the BluffTitler C++ ... PtrData: PCopyDataStruct; ...
    (alt.comp.lang.borland-delphi)