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; with stctr(FindComponent( nameprefix+inttostr)) 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;为何老是通不过测试,也无法建立通用动态组件模块,请大家想一下如何解决