Click on different buttons to generate different pages to load onto a panel.
Procedure Tmainform.demobuttonclick (sender:tobject); var newdemoclass:tformclass; Tformclass = Class of Tform; refers to the class knowledge point of the class; Newdemoclass is represented as a class of form class, subject to textual research
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; Ten: newdemoclass: = Theaderownerdrawform; else newdemoclass: = nil; End; The IF (containerpanel.controlcount = 0) or not (Containerpanel.controls[0] is Newdemoclass) and then//panel are not possible to be created without or not the current class. begin If containerpanel.controlcount > 0 then containerpanel.controls[0]. Free; If Assigned (newdemoclass) then the begin Newdemo: = Newdemoclass.create (self);//belong to self refer to main form Newdemo.hide; Newdemo.borderstyle: = Bsnone; Newdemo.parent: = Containerpanel; Displayed position newdemo.align: = alclient; Newdemo.show; End; End;end;
Click on different buttons to generate a different form onto a panel, like frame usage--good