回复 9楼 zyxxzhyg
谢谢!
报告老师,我低头不是因为我在装低调,是你问的问题,我真的不会答,,,
of = CREATEOBJECT("logForm") of.show(1) DEFINE CLASS logForm as Form testLoginCount = 3 ADD OBJECT cmdLogin as loginBtn ENDDEFINE DEFINE CLASS loginBtn as CommandButton top=168 left=144 height=25 width=60 caption="登 录" PROCEDURE click thisform.testLoginCount = thisform.testLoginCount - 1 IF thisform.testLoginCount == 0 MESSAGEBOX("尝试登录过于频繁,程序将退出!如有问题,请联系程序管理员!",64,"非法登录警告!") thisform.Release ELSE ENDIF ENDDEFINE
of = CREATEOBJECT("logForm") of.show(1) DEFINE CLASS logForm as Form ADD OBJECT cmdLogin as loginBtn ENDDEFINE DEFINE CLASS loginBtn as CommandButton top=168 left=144 height=25 width=60 caption="登 录" testLoginCount = 3 PROCEDURE click this.testLoginCount = this.testLoginCount - 1 IF this.testLoginCount == 0 MESSAGEBOX("尝试登录过于频繁,程序将退出!如有问题,请联系程序管理员!",64,"非法登录警告!") thisform.Release ELSE ENDIF ENDDEFINE
*----------------------- * 登录示例 * [color=#800000]2015.12.15.[/color] *----------------------- CLEAR ALL CLOSE PROCEDURES SET PATH TO "..\MyTools" SET PROCEDURE TO "MyForm", "MyLogin" PUBLIC gcUserName Login("gcUserName") IF !EMPTY(gcUserName) Main() ENDIF CLOSE PROCEDURES CLEAR ALL RETURN PROCEDURE Main() LOCAL loMainForm loMainForm = CREATEOBJECT("C_MainForm") WITH loMainForm .Caption = "主窗体" .Width = 600 .Height = 400 .AutoCenter = .T. .Show ENDWITH READ EVENTS ENDPROC DEFINE CLASS C_MainForm AS MyForm ShowWindow = 2 ADD OBJECT Label1 AS Label WITH Caption = "欢迎您!" + gcUserName, FontSize = 36, AutoSize = .T. PROCEDURE Arrange WITH This.Label1 .Top = (This.Height - .Height) / 2 .Left = (This.Width - .Width) / 2 ENDWITH ENDPROC ENDDEFINE
PROCEDURE Login(tcControlSource) LOCAL loLogin &tcControlSource = "" loLogin = CREATEOBJECT("MyLogin", tcControlSource) loLogin.Show READ EVENTS ENDPROC DEFINE CLASS MyLogin AS MyForm ShowWindow = 2 Caption = "请登录" Width = 300 Height = 200 BorderStyle = 1 ControlBox = .F. AutoCenter = .T. ADD OBJECT Label1 AS Label WITH Caption = "账号:", Width = 60, Height = 25, Alignment = 1, FontBold = .T. ADD OBJECT Text1 AS TextBox WITH Width = 100, Height = 25 ADD OBJECT Label2 AS Label WITH Caption = "密码:", Width = 60, Height = 25, Alignment = 1, FontBold = .T. ADD OBJECT Text2 AS TextBox WITH Value = "", PasswordChar = "*" ADD OBJECT Button1 AS CommandButton WITH Caption = "提交", Width = 40, Height = 25 PROCEDURE Arrange WITH This.Label1 .Top = 5 .Left = 5 ENDWITH WITH This.Text1 .Top = This.Label1.Top .Left = This.Label1.Left + This.Label1.Width + 5 ENDWITH WITH This.Label2 .Top = This.Label1.Top + This.Label1.Height + 5 .Left = This.Label1.Left ENDWITH WITH This.Text2 .Top = This.Label2.Top .Left = This.Label2.Left + This.Label2.Width + 5 ENDWITH WITH This.Button1 .Top = This.Label2.Top + This.Label2.Height + 5 .Left = 5 ENDWITH This.Height = This.Button1.Top + This.Button1.Height This.Width = This.Text2.Left + This.Text2.Width + 5 ENDPROC PROCEDURE Init(tcControlSource) IF !EMPTY(tcControlSource) This.Text1.ControlSource = tcControlSource RETURN .T. ELSE RETURN .F. ENDIF ENDPROC PROCEDURE Text1.Valid This.Value = ALLTRIM(This.Value) ENDPROC PROCEDURE Text2.Valid This.Value = ALLTRIM(This.Value) ENDPROC PROCEDURE Button1.Click This.Parent.Verify ENDPROC HIDDEN TryCount TryCount = 3 PROCEDURE Verify WITH This IF !((.Text1.Value == "Admin") .AND. (.Text2.Value) == "123456") .TryCount = .TryCount - 1 IF .TryCount > 0 MESSAGEBOX("您输入的账号或密码不对哦,请重新输入!") .SetAll("Value", "", "TextBox") .Text1.SetFocus ELSE .Release ENDIF ELSE .Release ENDIF ENDWITH ENDPROC ENDDEFINE
[此贴子已经被作者于2015-12-15 15:38编辑过]