unit UMainFrm;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, cDragPanel, StdCtrls, Buttons, ExtCtrls, MyPanel, ArtPanel,
Gauges, ComCtrls, UMyThread;
type
TArrhqPanel = array of TArtPanel
//货区
TArrhjPanel = array of TArtPanel
//货架
TArrhcPanel = array of TArtPanel
//货层
TArrhdPanel = array of TDragPanel;
HqInfo = record
ckname :string;
ckbm :string;
hqname :string;
hqbm :string;
hqPanel :TArrhqPanel
end;
HcInfo = Record
hjname :string;
hjbm :string;
hjlayer :Integer;
hcPanel :TArrhcPanel;
end;
TMainFrm = class(TForm)
Panel1: TPanel;
ScrollBox1: TScrollBox;
Panel2: TPanel;
Edit1: TEdit;
BitBtn2: TBitBtn;
Label1: TLabel;
BitBtn3: TBitBtn;
BitBtn4: TBitBtn;
ArtPanel1: TArtPanel;
Label3: TLabel;
ArtPanel2: TArtPanel;
Label4: TLabel;
Label2: TLabel;
BitBtn1: TBitBtn;
Panel3: TPanel;
Edit2: TEdit;
Bevel1: TBevel;
Bevel2: TBevel;
ArtPanel3: TArtPanel;
Bevel3: TBevel;
BitBtn5: TBitBtn;
Status: TStatusBar;
Gauge1: TGauge;
procedure BitBtn1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
Procedure DestroyPanel;
procedure FormClose(Sender: TObject
var Action: TCloseAction);
procedure BitBtn2Click(Sender: TObject);
procedure BitBtn4Click(Sender: TObject);
procedure BitBtn3Click(Sender: TObject);
procedure BitBtn5Click(Sender: TObject);
procedure StatusDrawPanel(StatusBar: TStatusBar;
Panel: TStatusPanel
const Rect: TRect);
private
Process :TProgressBar;
StatusDrawRect:TRect
//记录要插入状态条特技的坐标范围
{ Private declarations }
public
ArrhqPanel :TArrhqPanel
//货区
ArrhjPanel :TArrhJPanel
//货架
ArrhcPanel :TArrhCPanel
//货层
ArrhdPanel :TArrhdPanel
//货段
j :integer;
{ Public declarations }
end;
var
MainFrm: TMainFrm;
implementation
{$R *.dfm}
Procedure TMainFrm.DestroyPanel;
var v_count,i :integer;
begin
//释放货段
v_count := Length(ArrhdPanel);
For i:=0 to v_count -1 do
If ArrhdPanel <> nil then
begin
ArrhdPanel.Free;
ArrhdPanel := nil;
end;
//释放货层
v_count := Length(ArrhcPanel);
For i:=0 to v_count -1 do
If ArrhcPanel <> nil then
begin
ArrhcPanel.Free;
ArrhcPanel := nil;
end;
//释放货架
v_count := Length(ArrhjPanel);
For i:=0 to v_count -1 do
If ArrhjPanel <> nil then
begin
ArrhjPanel.Free;
ArrhjPanel := nil;
end;
//释放货段
v_count := Length(ArrhqPanel);
For i:=0 to v_count -1 do
If ArrhqPanel <> nil then
begin
ArrhqPanel.Free;
ArrhqPanel := nil;
end;
end;
//*************** 货段 **************//
procedure TMainFrm.BitBtn1Click(Sender: TObject);
var v_count, i :integer;
p:tpoint;
v_hccount,j :integer;
v_hdcount,v_pro :integer;
A,B :MyThread;
begin
try
{ progress:=TProgressbar.create(MainFrm);
staPanleWidth:=status.Panels.Items[2].width;
status.Panels.Items[2].width:=600
// 改变宽度
status.repaint;
with progress do
begin
top:=StatusDrawRect.top;
left:=StatusDrawRect.left;
width:=StatusDrawRect.right-StatusDrawRect.left;
height:=StatusDrawRect.bottom-StatusDrawRect.top;
//设定进程条的宽度和高度
visible:=true;
try
Parent := status
//该进程条的拥有者为状态条status
Min := 0
Max := Count
//进程条的最大和最小值
Step := 1
//进程条的步长
for i := 1 to Count do
Stepit
// 累加进程条
//ShowMessage('现在,进程条将要从内存中被释放');
finally
Free
//释放进程条
end
//try
end
//with
status.Panels.Items[2].width:=staPanleWidth
//恢复状态条嵌板的宽度
}
v_pro :=1;
Gauge1.Visible := True;
Try
v_hdcount := StrToInt(Edit2.Text);
Except
MessageDlg('错误!', mtInformation,[mbOk], 0);
Exit;
end;
v_hccount :=Length(ArrhcPanel);
Gauge1.MaxValue :=v_hdcount * v_hccount
Gauge1.Progress :=0;
For j:=0 to v_hccount -1 do
begin
A:=MyThread.Create(ArrhdPanel,ArrhcPanel,j,v_hdocunt);
{for i:=0 to v_hdcount do
begin
V_Count :=Length(ArrhdPanel);
SetLength(ArrhdPanel,V_Count+1);
ArrhdPanel[V_Count] :=TDragPanel.Create(self);
ArrhdPanel[V_Count].Parent := ArrhcPanel[j];
ArrhdPanel[V_Count].Width := 30;
ArrhdPanel[V_Count].Height :=50;
ArrhdPanel[V_Count].Caption := IntToStr(i);
If i = 0 then
begin
//Showmessage(inttostr(arrhcPanel[j].Top)+#13+Inttostr(ArrhcPanel[j].Left));
ArrhdPanel[V_Count].Top :=0;//ArrhcPanel[j].Top;
ArrhdPanel[V_Count].Left:=0;//ArrhcPanel[j].Left;
end else
begin
//Showmessage(inttostr(ArrhdPanel[V_Count-1].Top)+#13+Inttostr(ArrhdPanel[V_Count-1].Left+ArrhdPanel[V_Count-1].Width));
ArrhdPanel[V_Count].Top :=ArrhdPanel[V_Count-1].Top;
ArrhdPanel[V_Count].Left:=ArrhdPanel[V_Count-1].Left+ArrhdPanel[V_Count-1].Width;
end;
Gauge1.Progress :=v_pro;
Inc(v_pro);
end
}
end;
BitBtn1.Enabled := False;
BitBtn3.Enabled := False;
BitBtn4.Enabled := False;
Gauge1.Progress :=0;
Gauge1.MaxValue :=0;
Gauge1.Visible := False;
finally
end;
end;
//*************** 货区 **************//
procedure TMainFrm.FormCreate(Sender: TObject);
begin
j:=0;
end;
//*************** 货层 **************//
procedure TMainFrm.FormClose(Sender: TObject
var Action: TCloseAction);
begin
DestroyPanel;
end;
procedure TMainFrm.BitBtn2Click(Sender: TObject);
begin
DestroyPanel;
BitBtn1.Enabled := False;
BitBtn3.Enabled := False;
BitBtn4.Enabled := True;
end;
//*************** 货区 **************//
procedure TMainFrm.BitBtn4Click(Sender: TObject);
var v_count, i :Integer;
begin
Try
v_count := StrToInt(Edit1.Text);
Except
MessageDlg('错误!', mtInformation,[mbOk], 0);
Exit;
end;
For i:=0 to v_count - 1 do
begin
V_Count :=Length(ArrhqPanel);
SetLength(ArrhqPanel,V_Count+1);
ArrhqPanel[V_Count] :=TArtPanel.Create(self);
ArrhqPanel[V_Count].Parent := ScrollBox1;
ArrhqPanel[V_Count].Width := 804;
ArrhqPanel[V_Count].Height :=100;
ArrhqPanel[V_Count].BevelInner := bvLowered;
ArrhqPanel[V_Count].BevelOuter := bvRaised;
ArrhqPanel[V_Count].ColorHighlight := clYellow;
ArrhqPanel[V_Count].ColorShadow := clYellow;
if i = 0 then
begin
ArrhqPanel[V_Count].Top :=0;//ScrollBox1.Top;
ArrhqPanel[V_Count].Left:=0;//ScrollBox1.Left;
end else
begin
if i mod 2 <> 0then //1、3、5
begin
ArrhqPanel[V_Count].Top :=ArrhqPanel[V_Count-1].Top + ArrhqPanel[V_Count].Height + 50;
ArrhqPanel[V_Count].Left:=ArrhqPanel[V_Count-1].Left;
end else //2、4、6
begin
ArrhqPanel[V_Count].Top :=ArrhqPanel[V_Count-1].Top + ArrhqPanel[V_Count].Height;;
ArrhqPanel[V_Count].Left:=ArrhqPanel[V_Count-1].Left;
end;
end;
end;
BitBtn3.Enabled := True;
BitBtn4.Enabled := False;
end;
//*************** 货层 **************//
procedure TMainFrm.BitBtn3Click(Sender: TObject);
var v_count, i,j :Integer;
p :tpoint;
begin
j := Length(ArrhqPanel);
For i:=0 to j - 1 do
begin
V_Count :=Length(ArrhcPanel);
SetLength(ArrhcPanel,V_Count+1);
ArrhcPanel[V_Count] :=TArtPanel.Create(self);
ArrhcPanel[V_Count].Parent := ArrhqPanel;
ArrhcPanel[V_Count].Width := 800;
ArrhcPanel[V_Count].Height :=48;
ArrhcPanel[V_Count].BevelInner := bvLowered;
ArrhcPanel[V_Count].BevelOuter := bvRaised;
ArrhcPanel[V_Count].Top :=0;//ArrhqPanel[0].Top+2
//?????????????????
ArrhcPanel[V_Count].Left:=0;//ArrhqPanel.Left+2;
ArrhcPanel[V_Count].ColorHighlight := clSkyBlue;
ArrhcPanel[V_Count].ColorShadow := clSkyBlue;
V_Count :=Length(ArrhcPanel);
SetLength(ArrhcPanel,V_Count+1);
ArrhcPanel[V_Count] :=TArtPanel.Create(self);
ArrhcPanel[V_Count].Parent := ArrhqPanel;
ArrhcPanel[V_Count].Width := 800;
ArrhcPanel[V_Count].Height :=48;
ArrhcPanel[V_Count].BevelInner := bvLowered;
ArrhcPanel[V_Count].BevelOuter := bvRaised;
ArrhcPanel[V_Count].Top :=ArrhcPanel[V_Count].Top + ArrhcPanel[V_Count-1].Height +2;
ArrhcPanel[V_Count].Left:=ArrhcPanel[V_Count].Left+2;
ArrhcPanel[V_Count].ColorHighlight := clFuchsia;
ArrhcPanel[V_Count].ColorShadow := clFuchsia;
end;
BitBtn1.Enabled := True;
BitBtn3.Enabled := False;
end;
procedure TMainFrm.BitBtn5Click(Sender: TObject);
begin
Close;
end;
procedure TMainFrm.StatusDrawPanel(StatusBar: TStatusBar;
Panel: TStatusPanel
const Rect: TRect);
begin
StatusDrawRect:=rect
//记录要实现状态条特技的坐标范围
end;
end.