This is my whole code:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls;
type
TForm1 = class(TForm)
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
Images: array[0..29,0..39] of TImage; //array
implementation
{$R *.dfm}
//form create
procedure TForm1.FormCreate(Sender: TObject);
var xx,yy: Integer; //local variables
begin
for xx:=0 to 29 do
for yy:=0 to 39 do
begin
Images[xx,yy]:=Timage.Create(Form1);
Images[xx,yy].Canvas.Rectangle(0,0,17,17);
Images[xx,yy].Left:=xx*16;
Images[xx,yy].Top:=yy*16;
end;
end;
end.
And I always get the error : "Project Project1.exe has raised the exception class EClassNotFound with message "TImage not found". Process stopped. Use step or run to continue "
I have tried other codes on the internet like:
Delphi: TImage.Create causes Access violation
http://www.delphi-central.com/tutorials/memory_game_2.aspx
Nothing helps! Why is this happening?
Thank you.
Are you sure you get the exception at the line with TImage.Create? Could it be you have an invalid DFM file still containig a TImage instance which is missing from the TForm1 declaration?
Normally all classes used as children in a form or datamodule are automatically registered for streaming. As there is no TImage declared in the form and no other form of the application contains a TImage, there is no registration.
You can simply test by dropping a TImage onto the form.
and if you want to show in form add this code to loop:
Images[xx,yy].Parent:= Self;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With