J
jackywu2005
Unregistered / Unconfirmed
GUEST, unregistred user!
procedure TForm1.ToolButton1Click(Sender: TObject);
var
Sheet:TTabSheet;
frm_sprk:TFrm_Sprk;
begin
if PageMain.Visible =false then
begin
PageMain.Visible :=True;
end;
//定义TAB
sheet:=TTabSheet.Create(PageMain);
Sheet.PageControl :=PageMain ;
Sheet.Name:='Tab_sprk';
TabID :=LongInt(Sheet);
//定义窗体
frm_sprk:=TFrm_Sprk.Create(application);
frm_sprk.BorderStyle :=bsNone;
frm_sprk.Align:=alClient ;
frm_sprk.Parent :=Sheet;
frm_sprk.caption:='商品入库';
self.SkinData1.AddNestForm(Self,frm_sprk);
frm_sprk.Visible :=True;
PageMain.ActivePage :=Sheet ;
sheet.Caption:=frm_sprk.caption;
ToolButton1.Enabled :=false;
end;
建立可以成功
但是问题是窗口怎么关闭啊~!
我在frm_sprk窗体上设按钮关闭,该用什么代码?
是直接关闭Sheet吗?
用
TTabSheet(TabID).Free;
if form1.PageMain.PageCount =0 then
begin
form1.PageMain.Visible :=false;
form1.ToolButton1.Enabled :=True;
Frm_Sprk:=nil;
end;
却报错
显示:Control '' has no parent window.
是为什么啊!
var
Sheet:TTabSheet;
frm_sprk:TFrm_Sprk;
begin
if PageMain.Visible =false then
begin
PageMain.Visible :=True;
end;
//定义TAB
sheet:=TTabSheet.Create(PageMain);
Sheet.PageControl :=PageMain ;
Sheet.Name:='Tab_sprk';
TabID :=LongInt(Sheet);
//定义窗体
frm_sprk:=TFrm_Sprk.Create(application);
frm_sprk.BorderStyle :=bsNone;
frm_sprk.Align:=alClient ;
frm_sprk.Parent :=Sheet;
frm_sprk.caption:='商品入库';
self.SkinData1.AddNestForm(Self,frm_sprk);
frm_sprk.Visible :=True;
PageMain.ActivePage :=Sheet ;
sheet.Caption:=frm_sprk.caption;
ToolButton1.Enabled :=false;
end;
建立可以成功
但是问题是窗口怎么关闭啊~!
我在frm_sprk窗体上设按钮关闭,该用什么代码?
是直接关闭Sheet吗?
用
TTabSheet(TabID).Free;
if form1.PageMain.PageCount =0 then
begin
form1.PageMain.Visible :=false;
form1.ToolButton1.Enabled :=True;
Frm_Sprk:=nil;
end;
却报错
显示:Control '' has no parent window.
是为什么啊!