标签:
//点击不同按钮生成不同页面加载到某个panel上面。
procedure TMainForm.DemoButtonClick(Sender: TObject); var NewDemoClass: TFormClass; // TFormClass = class of TForm; 涉及到类的类 知识点; NewDemoClass表示为窗体类的类,有待考证
NewDemo: TForm; begin case (Sender as TSpeedButton).Tag of 0: NewDemoClass := TSpeedForm; //type TSpeedForm = class(TForm)
1: NewDemoClass := TGeneralForm; 2: NewDemoClass := TPropertiesForm; 3: NewDemoClass := TVisibilityForm; 5: NewDemoClass := TGridForm; 6: NewDemoClass := TDrawTreeForm; 7: NewDemoClass := TAlignForm; 8: NewDemoClass := TWindowsXPForm; 9: NewDemoClass := TNodeForm; 10: NewDemoClass := THeaderOwnerDrawForm; else NewDemoClass := nil; end; if (ContainerPanel.ControlCount = 0) or not (ContainerPanel.Controls[0] is NewDemoClass) then //panel上没有或不是当前类时才可能创建。 begin if ContainerPanel.ControlCount > 0 then ContainerPanel.Controls[0].Free; if Assigned(NewDemoClass) then begin NewDemo := NewDemoClass.Create(Self);//所属为self 指主窗体 NewDemo.Hide; NewDemo.BorderStyle := bsNone; NewDemo.Parent := ContainerPanel; //显示的位置 NewDemo.Align := alClient; NewDemo.Show; end; end; end;
点击不同按钮生成不同窗体到某个panel上面,类似Frame用法--不错
标签:
原文地址:http://www.cnblogs.com/rogge7/p/4528845.html