授人以渔,不授人以鱼。
回复 8楼 吹水佬
我在main.prg里 声明一个公共类 里面有clear events
*----------------------- * 多窗体示例 * [color=#800000]2015.12.08.[/color] *----------------------- SET PATH TO "..\MyTools" SET PROCEDURE TO "MyForm" oMainForm = CREATEOBJECT("C_MainForm") oMainForm.Show READ EVENTS RETURN DEFINE CLASS C_MainForm AS MyForm Caption = "主窗体" ShowWindow = 2 Width = 600 Height = 400 AutoCenter = .T. ADD OBJECT cmdLogin AS CommandButton WITH Caption = "登录", Width = 100, Height = 25 PROCEDURE Arrange WITH This.cmdLogin .Top = (This.Height - .Height) / 2 .Left = (This.Width - .Width) / 2 ENDWITH ENDPROC PROCEDURE Destroy CLEAR EVENTS ENDPROC PROCEDURE cmdLogin.Click LOCAL loLogin loLogin = CREATEOBJECT("C_Login") loLogin.Show ENDPROC ENDDEFINE DEFINE CLASS C_Login AS MyForm Caption = "登陆" ShowWindow = 1 WindowType = 1 Width = 300 Height = 200 AutoCenter = .T. PROCEDURE Destroy * 重写Destroy否决父类中默認CLEAR EVENTS的动作 ENDPROC ENDDEFINE
DEFINE CLASS MyForm AS Form PROCEDURE Arrange FOR EACH obj IN This.Controls FOXOBJECT IF (VARTYPE(obj.CanArrange) == "L") .AND. obj.CanArrange obj.Arrange ENDIF NEXT ENDPROC PROCEDURE Activate This.Arrange ENDPROC PROCEDURE Resize This.Arrange ENDPROC PROCEDURE Destroy CLEAR EVENTS ENDPROC ENDDEFINE
[此贴子已经被作者于2015-12-8 13:03编辑过]
SET PATH TO "..\MyTools" SET PROCEDURE TO "MyForm" oMainForm = CREATEOBJECT("C_MainForm") oMainForm.startLoginForm READ EVENTS RETURN DEFINE CLASS C_MainForm AS MyForm Caption = "主窗体" ShowWindow = 2 Width = 600 Height = 400 AutoCenter = .T. ADD OBJECT cmdLogin AS CommandButton WITH Caption = "登录", Width = 100, Height = 25 PROCEDURE Arrange WITH This.cmdLogin .Top = (This.Height - .Height) / 2 .Left = (This.Width - .Width) / 2 ENDWITH ENDPROC PROCEDURE Destroy CLEAR EVENTS ENDPROC PROCEDURE startLoginForm LOCAL loLogin loLogin = CREATEOBJECT("C_Login") loLogin.show ENDPROC ENDDEFINE DEFINE CLASS C_Login AS MyForm Caption = "登陆" ShowWindow = 1 WindowType = 1 Width = 300 Height = 200 AutoCenter = .T. PROCEDURE Destroy oMainForm.show * 重写Destroy否决父类中默認CLEAR EVENTS的动作 ENDPROC ENDDEFINE