end;Procedure ToffmonForm.CreateNewPan(const ObjName:shortString;const Creater:TwinControl);//这想要个功能,但是是用一个CREATER来做,听说是什么容器的。不会. var NewPan:TPanel; NewEdit:Tedit; NewBut:Tbutton; i:integer; begin newPan:= Tpanel.Create(self); newpan.Name :='pan'+objName; newpan.Parent :=mainPan; newpan.Caption :=''; newpan.Top:=creater.Top + creater.Height ; newpan.Left := creater.Left ; newpan.Width :=creater.Width ; newpan.Height := creater.Height ; for i:= 0 to 6 do begin if creater.Controls[i].ClassType = Tedit then begin newedit:=Tedit.Create(self); newedit.Name :='Newedit'+objname+inttostr(i); newedit.Parent :=newpan; newedit.Text :=''; newedit.Top :=(creater.Controls[i] as Tedit).Top ; newedit.left :=(creater.Controls[i] as Tedit).left ; newedit.width :=(creater.Controls[i] as Tedit).width ; newedit.height :=(creater.Controls[i] as Tedit).height ; end else begin newbut:=Tbutton.Create(self); newbut.Name :='newbut'+objname+inttostr(i); newbut.Parent :=newpan; newbut.Caption :=(creater.Controls[i] as Tbutton).Caption ; newbut.Top :=(creater.Controls[i] as Tbutton).Top ; newbut.left :=(creater.Controls[i] as Tbutton).left ; newbut.width :=(creater.Controls[i] as Tbutton).width ; newbut.height :=(creater.Controls[i] as Tbutton).height ; newbut.OnClick :=(creater.Controls[i] as Tbutton).OnClick ; end; end; end; procedure TOffMonForm.Button2Click(Sender: TObject); begin createnewpan(inttostr((sender as Tbutton).Parent.ComponentIndex),(sender as Tbutton).Parent); (sender as Tbutton).Enabled :=false; end;procedure TOffMonForm.Button3Click(Sender: TObject); begin with (sender as Tbutton).Parent do begin if ((controls[0] as tedit).Text = '') or ((controls[1] as tedit).Text = '') or((controls[2] as tedit).Text = '') then begin showmessage('Empty Value!'); end else begin if (controls[2] as tedit).Text = '-' then (controls[3] as tedit).Text := inttostr(strtoint((controls[0] as tedit).Text) - strtoint((controls[1] as tedit).Text)) else if (controls[2] as tedit).Text = '+' then (controls[3] as tedit).Text := inttostr(strtoint((controls[0] as tedit).Text)+strtoint((controls[1] as tedit).Text)) else if (controls[2] as tedit).Text = '/' then (controls[3] as tedit).Text := inttostr(strtoint((controls[0] as tedit).Text) div strtoint((controls[1] as tedit).Text)) else if (controls[2] as tedit).Text = '*' then (controls[3] as tedit).Text := inttostr(strtoint((controls[0] as tedit).Text)*strtoint((controls[1] as tedit).Text)) else showmessage('!!'); end; end; end;end.
2)因为没有RecNo,所以只能这样咯。BDE的数据库都是这样的。
3)点这个Panel,按Ctrl+C,然后在需要的地方Ctrl+v
请赐教!
newPan := TPanel.Create(Self);
newPan.Parent := Self;
newPan.Left := 100;
newPan.Width := 200;
...
newPan := TPanel.Create(Self);
newPan.Parent := panel1;
newPan.Left := 100;
newPan.Width := 200;
明天给你代码看。:)
怎么样解决,有什么好办法,可以知道TQUERY的当前记录位置.object OffMonForm: TOffMonForm
Left = 237
Top = 197
Width = 712
Height = 480
Caption = 'OffMonForm'
Color = clBtnFace
Font.Charset = GB2312_CHARSET
Font.Color = clWindowText
Font.Height = -13
Font.Name = 'MS Sans Serif'
Font.Style = []
FormStyle = fsMDIChild
OldCreateOrder = False
Position = poDefault
Visible = True
PixelsPerInch = 96
TextHeight = 13
object GroupBox1: TGroupBox
Left = 0
Top = 0
Width = 121
Height = 105
Caption = 'GroupBox1'
TabOrder = 0
end
object GroupBox2: TGroupBox
Left = 0
Top = 112
Width = 121
Height = 177
Caption = 'GroupBox2'
TabOrder = 1
end
object GroupBox3: TGroupBox
Left = 0
Top = 296
Width = 121
Height = 153
Caption = 'GroupBox3'
TabOrder = 2
end
object MainPan: TPanel
Left = 128
Top = 8
Width = 555
Height = 441
TabOrder = 3
object SourcePan: TPanel
Left = 0
Top = 0
Width = 553
Height = 73
TabOrder = 0
object Edit1: TEdit
Left = 8
Top = 8
Width = 121
Height = 21
TabOrder = 0
end
object Edit2: TEdit
Left = 144
Top = 8
Width = 121
Height = 21
TabOrder = 1
end
object Edit3: TEdit
Left = 288
Top = 8
Width = 121
Height = 21
TabOrder = 2
end
object Edit4: TEdit
Left = 424
Top = 8
Width = 121
Height = 21
TabOrder = 3
end
object Button1: TButton
Left = 472
Top = 40
Width = 75
Height = 25
Caption = 'Release'
TabOrder = 4
end
object Button2: TButton
Left = 392
Top = 40
Width = 75
Height = 25
Caption = 'Creater'
TabOrder = 5
OnClick = Button2Click
end
object Button3: TButton
Left = 312
Top = 40
Width = 75
Height = 25
Caption = 'Calculate'
TabOrder = 6
OnClick = Button3Click
end
end
end
object MainScrollBar: TScrollBar
Left = 684
Top = 8
Width = 16
Height = 441
Kind = sbVertical
PageSize = 0
TabOrder = 4
end
end
刚刚死机了。!unit OffMonUnit;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls;type
TOffMonForm = class(TForm)
GroupBox1: TGroupBox;
GroupBox2: TGroupBox;
GroupBox3: TGroupBox;
MainPan: TPanel;
MainScrollBar: TScrollBar;
SourcePan: TPanel;
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Edit4: TEdit;
Button1: TButton;
Button2: TButton;
Button3: TButton;
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
private
{ Private declarations }
Procedure CreateNewPan(const ObjName:shortString;const Creater:TwinControl);
Procedure FreeObj(FreePan:TPanel);
public
{ Public declarations }
end;var
OffMonForm: TOffMonForm;implementation{$R *.dfm}Procedure TOffMonForm.FreeObj(FreePan:TPanel);
begin
end;Procedure ToffmonForm.CreateNewPan(const ObjName:shortString;const Creater:TwinControl);//这想要个功能,但是是用一个CREATER来做,听说是什么容器的。不会.
var
NewPan:TPanel;
NewEdit:Tedit;
NewBut:Tbutton;
i:integer;
begin
newPan:= Tpanel.Create(self);
newpan.Name :='pan'+objName;
newpan.Parent :=mainPan;
newpan.Caption :='';
newpan.Top:=creater.Top + creater.Height ;
newpan.Left := creater.Left ;
newpan.Width :=creater.Width ;
newpan.Height := creater.Height ;
for i:= 0 to 6 do
begin
if creater.Controls[i].ClassType = Tedit then
begin
newedit:=Tedit.Create(self);
newedit.Name :='Newedit'+objname+inttostr(i);
newedit.Parent :=newpan;
newedit.Text :='';
newedit.Top :=(creater.Controls[i] as Tedit).Top ;
newedit.left :=(creater.Controls[i] as Tedit).left ;
newedit.width :=(creater.Controls[i] as Tedit).width ;
newedit.height :=(creater.Controls[i] as Tedit).height ;
end
else
begin
newbut:=Tbutton.Create(self);
newbut.Name :='newbut'+objname+inttostr(i);
newbut.Parent :=newpan;
newbut.Caption :=(creater.Controls[i] as Tbutton).Caption ;
newbut.Top :=(creater.Controls[i] as Tbutton).Top ;
newbut.left :=(creater.Controls[i] as Tbutton).left ;
newbut.width :=(creater.Controls[i] as Tbutton).width ;
newbut.height :=(creater.Controls[i] as Tbutton).height ;
newbut.OnClick :=(creater.Controls[i] as Tbutton).OnClick ;
end;
end;
end;
procedure TOffMonForm.Button2Click(Sender: TObject);
begin
createnewpan(inttostr((sender as Tbutton).Parent.ComponentIndex),(sender as Tbutton).Parent);
(sender as Tbutton).Enabled :=false;
end;procedure TOffMonForm.Button3Click(Sender: TObject);
begin
with (sender as Tbutton).Parent do
begin
if ((controls[0] as tedit).Text = '') or ((controls[1] as tedit).Text = '') or((controls[2] as tedit).Text = '') then
begin
showmessage('Empty Value!');
end
else
begin
if (controls[2] as tedit).Text = '-' then
(controls[3] as tedit).Text := inttostr(strtoint((controls[0] as tedit).Text) - strtoint((controls[1] as tedit).Text))
else if (controls[2] as tedit).Text = '+' then
(controls[3] as tedit).Text := inttostr(strtoint((controls[0] as tedit).Text)+strtoint((controls[1] as tedit).Text))
else if (controls[2] as tedit).Text = '/' then
(controls[3] as tedit).Text := inttostr(strtoint((controls[0] as tedit).Text) div strtoint((controls[1] as tedit).Text))
else if (controls[2] as tedit).Text = '*' then
(controls[3] as tedit).Text := inttostr(strtoint((controls[0] as tedit).Text)*strtoint((controls[1] as tedit).Text))
else
showmessage('!!');
end;
end;
end;end.