运行时,怎么添加自定义属性?
[local]1[/local]
程序代码:&&main.prg
SET TALK OFF &&不显示命令结果
SET ECHO ON &&调试时跟踪
SET DATE TO ANSI &&yy.mm.dd的时间格式
SET ESCAPE OFF &&按ESC键不中断命令或程序运行
SET SAFETY OFF &&改写文件时不提示
SET EXACT ON &&精确字符串比较?
SET DELETED ON &&忽略做了删除标记的记录
SET CENTURY ON &&显示四位年份
CLOSE ALL
CLEAR ALL
&&_screen.Visible= .F. &&在config.fpw中用SCREEN=OFF代替了
PUBLIC currUser &&,userPerm 登录用户权限
myDrv=SYS(5)
myDir=SYS(2003)
myProgPath=myDrv+myDir
SET DEFAULT TO &myProgPath &&当前程序所在盘和所在路径
SET PROCEDURE TO "myFormClass","myControlClass" ADDITIVE &&ADDITIVE参数的作用有待测试
PUBLIC testLoginCount &&问题在这里
testLoginCount=3
mainForm=CREATEOBJECT("mForm")
WITH mainForm
.caption="水电工程处材料管理系统"
.autoCenter=.t.
.borderStyle=2
.icon="logo.ico"
.picture="主背景.bmp"
.height=550
.width=770
.maxButton=.f.
&&.show
ENDWITH
USE 授权用户
loginForm=CREATEOBJECT("logForm")
WITH loginForm
.caption="欢迎登录材料管理系统"
.autoCenter=.t.
.width=300
.height=200
.titleBar=0
.picture="登录背景.bmp"
.icon="logo.ico"
.controlBox=.f.
ENDWITH
loginForm.show
READ EVENTS
RETURN
DEFINE CLASS mForm as myForm
showWindow=2
ADD OBJECT cmdExit as exitBtn WITH caption="退出系统",top=504,left=108,height=25,width=60
PROCEDURE show
thisform.autoCenter=.t.
MESSAGEBOX(currUser,64,"aaa")
ENDPROC
PROCEDURE destroy
CLEAR EVENTS
ENDPROC
ENDDEFINE
DEFINE CLASS logForm as Form
showWindow=2
ADD OBJECT cmdLogin as loginBtn
ADD OBJECT cmdExit as logExitBtn WITH top=168,left=228,height=25,width=60,caption="退 出"
ADD OBJECT userNameCombo as logCbx
ADD OBJECT passwordCheck as logPass
ADD OBJECT lbl1 as Label WITH caption="水电工程处",;
alignment=2,;
backStyle=0,;
fontSize=16,;
foreColor=RGB(0,0,0),;
height=24,;
left=48,;
top=12,;
width=204
ADD OBJECT lbl2 as Label WITH caption="材料管理系统",;
alignment=2,;
backStyle=0,;
fontSize=18,;
foreColor=RGB(0,0,0),;
height=24,;
left=63,;
top=48,;
width=174
ADD OBJECT lbl3 as Label WITH caption="用户名:",;
backStyle=0,;
fontSize=12,;
foreColor=RGB(0,0,0),;
height=24,;
left=24,;
top=84,;
width=60
ADD OBJECT lbl4 as Label WITH caption="密 码:",;
backStyle=0,;
fontSize=12,;
foreColor=RGB(0,0,0),;
height=24,;
left=24,;
top=132,;
width=60
*!* PROCEDURE load
*!* LOCAL testLoginCount
*!* testLoginCount=3
*!* ENDPROC
ENDDEFINE
DEFINE CLASS logExitBtn as CommandButton
PROCEDURE click
CLOSE ALL
CLEAR events
IF _vfp.StartMode==4
QUIT
ENDIF
ENDPROC
ENDDEFINE
DEFINE CLASS loginBtn as CommandButton
top=168
left=144
height=25
width=60
caption="登 录"
PROCEDURE click
IF ALLTRIM(thisform.userNameCombo.Value)==ALLTRIM(授权用户.用户名) ;
AND ALLTRIM(thisform.passwordCheck.value)==ALLTRIM(授权用户.密码)
currUser=ALLTRIM(授权用户.用户名)
thisform.Release
mainForm.show
ELSE
testLoginCount=testLoginCount-1
IF testLoginCount=0
MESSAGEBOX("尝试登录过于频繁,程序将退出!如有问题,请联系程序管理员!",64,"非法登录警告!")
thisform.Release
ELSE
msgText="用户名或密码错误,你还有"+ALLTRIM(STR(testLoginCount))+"次机会!"
=MESSAGEBOX(msgText,64,"重试登录")
thisform.passwordCheck.Value=""
thisform.passwordCheck.SetFocus()
ENDIF
ENDIF
SELECT 授权用户
USE
ENDDEFINE
DEFINE CLASS logCbx as ComboBox
left=96
top=84
width=156
height=24
fontSize=12
rowSource="授权用户.用户名"
rowSourceType=6
ENDDEFINE
DEFINE CLASS logPass as TextBox
passwordChar="*"
left=96
height=24
top=132
width=156
fontSize=12
ENDDEFINE
程序代码:&&myControlClass.prg
DEFINE CLASS exitBtn as CommandButton
PROCEDURE click
RELEASE thisform
ENDPROC
ENDDEFINE
程序代码:&&myFormClass.prg
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
ENDDEFINE问题描述:testLoginCount,用于计数登录次数
用表单设计器设计表单的时候,我把它放在表单的init里,就可以了
可是,用代码设计的时候,写在表单类定义的init里,还不行,只能在程序最开始用public,这样做,用完之后,还不知道怎么销毁
想起之前的贴子,有几位老师说,可以用表单自定义属性代替全局变量,查了帮助,只看到设计器里怎么做,运行时用代码创建表单,就不知道怎么做了
请各位老师指教









