BPL简单问题 ( 积分: 100 )

  • 主题发起人 主题发起人 delphihsc
  • 开始时间 开始时间
D

delphihsc

Unregistered / Unconfirmed
GUEST, unregistred user!
function&nbsp;ShowModalFormByClassName(const&nbsp;ClassName:&nbsp;string):&nbsp;integer;<br>var<br>&nbsp;&nbsp;frm:&nbsp;TCustomForm;<br>begin<br>&nbsp;&nbsp;frm&nbsp;:=&nbsp;CreateFormByClassName(ClassName);<br>&nbsp;&nbsp;try<br>&nbsp;&nbsp;&nbsp;&nbsp;Result&nbsp;:=&nbsp;frm.ShowModal;<br>&nbsp;&nbsp;finally<br>&nbsp;&nbsp;&nbsp;&nbsp;frm.Release;<br>&nbsp;&nbsp;end;<br>end;<br>function&nbsp;CreateFormByClassName(const&nbsp;ClassName:&nbsp;string):&nbsp;TCustomForm;<br>var<br>&nbsp;&nbsp;AClass:&nbsp;TPersistentClass;<br>begin<br>&nbsp;&nbsp;{&nbsp;Note&nbsp;that&nbsp;TApplication&nbsp;&quot;owns&quot;&nbsp;this&nbsp;form&nbsp;and&nbsp;thus&nbsp;it&nbsp;must&nbsp;be&nbsp;freed&nbsp;prior<br>&nbsp;&nbsp;&nbsp;&nbsp;to&nbsp;unloading&nbsp;the&nbsp;package&nbsp;}<br>&nbsp;&nbsp;AClass&nbsp;:=&nbsp;GetClass(ClassName);<br>&nbsp;&nbsp;if&nbsp;AClass&nbsp;&lt;&gt;&nbsp;nil&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;Result&nbsp;:=&nbsp;TComponentClass(AClass).Create(Application)&nbsp;as&nbsp;TCustomForm<br>&nbsp;&nbsp;else<br>&nbsp;&nbsp;&nbsp;&nbsp;raise&nbsp;Exception.CreateFmt(sErrorCreateForm,&nbsp;[ClassName]);<br>end;<br>ShowModalFormByClassName(窗体名)<br>怎么样把上面的改成可以显示多窗体的.<br>&nbsp;&nbsp;&nbsp;&nbsp;Result&nbsp;:=&nbsp;frm.ShowModal;<br>我把这句改成frm.show不行.
 
不要用finally.
 
可将多窗体分别放在不同的TPanel中,show就可以了
 
后退
顶部