| 网站首页 | 文章中心 | 电子书下载 | 矢量图库 | 视频教程 | 素材下载 | 程序代码下载 | JS代码 | 论坛 | 
常用软件类:
|杀毒安全 |联络聊天 |网络软件 |多媒体类 |系统工具 |图形图像 |系统工具 |应用软件 |行业软件
开发设计类:
|动画制作 |图像处理 |3D设计 |操作系统 |站长学院 |网络相关 |WEB设计 |数据库类 |程序开发
VFP6.0中实现文字的推拉显隐的动画效果
作者:佚名    文章来源:网络    点击数:    更新时间:2006-12-2
  本程序主要利用Visual Foxpro 6.0(以下简称VFP6.0)中的定时器控件和RGB()函数实现文字的颜色大小变化,从而实现了类似于推拉镜头,淡入淡出的动画效果。
函数RGB()的声明如下:
RGB(nRedValue,nGreenValue,nBlueValue)
其中nRedValue、nGreenValue、nBlueValue分别代表红色、绿色、蓝色成份的值,它们的大小变化范围都是0~255,该函数返回一个单一的色彩值,该返回值可作为其它控件的前景色(即ForeColor属性)或背景色(即BackColor属性)的值。
按照下面的步骤,将表单存盘后并运行,可以看到屏幕中央出现一个灰色背景的窗口,在窗口中央从背景色到绿色逐渐出现"学籍管理"四个汉字,并且由小逐渐变大;在窗口内任意位置按一下鼠标左键,可以看到汉字从绿色逐渐变到背景色,并且由大逐渐变小。大家可以对程序稍加改动,就可以实现文字其它的颜色和大小变化。该效果可用于制作软件的封面,或用于制作软件的介绍等。

下面介绍一下具体步骤:

1.启动VFP6.0,并新建一个空白的表单Form1。

2.将表单Form1的BackColor属性设置为192、192、192,即Form1的背景色设为灰色,其它属性如下:
AutoCenter = .T.
BorderStyle = 0
Caption = "欢迎使用本系统"
TitleBar = 1
ZoomBox = .F.
Name = "Form1"。

3.在表单Form1中加入一个标签“学籍管理”控件,并设置其属性如下:

AutoSize = .T. &&使得标签能根据将来字体的大小自动改变大小
FontSize = 8
Alignment = 2 &&文字居于标签中央
Caption = "学籍管理"
ColorSource = 4 &&Windows颜色(默认)
Name = "学籍管理"

4.在表单Form1中加入一个定时器控件beginTimer,并设置其属性如下:
Enabled = .T.
Interval = 25 &&时间间隔为25毫秒
Name = "beginTimer"

5.在表单Form1中再加入一个定时器控件stopTimer,并设置其属性如下:
Enabled = .F.
Interval = 25
Name = "stoptimer"

6.在表单Form1的Init过程中写入以下代码:
PUBLIC red,green,blue
red=192
green=192
blue=192

&&使标签“学籍管理”位于窗体Form1的中央

thisform.学籍管理.left=(thisform.width-thisform.学籍管理.width)/2
thisform.学籍管理.top=(thisform.height-thisform.学籍管理.height)/2

7.在表单Form1的Click过程中写入以下代码:
thisform.beginTimer.enabled=.f.
thisform.stopTimer.enabled=.t.


8.在标签“学籍管理”的Click过程中写入以下代码:
thisform.click &&在标签区域中按一下鼠标左键也执行窗体的Click过程。

9.在定时器控件beginTimer的timer过程中加入以下代码:
&&把字体颜色从背景色变为绿色
if red >0
red=red-1
endif
if blue >0
blue=blue-1
endif
if green < 255
green=green+1
else
thisform.beginTimer.enabled=.f. &&颜色达到要求之后,关闭beginTimer
endif

thisform.学籍管理.forecolor=rgb(red,green,blue)
if thisform.学籍管理.fontsize<70
&&字体逐渐变大,直到70为止
thisform.学籍管理.fontsize=thisform.学籍管理.fontsize+1
endif
thisform.refresh()

10.在定时器控件stopTimer的timer过程中加入以下代码:
&&再把字体颜色变为背景色
if red <> 192
red = red+1
endif
if blue <> 192
blue = blue+1
endif
if green <> 192
green=green-1
endif

&&变为背景色后,释放窗体Form1,用户软件系统中的其它程序可接着执行
if red=192 and green=192 and blue=192
thisform.stoptimer.enabled=.f.
thisform.release
endif
thisform.学籍管理.forecolor=rgb(red,green,blue)
if thisform.学籍管理.fontsize>8
thisform.学籍管理.fontsize=thisform.学籍管理.fontsize-1
endif
thisform.refresh()

本程序在Windows98中文版环境下,Visual FoxPro 6.0中文版中运行通过。

相关文章