为何这样创建动态组件老是通不过(200)

W

woodyou

Unregistered / Unconfirmed
GUEST, unregistred user!
type TControlClass = Class of TControl; //定义一个类型procedure TinputForm.proDyComm(StCtrcomm: TControlClass;myCount,myheight,middleCount,myleft,mytop,mywidth,mystep,mymiddle:Integer;nameprefix:string;myOnKeyDown:TKeyEvent); //动态组件建立如:TLabel,TButton,TEdit var n, i:Integer; begin // stctr:=TControl.Create(StCtrcomm); stctr:= CreateComponent(StCtrcomm); for i := 0 to myCount-1 do begin begin if FindComponent( nameprefix+inttostr(i))<>nil then begin stctr(FindComponent( nameprefix+inttostr(i))).Free; //这里要对stctr进行释放? inherited; end; end; end; for n:= 0 to myCount-1 do begin stctr.Create(self).Name:= nameprefix+inttostr(n); with stctr(FindComponent( nameprefix+inttostr(n))) do begin width:=mywidth; //这里要对width/height/left进行设置? height:=myheight; if n<middleCount then begin left:=myleft; top:=(n+1)*mytop+n*(myheight+mystep) ; end else begin left:= myleft+mymiddle; top:=(n+1-middleCount)*mytop+(n-middleCount)*(myheight+mystep) ; end ; parent:=dbcgResult ; if stctr=TEdit then OnKeyDown:=myOnKeyDown; end; end; end;为何老是通不过测试,也无法建立通用动态组件模块,请大家想一下如何解决
 
J

johui

Unregistered / Unconfirmed
GUEST, unregistred user!
fStCtrcomm := StCtrcomm.Create 这样吧?
 

Similar threads

I
回复
0
查看
499
import
I
I
回复
0
查看
558
import
I
I
回复
0
查看
653
import
I
I
回复
0
查看
628
import
I
顶部