这个算动态吗?
搞出了一个传参数 来实现按钮 动态增加 和 尺寸动态改变的方法不知道可以吗 大牛们看看怎么样 还有好方法吗?
代码 有点不规范 不过比较短。。。
程序代码:
Clear All Public ga_Struct[4] ga_Struct[1] = CreateObject("St", 200, 100, "this is a" , .T., Rgb(234, 4, 6)) ga_Struct[2] = CreateObject("St", 100, 40, "this is b", .F. , Rgb(3, 45, 62)) ga_Struct[3] = CreateObject("St", 20, 80, "this is c" , .F., Rgb(23, 124, 6)) ga_Struct[4] = CreateObject("St", 250, 220, "this is d", .T., Rgb(214, 114, 96) ) Main() Clear All Return Procedure Main() Local lo_MainForm lo_MainForm = NewObject("C_Form") lo_MainForm.Show Read Events EndProc Define Class St as Custom a = 100 b = 100 s = "haha" q = .T. c = Rgb(0, 0, 0) Procedure Init(tn_a, tn_b, tc_s, tb_q, tc_c) With This .a = tn_a .b = tn_b .s = tc_s .q = tb_q .c = tc_c EndWith EndProc EndDefine Define Class Cbtn as Container k = "" SpecialEffect = 1 BorderWidth = 3 Procedure Init(St_k) With This .k = St_k .AddObject("lb", "Label") With this.lb .Caption = This.k.s .width = 80 .Height = 40 .Visible = .T. .Top = This.k.b / 2 - .Height / 2 .BackColor = This.k.c EndWith .AddObject("tb", "TextBox") With this.tb .Value = 0 .width = This.k.a .Left = 100 .Height = This.k.b .Visible = .T. EndWith If This.K.q == .T. .AddObject("btn", "CommandButton") With this.btn .Caption = This.k.s .width = 80 .Height = 40 .visible = .T. .Left = This.tb.Left + This.tb.Width + 10 .Visible = .T. EndWith EndIf .Width = 440 .Height = .tb.Height .SetAll("Alignment", 1) EndWith EndProc EndDefine Define Class C_Form as Form Width = 500 Height = 500 AutoCenter = .T. Caption = "Experiment" Procedure Init With This For i = 1 to Alen(ga_Struct, 0) lc_Name = "xx_" + Padl(i, 2, '0') .AddObject(lc_Name, "Cbtn", ga_Struct[i]) With This.&lc_Name .Left = 20 If i == 1 b1 = 50 Else b1 = b1 + ga_Struct[i -1].b EndIf .Top = b1 .Visible = .T. EndWith EndFor EndWith EndProc Procedure destroy Clear Events EndProc EndDefine