是的,这是兼容性的写法。不用自定义类的时候,就必须用BindEvent()把特定对象的事件代码委托到别的对象中去。
程序代码:
Define Class C_Form as Form Width = 400 Height = 400 AutoCenter = .T. Caption = "Experiment" Procedure Init With This .AddObject("xx", "CommandButton") With .xx .Top = 100 .Left = 100 .Height = 50 .Width = 100 .Caption = "XXbtn" .Visible = .T. EndWith BindEvent(.xx, "Click", This, "Click") EndWith EndProc Procedure Click MessageBox("阿弥陀佛") EndProc Procedure destroy Clear Events EndProc EndDefine
授人以渔,不授人以鱼。