在Windows2000开始或关闭的时候,有一条颜色渐变的进度条,很是好看。我们可以用简单的方法制作类似的进度条。用图片移动的方法可以很方便的实现这一功能。
; f* G% ^, a- p2 p( e8 x% n# t9 J首先用PhotoShop制作图片。新建一张长为300宽为20的空白图片,选择“直线渐变工具”,在选择框里打开渐变编辑器,选择渐变色的时候须注意一点,必须选择最左边的颜色和最右边的颜色相同的渐变色,这里我们选择“橙、黄、橙渐变”;拉颜色的时候一定得从图片的最左边平衡(按住Shift)地拉到图片的最右边,否则两端的颜色不同会影响效果。制作满意后可存储副本为BMP或JPG格式。
( Q+ a% w2 _0 U8 E3 X# y2 {) ` t1 e2 w, P" v: O接着用C++ Builder写程序(所有对象名都取默认值)。在窗体上添加一个TPanel对象,把它的BorderStyle设为bsSingle。在Panel1里添加两个Timage对象,两者的Picture属性都指定为刚才我们制作的那张图片。添加一个TTimer对象,把它的Interval属性设为10。
9 \0 {! G* }$ S在Form1的Show事件里添加如下代码:
; z# m4 o! g3 i8 oImage1->Top =0;
Image1->Left=0;
$ `' `) ^5 r$ z' k* D* ?$ UImage1->Height=Panel1->Height;
, {$ V3 E0 z3 B4 P9 u! dImage1->Width =Panel1->Width;
( B7 _8 N/ L" t& c7 WImage1->Stretch =true;
) l0 Z# f; u- `2 g! B: JImage2->Top =0;
Image2->Left=-Panel1->Width;
! Y4 [1 M. i0 Z6 bImage2->Height=Panel1->Height;
Image2->Width =Panel1->Width;
$ T$ }2 {6 i! s* @6 aImage2->Stretch =true;
在Timer1的OnTimer事件里添加如下代码:
Image1->Left++;
4 a. J4 @; L6 L3 i- Nif( Image1->Left==Image1->Width)
6 [2 v; y4 V1 G$ i# z4 K; f1 u& rImage1->Left=-Image1->Width;
& r# ]3 n$ T5 l3 I8 C2 W. VImage2->Left++;
if( Image2->Left==Image1->Width)
" y/ z; P7 ~+ S( d, {6 f( K# OImage2->Left=-Image1->Width;
| 欢迎光临 数学建模社区-数学中国 (http://www.madio.net/) | Powered by Discuz! X2.5 |