而且发现BindEvent()的一个不足就是把命令按钮的CLICK托管到Form后 只要在Form上任意一点点击都将实现点击结果。。。。
这个。。这个。。
这个。。这个。。

梅尚程荀
马谭杨奚
程序代码: If .Key.ask_Button == .T.
.AddObject("Ctnr_Button","CommandButton")
With This.Ctnr_Button
.Height = 30
.Caption = This.Key.btn_Caption
.Left = This.Ctnr_Text.Left + This.Ctnr_Text.Width + ln_Space
.Top = This.Key.chg_Height / 2 - .Height / 2
.Width = 100
EndWith
Do case
Case This.Key.ID == "Number"
BindEvent(.Ctnr_Button, "Click", This, "Click_Number")
EndCase
EndIf
.SetAll("Visible", .T.)
.SetAll("FontSize", 16)
.SetAll("Alignment", 2)
.SetAll("FontBold", 1)
.Height = .Key.chg_Height
EndWith
EndProc
Procedure Click_Number
MessageBox("Hhahaha")
EndProc



程序代码:Clear All
Main()
Procedure Main()
Local lo_MainForm
lo_MainForm = NewObject("C_Form")
lo_MainForm.Show
Read Events
Return
EndProc
DEFINE CLASS C_Form AS Form
AutoCenter = .T.
Width = 600
Height = 600
PROCEDURE Init
FOR i = 1 TO 8
lc_Name = "xx" + TRANSFORM(i)
This.AddObject(lc_Name, "myClass")
WITH This.&lc_Name
.Caption = "Caption + " + TRANSFORM(i)
.Height = 20 + 5 * (i - 1)
.Top = .Height * (i - 1)
.Width = 300
.Visible = .T.
.Resize
ENDWITH
NEXT
ENDPROC
PROCEDURE Click
ThisForm.SetAll("Caption", "bbb")
ENDPROC
ENDDEFINE
DEFINE CLASS myClass AS Container
Caption = ""
ADD OBJECT Label1 AS Label WITH Caption = "aaa", Left = 10, Top = 0, Width = 40, Height = 20
ADD Object TextBox1 AS TextBox with Left =200, value = 10, Top = 0, Width = 40, Height = 20
PROCEDURE Resize
WITH This
.SetAll("Height", .Height)
ENDWITH
ENDPROC
PROCEDURE TextBox1.Valid
With This
IF EMPTY(This.Value)
RETURN .F.
EndIf
EndWith
EndProc
Procedure Destroy
Clear Events
EndProc
ENDDEFINE---