J
jyg
Unregistered / Unconfirmed
GUEST, unregistred user!
unit Commint;
interface
uses classes,ExtCtrls,Graphics,Controls;
const
Block_Size = 20;
WorkHeigth = 16;
WorkWidth = 15;
ACount = 3 ;
type
Tblock = class(Tpanel)
public
constructor create(AOwner:Tcomponent);override;
end;
TBlockArray = array[0..ACount,0..ACount] of Tblock;
TWorkPanel = array[0..WorkWidth,0..WorkHeigth] of Tblock;
TShapeBLock = array[0..ACount,0..ACount] of integer;
Tblocks = class(Tobject)
panels :TBlockArray;
Workpanels :TworkPanel;
public
constructor create(AOwner:Twincontrol);
procedure initWorkPanel(AOwner:Twincontrol);
end;
implementation
{ Tblock }
constructor Tblock.create(AOwner: Tcomponent);
begin
inherited create(AOwner);
caption :='';
width := Block_size;
Height := Block_size;
color:=clred;
end;
{ Tblocks }
constructor Tblocks.create(AOwner:Twincontrol);
begin
inherited create;
initWorkpanel(AOwner);
end;
procedure Tblocks.initWorkPanel(AOwner:TWincontrol);
var
i,j:integer;
begin
for i:=0 to WorkWidth do
for j:=0 to WorkHeigth do
begin
Workpanels[i,j]:=Tblock.create(nil);
workpanels[i,j].left:=AOwner.left+i*BLock_size;
workpanels[i,j].top:=AOwner.top+i*BLock_size;
workpanels[i,j].Parent:=AOwner;
workpanels[i,j].Tag:=1;
workpanels[i,j].Color:=clblue;
end;
end;
end.
这个是公共单元;
unit Main_Unit;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs,commint, ExtCtrls;
type
TForm1 = class(TForm)
Panel1: TPanel;
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
block:Tblock;
Blocks:Tblocks;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
blocks.create(Panel1);
block:=Tblock.create(nil);
block.Left:=panel1.Left+5;
block.Top:=panel1.Left+5;;
block.Parent:=panel1;
end;
end.
这个品主要的单元;
当调试到这个句会有错误;;;
Workpanels[i,j]:=Tblock.create(nil); 会引出一个内存错误??
用编译指令{$D+ }会引出 Tfrom1 not fond
interface
uses classes,ExtCtrls,Graphics,Controls;
const
Block_Size = 20;
WorkHeigth = 16;
WorkWidth = 15;
ACount = 3 ;
type
Tblock = class(Tpanel)
public
constructor create(AOwner:Tcomponent);override;
end;
TBlockArray = array[0..ACount,0..ACount] of Tblock;
TWorkPanel = array[0..WorkWidth,0..WorkHeigth] of Tblock;
TShapeBLock = array[0..ACount,0..ACount] of integer;
Tblocks = class(Tobject)
panels :TBlockArray;
Workpanels :TworkPanel;
public
constructor create(AOwner:Twincontrol);
procedure initWorkPanel(AOwner:Twincontrol);
end;
implementation
{ Tblock }
constructor Tblock.create(AOwner: Tcomponent);
begin
inherited create(AOwner);
caption :='';
width := Block_size;
Height := Block_size;
color:=clred;
end;
{ Tblocks }
constructor Tblocks.create(AOwner:Twincontrol);
begin
inherited create;
initWorkpanel(AOwner);
end;
procedure Tblocks.initWorkPanel(AOwner:TWincontrol);
var
i,j:integer;
begin
for i:=0 to WorkWidth do
for j:=0 to WorkHeigth do
begin
Workpanels[i,j]:=Tblock.create(nil);
workpanels[i,j].left:=AOwner.left+i*BLock_size;
workpanels[i,j].top:=AOwner.top+i*BLock_size;
workpanels[i,j].Parent:=AOwner;
workpanels[i,j].Tag:=1;
workpanels[i,j].Color:=clblue;
end;
end;
end.
这个是公共单元;
unit Main_Unit;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs,commint, ExtCtrls;
type
TForm1 = class(TForm)
Panel1: TPanel;
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
block:Tblock;
Blocks:Tblocks;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
blocks.create(Panel1);
block:=Tblock.create(nil);
block.Left:=panel1.Left+5;
block.Top:=panel1.Left+5;;
block.Parent:=panel1;
end;
end.
这个品主要的单元;
当调试到这个句会有错误;;;
Workpanels[i,j]:=Tblock.create(nil); 会引出一个内存错误??
用编译指令{$D+ }会引出 Tfrom1 not fond