unit ChoiceRoom;interfaceuses
Windows, Messages, SysUtils, Buttons, Classes,Forms,StdCtrls,
Grids,DBGrids, DBCtrls, Mask;type
TChoiceRoom = class(TComponent)
private FHouseNum:String;
procedure CancelClick(Sender: TObject);
procedure OkClick(Sender: TObject); protected
{ Protected declarations }
public constructor Create(AOwner: TComponent); override;
destructor Destroy; override; published function Execute():String; end;procedure Register;implementationprocedure Register;
begin
RegisterComponents('Hotel', [TChoiceRoom]);
end;constructor TChoiceRoom.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
end;destructor TChoiceRoom.Destroy;
begin
inherited Destroy;
end;function TChoiceRoom.Execute():string;
var
GroupBox1:TGroupBox;
GroupBox2:TGroupBox;
FormChoice:TForm;
begin FormChoice := TForm.Create(Application);
with FormChoice do
begin
Name := 'FormChoice';
Caption := '请选择一个帐户';
Height := 367;
Width := 497;
BorderStyle := bsDialog;
Position := poOwnerFormCenter; GroupBox1 := TGroupBox.Create(self);
with GroupBox1 do
begin
Parent := FormChoice;
Caption := '请输入查询条件:';
Top := 8;
Left := 8;
Height := 65;
Width := 473;
end; with TLabel.Create(self) do
begin
Parent := GroupBox1;
Name := 'Label1';
Caption := '房号:';
Top := 32;
Left := 16;
Height := 13;
Width := 36;
end; with TLabel.Create(self) do
begin
Parent := GroupBox1;
Name := 'Label2';
Caption := '宾客姓名:';
Top := 32;
Left := 120;
Height := 13;
Width := 60;
end; with TLabel.Create(self) do
begin
Parent := GroupBox1;
Name := 'Label3';
Caption := '帐号:';
Top := 32;
Left := 280;
Height := 13;
Width := 36;
end; with TEdit.Create(self) do
begin
Parent := GroupBox1;
Name := 'ERoomNum';
Text := '';
Top := 29;
Left := 56;
Height := 13;
Width := 57;
end; with TEdit.Create(self) do
begin
Parent := GroupBox1;
Name := 'EGuestName';
Text := '';
Top := 29;
Left := 184;
Height := 13;
Width := 89;
end; with TEdit.Create(self) do
begin
Parent := GroupBox1;
Name := 'ERoomCnt';
Text := '';
Top := 29;
Left := 312;
Height := 13;
Width := 89;
end; with TBitBtn.Create(self) do
begin
Parent := GroupBox1;
Name := 'BitBtn1';
Caption := '查询';
Top := 16;
Left := 416;
Height := 41;
Width := 49;
end; with TDBGrid.Create(self) do
begin
Parent := FormChoice;
Name := 'BDGrid1';
Top := 80;
Left := 8;
Height := 129;
Width := 473;
end; with TCheckBox.Create(self) do
begin
Parent := FormChoice;
Name := 'chkEmpty';
Caption := '空房';
Checked := False;
Enabled := False;
Top := 216;
Left := 16;
Height := 17;
Width := 60;
end; with TCheckBox.Create(self) do
begin
Parent := FormChoice;
Name := 'chkBooking';
Caption := '预订';
Checked := False;
Enabled := False;
Top := 216;
Left := 80;
Height := 17;
Width := 60;
end; with TCheckBox.Create(self) do
begin
Parent := FormChoice;
Name := 'chkstay';
Caption := '在店';
Checked := False;
Enabled := False;
Top := 216;
Left := 144;
Height := 17;
Width := 60;
end; with TCheckBox.Create(self) do
begin
Parent := FormChoice;
Name := 'chkCheckout';
Caption := '已结';
Checked := False;
Enabled := False;
Top := 216;
Left := 208;
Height := 17;
Width := 60;
end; with TCheckBox.Create(self) do
begin
Parent := FormChoice;
Name := 'chkGroup';
Caption := '团队房';
Checked := False;
Enabled := False;
Top := 216;
Left := 272;
Height := 17;
Width := 60;
end; with TCheckBox.Create(self) do
begin
Parent := FormChoice;
Name := 'chkRepair';
Caption := '维修房';
Checked := False;
Enabled := False;
Top := 216;
Left := 344;
Height := 17;
Width := 60;
end; with TCheckBox.Create(self) do
begin
Parent := FormChoice;
Name := 'chkClose';
Caption := '关闭房';
Checked := False;
Enabled := False;
Top := 216;
Left := 416;
Height := 17;
Width := 60;
end; GroupBox2 := TGroupBox.Create(self);
with GroupBox2 do
begin
Parent := FormChoice;
Caption := '';
Top := 232;
Left := 8;
Height := 105;
Width := 401;
end; with TLabel.Create(self) do
begin
Parent := GroupBox2;
Name := 'Label4';
Caption := '备注:';
Top := 16;
Left := 8;
Height := 13;
Width := 36;
end; with TLabel.Create(self) do
begin
Parent := GroupBox2;
Name := 'Label5';
Caption := '旅行社/公司备注:';
Top := 40;
Left := 8;
Height := 13;
Width := 101;
end; with TDBEdit.Create(self) do
begin
Parent := GroupBox2;
Name := 'DBEdtMemo';
Text := '';
Top := 16;
Left := 48;
Height := 21;
Width := 345;
end; with TDBMemo.Create(self) do
begin
Parent := GroupBox2;
Name := 'DBEdtCoMemo';
Text := '';
Top := 56;
Left := 48;
Height := 41;
Width := 345;
end; with TBitBtn.Create(self) do
begin
Parent := FormChoice;
Name := 'BitBtn2';
Caption := '确定';
Top := 240;
Left := 416;
Height := 25;
Width := 67;
OnClick := OkClick;
end; with TBitBtn.Create(self) do
begin
Parent := FormChoice;
Name := 'BitBtn3';
Caption := '取消';
Top := 272;
Left := 416;
Height := 25;
Width := 67;
OnClick := CancelClick;
end; with TBitBtn.Create(self) do
begin
Parent := FormChoice;
Name := 'BitBtn4';
Caption := '帮助';
Top := 304;
Left := 416;
Height := 25;
Width := 67;
end; ShowModal;
Result := FHouseNum;
end;
end;procedure TChoiceRoom.CancelClick(Sender: TObject);
begin
FHouseNum := '';
TBitBtn(Sender).Parent.free ;
end;procedure TChoiceRoom.OkClick(Sender: TObject);
begin
FHouseNum := '1111';
TBitBtn(Sender).Parent.free ;
end;
end.当点击BitBtn1或BitBtn2后,FormChoice被释放掉了,但应用程序不能获得焦点,程序界面定死不能进行任何操作,如果点击FormChoice能正常关闭该窗体,但发现窗体没有被正常释放。
请问怎么解决?还是我的设计思路有问题?
Windows, Messages, SysUtils, Buttons, Classes,Forms,StdCtrls,
Grids,DBGrids, DBCtrls, Mask;type
TChoiceRoom = class(TComponent)
private FHouseNum:String;
procedure CancelClick(Sender: TObject);
procedure OkClick(Sender: TObject); protected
{ Protected declarations }
public constructor Create(AOwner: TComponent); override;
destructor Destroy; override; published function Execute():String; end;procedure Register;implementationprocedure Register;
begin
RegisterComponents('Hotel', [TChoiceRoom]);
end;constructor TChoiceRoom.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
end;destructor TChoiceRoom.Destroy;
begin
inherited Destroy;
end;function TChoiceRoom.Execute():string;
var
GroupBox1:TGroupBox;
GroupBox2:TGroupBox;
FormChoice:TForm;
begin FormChoice := TForm.Create(Application);
with FormChoice do
begin
Name := 'FormChoice';
Caption := '请选择一个帐户';
Height := 367;
Width := 497;
BorderStyle := bsDialog;
Position := poOwnerFormCenter; GroupBox1 := TGroupBox.Create(self);
with GroupBox1 do
begin
Parent := FormChoice;
Caption := '请输入查询条件:';
Top := 8;
Left := 8;
Height := 65;
Width := 473;
end; with TLabel.Create(self) do
begin
Parent := GroupBox1;
Name := 'Label1';
Caption := '房号:';
Top := 32;
Left := 16;
Height := 13;
Width := 36;
end; with TLabel.Create(self) do
begin
Parent := GroupBox1;
Name := 'Label2';
Caption := '宾客姓名:';
Top := 32;
Left := 120;
Height := 13;
Width := 60;
end; with TLabel.Create(self) do
begin
Parent := GroupBox1;
Name := 'Label3';
Caption := '帐号:';
Top := 32;
Left := 280;
Height := 13;
Width := 36;
end; with TEdit.Create(self) do
begin
Parent := GroupBox1;
Name := 'ERoomNum';
Text := '';
Top := 29;
Left := 56;
Height := 13;
Width := 57;
end; with TEdit.Create(self) do
begin
Parent := GroupBox1;
Name := 'EGuestName';
Text := '';
Top := 29;
Left := 184;
Height := 13;
Width := 89;
end; with TEdit.Create(self) do
begin
Parent := GroupBox1;
Name := 'ERoomCnt';
Text := '';
Top := 29;
Left := 312;
Height := 13;
Width := 89;
end; with TBitBtn.Create(self) do
begin
Parent := GroupBox1;
Name := 'BitBtn1';
Caption := '查询';
Top := 16;
Left := 416;
Height := 41;
Width := 49;
end; with TDBGrid.Create(self) do
begin
Parent := FormChoice;
Name := 'BDGrid1';
Top := 80;
Left := 8;
Height := 129;
Width := 473;
end; with TCheckBox.Create(self) do
begin
Parent := FormChoice;
Name := 'chkEmpty';
Caption := '空房';
Checked := False;
Enabled := False;
Top := 216;
Left := 16;
Height := 17;
Width := 60;
end; with TCheckBox.Create(self) do
begin
Parent := FormChoice;
Name := 'chkBooking';
Caption := '预订';
Checked := False;
Enabled := False;
Top := 216;
Left := 80;
Height := 17;
Width := 60;
end; with TCheckBox.Create(self) do
begin
Parent := FormChoice;
Name := 'chkstay';
Caption := '在店';
Checked := False;
Enabled := False;
Top := 216;
Left := 144;
Height := 17;
Width := 60;
end; with TCheckBox.Create(self) do
begin
Parent := FormChoice;
Name := 'chkCheckout';
Caption := '已结';
Checked := False;
Enabled := False;
Top := 216;
Left := 208;
Height := 17;
Width := 60;
end; with TCheckBox.Create(self) do
begin
Parent := FormChoice;
Name := 'chkGroup';
Caption := '团队房';
Checked := False;
Enabled := False;
Top := 216;
Left := 272;
Height := 17;
Width := 60;
end; with TCheckBox.Create(self) do
begin
Parent := FormChoice;
Name := 'chkRepair';
Caption := '维修房';
Checked := False;
Enabled := False;
Top := 216;
Left := 344;
Height := 17;
Width := 60;
end; with TCheckBox.Create(self) do
begin
Parent := FormChoice;
Name := 'chkClose';
Caption := '关闭房';
Checked := False;
Enabled := False;
Top := 216;
Left := 416;
Height := 17;
Width := 60;
end; GroupBox2 := TGroupBox.Create(self);
with GroupBox2 do
begin
Parent := FormChoice;
Caption := '';
Top := 232;
Left := 8;
Height := 105;
Width := 401;
end; with TLabel.Create(self) do
begin
Parent := GroupBox2;
Name := 'Label4';
Caption := '备注:';
Top := 16;
Left := 8;
Height := 13;
Width := 36;
end; with TLabel.Create(self) do
begin
Parent := GroupBox2;
Name := 'Label5';
Caption := '旅行社/公司备注:';
Top := 40;
Left := 8;
Height := 13;
Width := 101;
end; with TDBEdit.Create(self) do
begin
Parent := GroupBox2;
Name := 'DBEdtMemo';
Text := '';
Top := 16;
Left := 48;
Height := 21;
Width := 345;
end; with TDBMemo.Create(self) do
begin
Parent := GroupBox2;
Name := 'DBEdtCoMemo';
Text := '';
Top := 56;
Left := 48;
Height := 41;
Width := 345;
end; with TBitBtn.Create(self) do
begin
Parent := FormChoice;
Name := 'BitBtn2';
Caption := '确定';
Top := 240;
Left := 416;
Height := 25;
Width := 67;
OnClick := OkClick;
end; with TBitBtn.Create(self) do
begin
Parent := FormChoice;
Name := 'BitBtn3';
Caption := '取消';
Top := 272;
Left := 416;
Height := 25;
Width := 67;
OnClick := CancelClick;
end; with TBitBtn.Create(self) do
begin
Parent := FormChoice;
Name := 'BitBtn4';
Caption := '帮助';
Top := 304;
Left := 416;
Height := 25;
Width := 67;
end; ShowModal;
Result := FHouseNum;
end;
end;procedure TChoiceRoom.CancelClick(Sender: TObject);
begin
FHouseNum := '';
TBitBtn(Sender).Parent.free ;
end;procedure TChoiceRoom.OkClick(Sender: TObject);
begin
FHouseNum := '1111';
TBitBtn(Sender).Parent.free ;
end;
end.当点击BitBtn1或BitBtn2后,FormChoice被释放掉了,但应用程序不能获得焦点,程序界面定死不能进行任何操作,如果点击FormChoice能正常关闭该窗体,但发现窗体没有被正常释放。
请问怎么解决?还是我的设计思路有问题?
解决方案 »
- 虚拟机中是不是取不到硬盘序列号?
- 我想将某个exe文件保存到sqlserver数据库中,然后将该文件释放到sqlserver服务器的c盘根目录,代码该如何写?
- 问个问题啊,请大家支招
- 有什么三层结构开发的好书推荐?
- 请问一下,大家一般在程序中用那种写日志的方法啊.
- 如何即时刷新:关于ADOQuery、DBGrid、DataSource
- 初学者的DBGrid问题
- 请问tts(text to speech)怎样安装和使用
- 不知道大家是否能够让combobox右边的小箭头按钮不可见 ,但是在点击后才能可见 ,并且功能照旧
- 如何在for..to 里用label1.caption来显示循环进度
- GetMem的用法?
- 子窗体释放后程序主窗口不能获得焦点,程序暂停,怎么解决? (急急急)
————————————————————————————
当点击BitBtn1或BitBtn2后,FormChoice被释放掉了,但应用程序不能获得焦点,程序界面定死不能进行任何操作,如果点击FormChoice窗口上的关闭图标能正常关闭该窗体,但发现窗体没有被正常释放。请问怎么解决?还是我的设计思路有问题?
另外 TForm((Sender as TComponent).Parent).Closel
使用TForm(Sender as TComponent).Parent.Close提示close方法没有定义,但用showmessage(TForm(Sender as TComponent).Parent.Name)显示的却是FormChoice,百思不得其解啊。
主窗体.setfocus好了