jsp var 计算:VFP 主表单代码3

来源:百度文库 编辑:偶看新闻 时间:2024/04/30 03:19:04

主程序代码
do menu.mpr


*!* 第1部分
*!* 用于设置系统环境和指定错误处理程序
set talk off          &&关闭命令显示
set escape off        &&禁止运行的程序在按 esc 键后被中断
set exclusive off      &&允许网络上的任何用户共享和修改网络上打开的表
set help on            &&当按下 f1 键或在命令窗口中执行 help 命令时,显示帮助窗口
set help to medihelp.chm  &&指定帮助文件
set console on        &&将所有的结果输出到 visual foxpro 主窗口或活动的用户自定义窗口中
set date long          &&指定日期表达式的显示格式为长日期格式
set century on        &&设定日期中的年为4位数
set safety off        &&指定在改写已有文件时不显示对话框
set status bar on      &&打开vfp状态栏
set color to          &&设置颜色为默认状态
set hours to 24
set sysmenu off        &&关闭系统菜单
set notify off
set notify cursor off  &&不在状态栏中显示数据信息
set message to ""
clear                  &&清理主窗口显示
clear all              &&清除变量
on error do err.prg ;
    with error(), ;
    message(), ;
    message(1), ;
    program(), ;
    lineno(1)            &&指定当出现错误时执行的命令
   
*!* 第2部分
*!* 用于设置数据库的查找路径
if not file("datapath.txt")  &&如果没有找到datapath.txt文件,表示没有定义对数据库的查找路径
    do form frmsetdatapath  &&打开设置数据库路径表单
    read events
else
    cpath=filetostr("datapath.txt")  &&找到后则读取该文件
    set path to (cpath)              &&设置对数据库文件的查找路径
endif

*!* 第3部分
*!* 打开数据库和表
do opendb.prg

*!* 第4部分
*!* 执行操作员登录
do form frmlogin          &&打开登录表单
read events                &&开始事务处理
on shutdown do quitall.prg &&指定退出vfp时要执行的命令

*!* 第5部分
*!* 设置主窗口的大小、标题,并加入快捷工具栏和菜单
with _screen              &&设置vfp主表单为可见、最大化、标题、图标
    .visible=.t.
    .closable=.t.
    .controlbox=.t.
    .maxbutton=.t.
    .minbutton=.t.
    .movable=.t.
    .top=50
    .left=0
    .windowstate=2
    .caption="进销存管理系统[医药行业]"
    .icon='medisoft.ico'
endwith

public otoolbar,frmin,frmout,frmprint,frmsysset,frmbackup,frmstock,frmfinance &&定义表单名称全局变量
do menu.mpr      &&打开菜单

otoolbar=newobject("main_gj","libs.vcx")                &&建立工具栏对象
otoolbar.show()                                          &&显示对象
otoolbar.dock(0)                                          &&在vfp主窗口上方停放
set mark of bar 1 of popview to vartype(otoolbar)="o"    &&设置在显示工具栏时,在菜单项显示√标记

*!* 第6部分
*!* 在主窗口中加入背景图片和internet链接
ohandler=newobject("myhook")
bindevent(_screen,"resize",ohandler,"resize")  &&绑定主窗口的resize事件到ohandler对象的resize事件
_screen.addobject("image1","backimage")        &&在vfp主表单中加入图画
_screen.addobject("label1","labclass")
_screen.addobject("label2","label")

with _screen.label2
    .backstyle=0
    .caption="microsoft visual foxpro编程园地"
    .forecolor=rgb(0,0,255)
    .height=20
    .left=50
    .top=_screen.height-90
    .visible=.t.
    .width=300
endwith
read events

define class backimage as image
    name="image1"
    top=(_screen.height-159)/2-70
    left=(_screen.width-600)/2
    height=192
    width=487
    picture="background.jpg"
    backstyle=0
    stretch=2
    visible=.t.
Enddefine   

define class myhook as custom
    procedure resize  &&随窗口大小调整label1(internet链接)的位置和背景图片大小
        with _screen
            .label1.top=_screen.height-75
            .label2.top=_screen.height-90
            .image1.top=(_screen.height-159)/2-70
            .image1.left=(_screen.width-600)/2
        endwith 
    endproc   
enddefine

define class labclass as label
    backstyle=0
    caption="http://www.vfptop.com"
    forecolor=rgb(0,0,255)
    fontunderline=.t.
    Height=20
    left=100
    mouseicon="./images/hand-m.cur"
    mousepointer=99
    name="label1"
    tooltiptext="欢迎光临microsoft visual foxpro编程园地"
    visible=.t.
    Width=300
   
    procedure init
        this.left=50
        this.top=_screen.height-75
    endproc
   
    procedure click
        *!* 声明shellexecute函数
        declare integer shellexecute in "shell32.dll" ;
            integer hwnd, ;
            string lpverb, ;
            string lpfile, ;
            string lpparameters, ;
            string lpdirectory, ;
            long nshowcmd   
        *!* 设定要打开的internet站点
        lpfile="http://www.vfptop.com/"
        *!* 以浏览器窗口最大化方式打开internet站点
        =shellexecute(0,"open",lpfile ,"","",3)
    endproc               
   
    procedure mouseenter
        lparameters nbutton, nshift, nxcoord, nycoord
        this.forecolor=rgb(255,0,0)  &&当鼠标移动时字体颜色成为红色
    endproc
   
    procedure mouseleave
        lparameters nbutton, nshift, nxcoord, nycoord
        this.forecolor=rgb(0,0,255)  &&当鼠标移动时字体颜色成为蓝色
    endproc
enddefine       

·                                       

 

主程序代码
do menu.mpr


*!* 第1部分
*!* 用于设置系统环境和指定错误处理程序
set talk off          &&关闭命令显示
set escape off        &&禁止运行的程序在按 esc 键后被中断
set exclusive off      &&允许网络上的任何用户共享和修改网络上打开的表
set help on            &&当按下 f1 键或在命令窗口中执行 help 命令时,显示帮助窗口
set help to medihelp.chm  &&指定帮助文件
set console on        &&将所有的结果输出到 visual foxpro 主窗口或活动的用户自定义窗口中
set date long          &&指定日期表达式的显示格式为长日期格式
set century on        &&设定日期中的年为4位数
set safety off        &&指定在改写已有文件时不显示对话框
set status bar on      &&打开vfp状态栏
set color to          &&设置颜色为默认状态
set hours to 24
set sysmenu off        &&关闭系统菜单
set notify off
set notify cursor off  &&不在状态栏中显示数据信息
set message to ""
clear                  &&清理主窗口显示
clear all              &&清除变量
on error do err.prg ;
    with error(), ;
    message(), ;
    message(1), ;
    program(), ;
    lineno(1)            &&指定当出现错误时执行的命令
   
*!* 第2部分
*!* 用于设置数据库的查找路径
if not file("datapath.txt")  &&如果没有找到datapath.txt文件,表示没有定义对数据库的查找路径
    do form frmsetdatapath  &&打开设置数据库路径表单
    read events
else
    cpath=filetostr("datapath.txt")  &&找到后则读取该文件
    set path to (cpath)              &&设置对数据库文件的查找路径
endif

*!* 第3部分
*!* 打开数据库和表
do opendb.prg

*!* 第4部分
*!* 执行操作员登录
do form frmlogin          &&打开登录表单
read events                &&开始事务处理
on shutdown do quitall.prg &&指定退出vfp时要执行的命令

*!* 第5部分
*!* 设置主窗口的大小、标题,并加入快捷工具栏和菜单
with _screen              &&设置vfp主表单为可见、最大化、标题、图标
    .visible=.t.
    .closable=.t.
    .controlbox=.t.
    .maxbutton=.t.
    .minbutton=.t.
    .movable=.t.
    .top=50
    .left=0
    .windowstate=2
    .caption="进销存管理系统[医药行业]"
    .icon='medisoft.ico'
endwith

public otoolbar,frmin,frmout,frmprint,frmsysset,frmbackup,frmstock,frmfinance &&定义表单名称全局变量
do menu.mpr      &&打开菜单

otoolbar=newobject("main_gj","libs.vcx")                &&建立工具栏对象
otoolbar.show()                                          &&显示对象
otoolbar.dock(0)                                          &&在vfp主窗口上方停放
set mark of bar 1 of popview to vartype(otoolbar)="o"    &&设置在显示工具栏时,在菜单项显示√标记

*!* 第6部分
*!* 在主窗口中加入背景图片和internet链接
ohandler=newobject("myhook")
bindevent(_screen,"resize",ohandler,"resize")  &&绑定主窗口的resize事件到ohandler对象的resize事件
_screen.addobject("image1","backimage")        &&在vfp主表单中加入图画
_screen.addobject("label1","labclass")
_screen.addobject("label2","label")

with _screen.label2
    .backstyle=0
    .caption="microsoft visual foxpro编程园地"
    .forecolor=rgb(0,0,255)
    .height=20
    .left=50
    .top=_screen.height-90
    .visible=.t.
    .width=300
endwith
read events

define class backimage as image
    name="image1"
    top=(_screen.height-159)/2-70
    left=(_screen.width-600)/2
    height=192
    width=487
    picture="background.jpg"
    backstyle=0
    stretch=2
    visible=.t.
Enddefine   

define class myhook as custom
    procedure resize  &&随窗口大小调整label1(internet链接)的位置和背景图片大小
        with _screen
            .label1.top=_screen.height-75
            .label2.top=_screen.height-90
            .image1.top=(_screen.height-159)/2-70
            .image1.left=(_screen.width-600)/2
        endwith 
    endproc   
enddefine

define class labclass as label
    backstyle=0
    caption="http://www.vfptop.com"
    forecolor=rgb(0,0,255)
    fontunderline=.t.
    Height=20
    left=100
    mouseicon="./images/hand-m.cur"
    mousepointer=99
    name="label1"
    tooltiptext="欢迎光临microsoft visual foxpro编程园地"
    visible=.t.
    Width=300
   
    procedure init
        this.left=50
        this.top=_screen.height-75
    endproc
   
    procedure click
        *!* 声明shellexecute函数
        declare integer shellexecute in "shell32.dll" ;
            integer hwnd, ;
            string lpverb, ;
            string lpfile, ;
            string lpparameters, ;
            string lpdirectory, ;
            long nshowcmd   
        *!* 设定要打开的internet站点
        lpfile="http://www.vfptop.com/"
        *!* 以浏览器窗口最大化方式打开internet站点
        =shellexecute(0,"open",lpfile ,"","",3)
    endproc               
   
    procedure mouseenter
        lparameters nbutton, nshift, nxcoord, nycoord
        this.forecolor=rgb(255,0,0)  &&当鼠标移动时字体颜色成为红色
    endproc
   
    procedure mouseleave
        lparameters nbutton, nshift, nxcoord, nycoord
        this.forecolor=rgb(0,0,255)  &&当鼠标移动时字体颜色成为蓝色
    endproc
enddefine       

·