主题:[转帖]张洪举老师的主程序编制方法(新人要看)
**设置运行环境
SET TALK OFF &&关闭命令显示
SET ESCAPE OFF &&禁止运行的程序在按 Esc 键后被中断
SET EXCLUSIVE OFF &&允许网络上的任何用户共享和修改网络上打开的表
SET HELP ON &&当按下 F1 键或在命令窗口中执行 HELP 命令时,显示帮助窗口
SET HELP TO Comp_Help.CHM &&指定帮助文件
SET CONSOLE ON &&将所有的结果输出到Visual FoxPro主窗口或活动的用户自定义窗口中
SET DATE ANSI &&指定日期表达式的显示格式为yy.mm.dd
SET CENTURY ON &&设定日期中的年为4位数
SET SAFETY OFF &&指定在改写已有文件时不显示对话框
SET STATUS BAR ON &&打开Visual FoxPro状态栏
SET COLOR TO &&设置颜色为默认状态
SET SYSMENU OFF &&关闭系统菜单
SET MESSAGE TO "" &&指定在Visual FoxPro状态栏中显示的内容
CLEAR &&清除主窗口
CLEAR ALL &&清除变量
ON ERROR DO Err.PRG ;
WITH ERROR(), ;
MESSAGE(), ;
MESSAGE(1), ;
PROGRAM(), ;
LINENO(1) &&指定当出现错误时执行的命令
ON SHUTDOWN DO QuitAll.PRG &&指定退出Visual FoxPro时要执行的命令
****开始进行程序的事务处理操作
DO FORM Begin &&运行版权画面表单Begin
READ EVENTS &&开始事务处理,第1个READ EVENTS
DO FORM Login &&打开登录表单
READ EVENTS &&开始事务处理,第2个READ EVENTS
WITH _Screen &&设置Visual FoxPro主表单为可见、最大化、标题、图标
.Visible=.T.
.Closable=.T.
.ControlBox=.T.
.MaxButton=.T.
.MinButton=.T.
.Movable=.T.
.Top=0
.Left=0
.WindowState=2
.Caption="专家库管理系统--操作员"+Nowuser
.Icon='MainFrm.ico'
ENDWITH
PUBLIC tz_gj,ryzl,xtzd,dy,bfhf,about &&定义表单名称全局变量
*开始定义主菜单,注意:在Visual FoxPro 7.0中支持在菜单项中加入图标
SET SYSMENU TO
SET SYSMENU AUTOMATIC
DEFINE PAD _0lw07no93 OF _MSYSMENU PROMPT "文件(\<F)" COLOR SCHEME 3 ;
KEY ALT+F, ""
DEFINE PAD _msm_edit OF _MSYSMENU PROMPT "编辑(\<E)" COLOR SCHEME 3 ;
KEY ALT+E, ""
DEFINE PAD _0lw07no95 OF _MSYSMENU PROMPT "查看(\<V)" COLOR SCHEME 3 ;
KEY ALT+V, ""
DEFINE PAD _0lw07no96 OF _MSYSMENU PROMPT "帮助(\<H)" COLOR SCHEME 3 ;
KEY ALT+H, ""
ON PAD _0lw07no93 OF _MSYSMENU ACTIVATE POPUP 文件f
ON PAD _msm_edit OF _MSYSMENU ACTIVATE POPUP _medit
ON PAD _0lw07no95 OF _MSYSMENU ACTIVATE POPUP 查看v
ON PAD _0lw07no96 OF _MSYSMENU ACTIVATE POPUP 帮助h
DEFINE POPUP 文件f MARGIN RELATIVE SHADOW COLOR SCHEME 4
DEFINE BAR 1 OF 文件f PROMPT "人员资料(\<M)" ;
KEY CTRL+M, "Ctrl+M" ;
PICTURE "zhj163.bmp" ;
MESSAGE "人员基本资料录入管理"
DEFINE BAR 2 OF 文件f PROMPT "系统字典(\<D)..." ;
PICTURE "zhj53.bmp" ;
MESSAGE "各种系统字典库管理"
DEFINE BAR 3 OF 文件f PROMPT "打印(\<P)..." ;
KEY CTRL+P, "Ctrl+P" ;
PICTURE "print3.bmp" ;
MESSAGE "打印各种人员资料报表"
DEFINE BAR 4 OF 文件f PROMPT "数据备份/恢复(\<R) " ;
PICTURE "disk3.bmp" ;
MESSAGE "备份/恢复人员数据资料"
DEFINE BAR 5 OF 文件f PROMPT "\-"
DEFINE BAR 6 OF 文件f PROMPT "关闭(\<E)" ;
KEY CTRL+E, "Ctrl+E" ;
PICTURE "zhj24.ico" ;
MESSAGE "关闭系统"
ON SELECTION BAR 1 OF 文件f do form ryzl name ryzl
ON SELECTION BAR 2 OF 文件f do form xtzd name xtzd
ON SELECTION BAR 3 OF 文件f do form dy name dy
ON SELECTION BAR 4 OF 文件f do form bfhf name bfhf
ON SELECTION BAR 6 OF 文件f quit
DEFINE POPUP _medit MARGIN RELATIVE SHADOW COLOR SCHEME 4
DEFINE BAR _med_undo OF _medit PROMPT "撤消(\<U) ";
KEY CTRL+Z, "Ctrl+Z" ;
PICTURE "undo.bmp" ;
MESSAGE "撤消上一次命令或操作"
DEFINE BAR _med_redo OF _medit PROMPT "重作(\<D) ";
KEY CTRL+Z, "Ctrl+R" ;
PICTURE "redo.bmp" ;
MESSAGE "重复上一次命令或操作"
DEFINE BAR _med_sp100 OF _medit PROMPT "\-"
DEFINE BAR _med_cut OF _medit PROMPT "剪切(\<T) " ;
KEY CTRL+X, "Ctrl+X" ;
PICTURE "cut.bmp" ;
MESSAGE "移去选定内容并将其放入剪贴板"
DEFINE BAR _med_copy OF _medit PROMPT "复制(\<C) " ;
KEY CTRL+C, "Ctrl+C" ;
PICTURE "copy.bmp" ;
MESSAGE "将选定内容复制到剪贴板上"
DEFINE BAR _med_paste OF _medit PROMPT "粘贴(\<P) " ;
KEY CTRL+V, "Ctrl+V" ;
PICTURE "paste.bmp" ;
MESSAGE "粘贴剪贴板上的内容"
DEFINE BAR _med_clear OF _medit PROMPT "清除(\<A)" ;
MESSAGE "移去选定内容,并且不将其放到剪贴板上"
DEFINE BAR _med_sp200 OF _medit PROMPT "\-"
DEFINE BAR _med_slcta OF _medit PROMPT "全部选定(\<L) ";
KEY CTRL+A, "Ctrl+A" ;
MESSAGE "选定当前窗口中的所有文本或数据项"
DEFINE POPUP 查看v MARGIN RELATIVE SHADOW COLOR SCHEME 4
DEFINE BAR 1 OF 查看v PROMPT "工具栏(\<T)... "
ON SELECTION BAR 1 OF 查看v do gjxz
DEFINE POPUP 帮助h MARGIN RELATIVE SHADOW COLOR SCHEME 4
DEFINE BAR 1 OF 帮助h PROMPT "帮助(\<H) " ;
KEY F1, "F1" ;
PICTURE "help3.bmp" ;
MESSAGE "系统帮助"
DEFINE BAR 2 OF 帮助h PROMPT "关于(\<A)" ;
PICTURE "ABOUT2.bmp" ;
MESSAGE "系统版本"
ON SELECTION BAR 1 OF 帮助h do help.prg
ON SELECTION BAR 2 OF 帮助h do form about
ACTIVATE MENU _mSysMenu NOWAIT &&NOWAIT参数表示激活表单后继续执行程序
DO FORM Tz_gj NAME Tz_gj &&打开工具栏
**下面检测工具栏窗口是否已经打开,如果打开在菜单项的旁边加上√
SET MARK OF BAR 1 OF 查看v TO WEXIST("tz_gj")
_SCREEN.AddObject("Image1","BackImage") &&在Visual FoxPro主表单中加入图画
READ EVENTS &&开始事务处理,第3个READ EVENTS
DEFINE CLASS BackImage AS Image
Top=-30
Left=0
Picture="Back.jpg"
BackStyle=0
Visible=.T.
ENDDEFINE
本文来自CSDN博客,转载请标明出处:
这是张老师的博客:
[url=http://blog.csdn.net/zhanghongju/archive/2009/07/14/4348471.aspx]点击进入博客[/url]
SET TALK OFF &&关闭命令显示
SET ESCAPE OFF &&禁止运行的程序在按 Esc 键后被中断
SET EXCLUSIVE OFF &&允许网络上的任何用户共享和修改网络上打开的表
SET HELP ON &&当按下 F1 键或在命令窗口中执行 HELP 命令时,显示帮助窗口
SET HELP TO Comp_Help.CHM &&指定帮助文件
SET CONSOLE ON &&将所有的结果输出到Visual FoxPro主窗口或活动的用户自定义窗口中
SET DATE ANSI &&指定日期表达式的显示格式为yy.mm.dd
SET CENTURY ON &&设定日期中的年为4位数
SET SAFETY OFF &&指定在改写已有文件时不显示对话框
SET STATUS BAR ON &&打开Visual FoxPro状态栏
SET COLOR TO &&设置颜色为默认状态
SET SYSMENU OFF &&关闭系统菜单
SET MESSAGE TO "" &&指定在Visual FoxPro状态栏中显示的内容
CLEAR &&清除主窗口
CLEAR ALL &&清除变量
ON ERROR DO Err.PRG ;
WITH ERROR(), ;
MESSAGE(), ;
MESSAGE(1), ;
PROGRAM(), ;
LINENO(1) &&指定当出现错误时执行的命令
ON SHUTDOWN DO QuitAll.PRG &&指定退出Visual FoxPro时要执行的命令
****开始进行程序的事务处理操作
DO FORM Begin &&运行版权画面表单Begin
READ EVENTS &&开始事务处理,第1个READ EVENTS
DO FORM Login &&打开登录表单
READ EVENTS &&开始事务处理,第2个READ EVENTS
WITH _Screen &&设置Visual FoxPro主表单为可见、最大化、标题、图标
.Visible=.T.
.Closable=.T.
.ControlBox=.T.
.MaxButton=.T.
.MinButton=.T.
.Movable=.T.
.Top=0
.Left=0
.WindowState=2
.Caption="专家库管理系统--操作员"+Nowuser
.Icon='MainFrm.ico'
ENDWITH
PUBLIC tz_gj,ryzl,xtzd,dy,bfhf,about &&定义表单名称全局变量
*开始定义主菜单,注意:在Visual FoxPro 7.0中支持在菜单项中加入图标
SET SYSMENU TO
SET SYSMENU AUTOMATIC
DEFINE PAD _0lw07no93 OF _MSYSMENU PROMPT "文件(\<F)" COLOR SCHEME 3 ;
KEY ALT+F, ""
DEFINE PAD _msm_edit OF _MSYSMENU PROMPT "编辑(\<E)" COLOR SCHEME 3 ;
KEY ALT+E, ""
DEFINE PAD _0lw07no95 OF _MSYSMENU PROMPT "查看(\<V)" COLOR SCHEME 3 ;
KEY ALT+V, ""
DEFINE PAD _0lw07no96 OF _MSYSMENU PROMPT "帮助(\<H)" COLOR SCHEME 3 ;
KEY ALT+H, ""
ON PAD _0lw07no93 OF _MSYSMENU ACTIVATE POPUP 文件f
ON PAD _msm_edit OF _MSYSMENU ACTIVATE POPUP _medit
ON PAD _0lw07no95 OF _MSYSMENU ACTIVATE POPUP 查看v
ON PAD _0lw07no96 OF _MSYSMENU ACTIVATE POPUP 帮助h
DEFINE POPUP 文件f MARGIN RELATIVE SHADOW COLOR SCHEME 4
DEFINE BAR 1 OF 文件f PROMPT "人员资料(\<M)" ;
KEY CTRL+M, "Ctrl+M" ;
PICTURE "zhj163.bmp" ;
MESSAGE "人员基本资料录入管理"
DEFINE BAR 2 OF 文件f PROMPT "系统字典(\<D)..." ;
PICTURE "zhj53.bmp" ;
MESSAGE "各种系统字典库管理"
DEFINE BAR 3 OF 文件f PROMPT "打印(\<P)..." ;
KEY CTRL+P, "Ctrl+P" ;
PICTURE "print3.bmp" ;
MESSAGE "打印各种人员资料报表"
DEFINE BAR 4 OF 文件f PROMPT "数据备份/恢复(\<R) " ;
PICTURE "disk3.bmp" ;
MESSAGE "备份/恢复人员数据资料"
DEFINE BAR 5 OF 文件f PROMPT "\-"
DEFINE BAR 6 OF 文件f PROMPT "关闭(\<E)" ;
KEY CTRL+E, "Ctrl+E" ;
PICTURE "zhj24.ico" ;
MESSAGE "关闭系统"
ON SELECTION BAR 1 OF 文件f do form ryzl name ryzl
ON SELECTION BAR 2 OF 文件f do form xtzd name xtzd
ON SELECTION BAR 3 OF 文件f do form dy name dy
ON SELECTION BAR 4 OF 文件f do form bfhf name bfhf
ON SELECTION BAR 6 OF 文件f quit
DEFINE POPUP _medit MARGIN RELATIVE SHADOW COLOR SCHEME 4
DEFINE BAR _med_undo OF _medit PROMPT "撤消(\<U) ";
KEY CTRL+Z, "Ctrl+Z" ;
PICTURE "undo.bmp" ;
MESSAGE "撤消上一次命令或操作"
DEFINE BAR _med_redo OF _medit PROMPT "重作(\<D) ";
KEY CTRL+Z, "Ctrl+R" ;
PICTURE "redo.bmp" ;
MESSAGE "重复上一次命令或操作"
DEFINE BAR _med_sp100 OF _medit PROMPT "\-"
DEFINE BAR _med_cut OF _medit PROMPT "剪切(\<T) " ;
KEY CTRL+X, "Ctrl+X" ;
PICTURE "cut.bmp" ;
MESSAGE "移去选定内容并将其放入剪贴板"
DEFINE BAR _med_copy OF _medit PROMPT "复制(\<C) " ;
KEY CTRL+C, "Ctrl+C" ;
PICTURE "copy.bmp" ;
MESSAGE "将选定内容复制到剪贴板上"
DEFINE BAR _med_paste OF _medit PROMPT "粘贴(\<P) " ;
KEY CTRL+V, "Ctrl+V" ;
PICTURE "paste.bmp" ;
MESSAGE "粘贴剪贴板上的内容"
DEFINE BAR _med_clear OF _medit PROMPT "清除(\<A)" ;
MESSAGE "移去选定内容,并且不将其放到剪贴板上"
DEFINE BAR _med_sp200 OF _medit PROMPT "\-"
DEFINE BAR _med_slcta OF _medit PROMPT "全部选定(\<L) ";
KEY CTRL+A, "Ctrl+A" ;
MESSAGE "选定当前窗口中的所有文本或数据项"
DEFINE POPUP 查看v MARGIN RELATIVE SHADOW COLOR SCHEME 4
DEFINE BAR 1 OF 查看v PROMPT "工具栏(\<T)... "
ON SELECTION BAR 1 OF 查看v do gjxz
DEFINE POPUP 帮助h MARGIN RELATIVE SHADOW COLOR SCHEME 4
DEFINE BAR 1 OF 帮助h PROMPT "帮助(\<H) " ;
KEY F1, "F1" ;
PICTURE "help3.bmp" ;
MESSAGE "系统帮助"
DEFINE BAR 2 OF 帮助h PROMPT "关于(\<A)" ;
PICTURE "ABOUT2.bmp" ;
MESSAGE "系统版本"
ON SELECTION BAR 1 OF 帮助h do help.prg
ON SELECTION BAR 2 OF 帮助h do form about
ACTIVATE MENU _mSysMenu NOWAIT &&NOWAIT参数表示激活表单后继续执行程序
DO FORM Tz_gj NAME Tz_gj &&打开工具栏
**下面检测工具栏窗口是否已经打开,如果打开在菜单项的旁边加上√
SET MARK OF BAR 1 OF 查看v TO WEXIST("tz_gj")
_SCREEN.AddObject("Image1","BackImage") &&在Visual FoxPro主表单中加入图画
READ EVENTS &&开始事务处理,第3个READ EVENTS
DEFINE CLASS BackImage AS Image
Top=-30
Left=0
Picture="Back.jpg"
BackStyle=0
Visible=.T.
ENDDEFINE
本文来自CSDN博客,转载请标明出处:
这是张老师的博客:
[url=http://blog.csdn.net/zhanghongju/archive/2009/07/14/4348471.aspx]点击进入博客[/url]