以下是引用bccn201203在2012-9-23 20:57:46的发言:
原来如此 还没用过那个。。。
梅尚程荀
马谭杨奚
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 Width = 400 Height = 400 AutoCenter = .T. Caption = "Experiment" Procedure Init With This .AddObject("xx", "CommandButton") With this.xx .Top = 100 .Left = 100 .Height = 50 .Width = 100 .Caption = "XXbtn" .Visible = .T. EndWith EndWith EndProc Procedure xx.Click MessageBox("阿弥陀佛") EndProc Procedure destroy Clear Events EndProc EndDefine编译器会提示他认不到XX..........
Define Class C_Container as Container BorderWidth = 2 SpecialEffect = 1 Width = 2 * (gn_HalfWndWidth - gn_Space) Key = "" Procedure Init(t_Ctnr) Local ln_Space as Integer ln_Space = 20 With This .Key = t_Ctnr .AddObject("Ctnr_Label","Label") With This.Ctnr_Label .Caption = This.Key.lbl_Caption .Height = 30 .Width = 200 .Left = 10 .Top = This.Key.chg_Height / 2 - .Height / 2 EndWith .AddObject("Ctnr_Text","TextBox") With This.Ctnr_Text .Left = This.Ctnr_Label.Left + This.Ctnr_Label.Width + ln_Space .Height = This.Key.chg_Height .Width = This.Key.chg_Width EndWith 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 EndIf .SetAll("Visible", .T.) .SetAll("FontSize", 16) .SetAll("Alignment", 2) .SetAll("FontBold", 1) .Height = .Key.chg_Height BindEvent(.Ctnr_Button, "Click", This, "Click") EndWith EndProc Procedure Click MessageBox("Hhahaha") EndProc EndDefine
Procedure Ctnr_Button.Click MessageBox("Hhahaha") EndProc去掉和不去掉BindEvent(.Ctnr_Button, "Click", This, "Click") 都不行?