这是我的全部代码:
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.我总是收到错误:“ Project1.exe引发了异常类EClassNotFound,并带有消息"TImage not”。进程停止。使用step或run继续“
我曾在互联网上尝试过其他密码,例如:
Delphi: TImage.Create causes Access violation
http://www.delphi-central.com/tutorials/memory_game_2.aspx
什么都帮不上忙!为什么会发生这种情况?
谢谢。
发布于 2012-04-26 07:53:17
您确定在TImage.Create行中得到了异常吗?是否有一个无效的DFM文件仍然包含一个TImage实例,这个实例在TForm1声明中丢失了?
通常,在窗体或数据模式中用作子类的所有类都会自动注册为流。由于表单中没有声明TImage,也没有其他形式的应用程序包含TImage,因此没有注册。
您只需将TImage放到表单上即可进行测试。
发布于 2012-04-26 11:16:55
如果要以形式显示,请将以下代码添加到循环:
Images[xx,yy].Parent:= Self;https://stackoverflow.com/questions/10329171
复制相似问题