分享
 
 
 

用BCB实现窗体动画特效

王朝other·作者佚名  2006-02-01
窄屏简体版  字體: |||超大  

下面是头文件:

//---------------------------------------------------------------------------

#ifndef Unit1H

#define Unit1H

//---------------------------------------------------------------------------

#include <Classes.hpp>

#include <Controls.hpp>

#include <StdCtrls.hpp>

#include <Forms.hpp>

#include <Buttons.hpp>

#include <ExtCtrls.hpp>

#include <Graphics.hpp>

//---------------------------------------------------------------------------

class TForm1 : public TForm

{

__published: // IDE-managed Components

TImage *Image1;

TBitBtn *BitBtn1;

TBitBtn *BitBtn2;

TBitBtn *BitBtn3;

TBitBtn *BitBtn4;

TBitBtn *BitBtn5;

TBitBtn *BitBtn6;

TBitBtn *BitBtn7;

TBitBtn *BitBtn8;

TBitBtn *BitBtn9;

TBitBtn *BitBtn10;

TBitBtn *BitBtn11;

TBitBtn *BitBtn12;

TBitBtn *BitBtn13;

TBitBtn *BitBtn14;

TBitBtn *BitBtn15;

TBitBtn *BitBtn16;

TBitBtn *BitBtn17;

TBitBtn *BitBtn18;

TStaticText *StaticText1;

TBitBtn *BitBtn19;

TBitBtn *BitBtn20;

TBitBtn *BitBtn21;

void __fastcall FormCreate(TObject *Sender);

void __fastcall BitBtn1Click(TObject *Sender);

void __fastcall BitBtn2Click(TObject *Sender);

void __fastcall BitBtn3Click(TObject *Sender);

void __fastcall BitBtn4Click(TObject *Sender);

void __fastcall BitBtn5Click(TObject *Sender);

void __fastcall BitBtn6Click(TObject *Sender);

void __fastcall BitBtn7Click(TObject *Sender);

void __fastcall BitBtn8Click(TObject *Sender);

void __fastcall BitBtn9Click(TObject *Sender);

void __fastcall BitBtn10Click(TObject *Sender);

void __fastcall BitBtn11Click(TObject *Sender);

void __fastcall BitBtn12Click(TObject *Sender);

void __fastcall BitBtn13Click(TObject *Sender);

void __fastcall BitBtn14Click(TObject *Sender);

void __fastcall BitBtn15Click(TObject *Sender);

void __fastcall BitBtn16Click(TObject *Sender);

void __fastcall BitBtn17Click(TObject *Sender);

void __fastcall BitBtn18Click(TObject *Sender);

void __fastcall BitBtn19Click(TObject *Sender);

void __fastcall BitBtn20Click(TObject *Sender);

void __fastcall BitBtn21Click(TObject *Sender);

private: // User declarations

BITMAP bmp;

HRGN MyRgn;

Graphics::TBitmap *Bitmap1;

int i,j;

int WidthHalf;

int HeightHalf;

TRect Dest1,Source1,Dest2,Source2;

public: // User declarations

__fastcall TForm1(TComponent* Owner);

};

//---------------------------------------------------------------------------

extern PACKAGE TForm1 *Form1;

//---------------------------------------------------------------------------

#endif

///////////////////////////////////////////////////////////////////////

下面是CPP文件

#include <vcl.h>

#pragma hdrstop

#include "Unit1.h"

#include "math.h"

//---------------------------------------------------------------------------

#pragma package(smart_init)

#pragma resource "*.dfm"

TForm1 *Form1;

//---------------------------------------------------------------------------

__fastcall TForm1::TForm1(TComponent* Owner)

: TForm(Owner)

{

}

//---------------------------------------------------------------------------

void __fastcall TForm1::FormCreate(TObject *Sender)

{

Form1->BorderStyle = bsNone;

Form1->Left = 0;

Form1->Top = 0;

Form1->Width = Screen->Width;

Form1->Height = Screen->Height;//窗体全屏显示

Bitmap1 = new Graphics::TBitmap();//定义一个图象句柄//

Bitmap1->LoadFromFile("test.bmp");//设定所要特效显示的图象为factory.bmp//

if(GetDeviceCaps(Form1->Canvas->Handle,BITSPIXEL)==8){//取得显示窗口的颜色属性

GetObject(Bitmap1->Handle,sizeof(BITMAP),(LPSTR)&bmp);

if (bmp.bmBitsPixel==8){//如果特效显示的图象颜色属性为256色//

SelectPalette(Form1->Canvas->Handle,Bitmap1->Palette,FALSE);//从特效显示的颜色画板中提取配色方案//

RealizePalette(Form1->Canvas->Handle); //在显示窗口中设置配色方案//

}

Bitmap1->HandleType=bmDDB;

}

}

//---------------------------------------------------------------------------

void __fastcall TForm1::BitBtn1Click(TObject *Sender)

{//图象从中间向左右拉开!

Form1->Refresh();

WidthHalf=Bitmap1->Width/2+Bitmap1->Width%2;

for(i=0;i<=WidthHalf; i++){

Dest1=Rect(WidthHalf-i,0,WidthHalf+i,Bitmap1->Height);

Source1=Rect(WidthHalf-i,0,WidthHalf+i,Bitmap1->Height);

Form1->Canvas->CopyRect(Dest1,Bitmap1->Canvas,Source1);

for(j=0;j<10000;j++);//图像的延迟显示//

}

}

//---------------------------------------------------------------------------

void __fastcall TForm1::BitBtn2Click(TObject *Sender)

{//图象由左右拉向中间!

Form1->Refresh();

WidthHalf=Bitmap1->Width/2+Bitmap1->Width%2;

Form1->Refresh();

for(i=0;i<=WidthHalf;i++){

Source1=Dest1=Rect(0,0,i,Bitmap1->Height);

Source2=Dest2=Rect(Bitmap1->Width-i,0,Bitmap1->Width,Bitmap1->Height);

Form1->Canvas->CopyRect(Dest1,Bitmap1->Canvas,Source1);

Form1->Canvas->CopyRect(Dest2,Bitmap1->Canvas,Source2);

for(j=0;j<10000;j++);

}

}

//---------------------------------------------------------------------------

void __fastcall TForm1::BitBtn3Click(TObject *Sender)

{//图象从中间分到两边

Form1->Refresh();

HeightHalf=Bitmap1->Height/2+Bitmap1->Height%2;

for(i=0;i<=HeightHalf;i++){

Dest1=Rect(0,HeightHalf-i,Bitmap1->Width,HeightHalf);

Source1=Rect(0,0,Bitmap1->Width,i);

Dest2=Rect(0,HeightHalf,Bitmap1->Width,HeightHalf+i);

Source2=Rect(0,Bitmap1->Height-i,Bitmap1->Width,Bitmap1->Height);

Form1->Canvas->CopyRect(Dest1,Bitmap1->Canvas,Source1);

Form1->Canvas->CopyRect(Dest2,Bitmap1->Canvas,Source2);

for(j=0;j<10000;j++);

}

}

//---------------------------------------------------------------------------

void __fastcall TForm1::BitBtn4Click(TObject *Sender)

{//图象从两边靠拢

Form1->Refresh();

HeightHalf=Bitmap1->Height/2+Bitmap1->Height%2;

for(i=0;i<=HeightHalf;i++){

Dest1=Rect(0,0,Bitmap1->Width,i);

Source1=Rect(0,HeightHalf-i,Bitmap1->Width,HeightHalf);

Dest2=Rect(0,Bitmap1->Height-i,

Bitmap1->Width,Bitmap1->Height);

Source2=Rect(0,HeightHalf,Bitmap1->Width,HeightHalf+i);

Form1->Canvas->CopyRect(Dest1,Bitmap1->Canvas,Source1);

Form1->Canvas->CopyRect(Dest2,Bitmap1->Canvas,Source2);

for(j=0;j<10000;j++);

}

}

//---------------------------------------------------------------------------

void __fastcall TForm1::BitBtn5Click(TObject *Sender)

{//图象从左拉向右

Form1->Refresh();

for(i=Bitmap1->Width;i>=0;i--){

Dest1=Rect(0,0,Bitmap1->Width-i,Bitmap1->Height);

Source1=Rect(i,0,Bitmap1->Width,Bitmap1->Height);

Form1->Canvas->CopyRect(Dest1,Bitmap1->Canvas,Source1);

for(j=0;j<10000;j++);

}

}

//---------------------------------------------------------------------------

void __fastcall TForm1::BitBtn6Click(TObject *Sender)

{//图象从右拉到左

Form1->Refresh();

for(i=0;i<=Bitmap1->Width;i++){

Dest1=Rect(Bitmap1->Width-i,0,Bitmap1->Width,Bitmap1->Height);

Source1=Rect(0,0,i,Bitmap1->Height);

Form1->Canvas->CopyRect(Dest1,Bitmap1->Canvas,Source1);

for(j=0;j<10000;j++);

}

}

//---------------------------------------------------------------------------

void __fastcall TForm1::BitBtn7Click(TObject *Sender)

{//图象从上拉到下

Form1->Refresh();

for(i=0;i<=Bitmap1->Height;i++){

Dest1=Rect(0,0,Bitmap1->Width,i);

Source1=Rect(0,Bitmap1->Height-i,Bitmap1->Width,Bitmap1->Height);

Form1->Canvas->CopyRect(Dest1,Bitmap1->Canvas,Source1);

for(j=0;j<1;j++);

}

}

//---------------------------------------------------------------------------

void __fastcall TForm1::BitBtn8Click(TObject *Sender)

{//图象从下拉到上

Form1->Refresh();

for(i=0;i<=Bitmap1->Height;i++){

Dest1 =Rect(0,Bitmap1->Height-i,Bitmap1->Width,

Bitmap1->Height);

Source1 =Rect(0,0,Bitmap1->Width,i);

Form1->Canvas->CopyRect(Dest1,Bitmap1->Canvas,Source1);

for(j=0;j<10000;j++);

}

}

//---------------------------------------------------------------------------

void __fastcall TForm1::BitBtn9Click(TObject *Sender)

{//图象从左现到右

Form1->Refresh();

for(i=0;i<=Bitmap1->Width;i++){

Dest1 =Rect(0,0,i,Bitmap1->Height);

Source1 =Rect(0,0,i,Bitmap1->Height);

Form1->Canvas->CopyRect(Dest1,Bitmap1->Canvas,Source1);

for(j=0;j<10000;j++);

}

}

//---------------------------------------------------------------------------

void __fastcall TForm1::BitBtn10Click(TObject *Sender)

{//图象从右现到左

Form1->Refresh();

for(i=Bitmap1->Width;i>=0;i--){

Dest1 =Rect(i+0,0,0+Bitmap1->Width,0+Bitmap1->Height);

Source1 =Rect(i,0,Bitmap1->Width,Bitmap1->Height);

Form1->Canvas->CopyRect(Dest1,Bitmap1->Canvas,Source1);

for(j=0;j<10000;j++);

}

}

//---------------------------------------------------------------------------

void __fastcall TForm1::BitBtn11Click(TObject *Sender)

{//图象从上现到下

Form1->Refresh();

for(i=0;i<=Bitmap1->Height;i++){

Dest1 =Rect(0,0,Bitmap1->Width+0,i+0);

Source1 =Rect(0,0,Bitmap1->Width,i);

Form1->Canvas->CopyRect(Dest1,Bitmap1->Canvas,Source1);

for(j=0;j<10000;j++);

}

}

//---------------------------------------------------------------------------

void __fastcall TForm1::BitBtn12Click(TObject *Sender)

{//图象从下现到上

Form1->Refresh();

for(i=Bitmap1->Height;i>=0;i--){

Dest1=Rect(0,i+0,Bitmap1->Width+0,Bitmap1->Height+0);

Source1=Rect(0,i,Bitmap1->Width,Bitmap1->Height);

Form1->Canvas->CopyRect(Dest1,Bitmap1->Canvas,Source1);

for(j=0;j<10000;j++);

}

}

//---------------------------------------------------------------------------

void __fastcall TForm1::BitBtn13Click(TObject *Sender)

{//金属熔铸A

Form1->Refresh();

for(i=Bitmap1->Height;i>=0;i--){

Source1 =Rect(0,i,Bitmap1->Width,i+1);

for(int j1=0;j1<=i;j1++){

Dest1 =Rect(0 ,j1,Bitmap1->Width+0,j1+1);

Form1->Canvas->CopyRect(Dest1,Bitmap1->Canvas,Source1);

for(j=0;j<10000;j++);

}

}

}

//---------------------------------------------------------------------------

void __fastcall TForm1::BitBtn14Click(TObject *Sender)

{//逆金属熔铸

Form1->Refresh();

for(i=0;i<=Bitmap1->Height;i++){

Source1 =Rect(0,i,Bitmap1->Width,i+1);

for(int j1=Bitmap1->Height-1;j1>=i;j1--){

Dest1 =Rect(0,j1,Bitmap1->Width,j1+1);

Form1->Canvas->CopyRect(Dest1,Bitmap1->Canvas,Source1);

for(j=0;j<10000;j++);

}

}

}

//---------------------------------------------------------------------------

void __fastcall TForm1::BitBtn15Click(TObject *Sender)

{

Form1->Refresh();

int j1=sqrt(Bitmap1->Width*Bitmap1->Width+

Bitmap1->Height*Bitmap1->Height)/2+4;

for (i=1;i<j1;i++){

MyRgn=CreateEllipticRgn(Bitmap1->Width/2-i,

Bitmap1->Height/2-i,

Bitmap1->Width/2+i,

Bitmap1->Height/2+i);

SelectObject(Canvas->Handle,MyRgn);

Canvas->Draw(0,0,Bitmap1);

DeleteObject(MyRgn);

for(j=0;j<10000;j++);

}

}

//---------------------------------------------------------------------------

void __fastcall TForm1::BitBtn16Click(TObject *Sender)

{

Form1->Refresh();

HeightHalf=Bitmap1->Height/2+Bitmap1->Height%2;

Source1=Rect(0,0,Bitmap1->Width,HeightHalf);

Source2=Rect(0,HeightHalf,Bitmap1->Width,Bitmap1->Height);

for(i=0;i<=Bitmap1->Width;i++){

Dest1=Rect(0-Bitmap1->Width+i,0,i,0+HeightHalf);

Dest2=Rect(Bitmap1->Width-i,HeightHalf,Bitmap1->Width+Bitmap1->Width-i,Bitmap1->Height+0);

Form1->Canvas->MoveTo(0-Bitmap1->Width+i-1,0);

Form1->Canvas->LineTo(0-Bitmap1->Width+i-1,HeightHalf);

Form1->Canvas->CopyRect(Dest1,Bitmap1->Canvas,Source1);

Form1->Canvas->MoveTo(Bitmap1->Width+Bitmap1->Width-i,0);

Form1->Canvas->LineTo(Bitmap1->Width+Bitmap1->Width-i,Bitmap1->Height);

Form1->Canvas->CopyRect(Dest2,Bitmap1->Canvas,Source2);

for(j=0;j<10000;j++);

}

}

//---------------------------------------------------------------------------

void __fastcall TForm1::BitBtn17Click(TObject *Sender)

{

Form1->Refresh();

WidthHalf=Bitmap1->Width/2+Bitmap1->Width%2;

Source1=Rect(0,0,WidthHalf,Bitmap1->Height);

Source2=Rect(WidthHalf,0,Bitmap1->Width,Bitmap1->Height);

for(i=0;i<=Bitmap1->Height;i++){

Dest1=Rect(0,0-Bitmap1->Height+i,WidthHalf,0+i);//Bitmap1->Width

Dest2=Rect(WidthHalf,Bitmap1->Height-i,Bitmap1->Width,0+i);//Bitmap1->Height+1);

Canvas->MoveTo(0,0-Bitmap1->Height+i-1);

Form1->Canvas->LineTo(WidthHalf,0-Bitmap1->Height+i-1);

Form1->Canvas->CopyRect(Dest1,Bitmap1->Canvas,Source1);

Form1->Canvas->MoveTo(WidthHalf,

Bitmap1->Height+Bitmap1->Height-i);

Form1->Canvas->LineTo(Bitmap1->Width,

Bitmap1->Height+Bitmap1->Height-i);

Form1->Canvas->CopyRect(Dest2,Bitmap1->Canvas,Source2);

for(j=0;j<10000;j++);

}

}

//---------------------------------------------------------------------------

void __fastcall TForm1::BitBtn18Click(TObject *Sender)

{

Form1->Refresh();

WidthHalf=Bitmap1->Width/2+Bitmap1->Width%2;

Source1=Rect(0,0,WidthHalf,Bitmap1->Height);

Source2=Rect(WidthHalf,0,Bitmap1->Width,Bitmap1->Height);

for(i=0;i<=Bitmap1->Height;i++){

Dest1=Rect(0,0-Bitmap1->Height+i,WidthHalf,0+i);//Bitmap1->Width

Dest2=Rect(WidthHalf,Bitmap1->Height-i,Bitmap1->Width,i-0);

Canvas->MoveTo(0,0-Bitmap1->Height+i-1);

Form1->Canvas->LineTo(WidthHalf,0-Bitmap1->Height+i-1);

Form1->Canvas->CopyRect(Dest1,Bitmap1->Canvas,Source1);

Form1->Canvas->MoveTo(WidthHalf,

Bitmap1->Height+Bitmap1->Height-i);

Form1->Canvas->LineTo(Bitmap1->Width,

Bitmap1->Height+Bitmap1->Height-i);

Form1->Canvas->CopyRect(Dest2,Bitmap1->Canvas,Source2);

for(j=0;j<10000;j++);

}

}

//---------------------------------------------------------------------------

void __fastcall TForm1::BitBtn19Click(TObject *Sender)

{

Form1->Refresh();

Source2=Rect(0,0,Bitmap1->Width,Bitmap1->Height);

for(i=0;i<=Bitmap1->Height;i++){

Dest2=Rect(0,Bitmap1->Height-i,Bitmap1->Width,i-0);

Canvas->MoveTo(0,0-Bitmap1->Height+i-1);

Form1->Canvas->MoveTo(0,Bitmap1->Height+Bitmap1->Height-i);

Form1->Canvas->LineTo(Bitmap1->Width,Bitmap1->Height+Bitmap1->Height-i);

Form1->Canvas->CopyRect(Dest2,Bitmap1->Canvas,Source2);

for(j=0;j<10000;j++);

}

}

//---------------------------------------------------------------------------

void __fastcall TForm1::BitBtn20Click(TObject *Render)

{

Form1->Refresh();

Source2=Rect(0,Bitmap1->Height,Bitmap1->Width,0);

for(i=0;i<=Bitmap1->Width;i++){

Dest2=Rect(i-0,Bitmap1->Height,Bitmap1->Width-i,0);

Canvas->MoveTo(0-Bitmap1->Width+i-1,0);

Form1->Canvas->MoveTo(Bitmap1->Width+Bitmap1->Width-i,0);

Form1->Canvas->LineTo(Bitmap1->Width+Bitmap1->Width-i,Bitmap1->Height);

Form1->Canvas->CopyRect(Dest2,Bitmap1->Canvas,Source2);

for(j=0;j<10000;j++);

}

}

//---------------------------------------------------------------------------

void __fastcall TForm1::BitBtn21Click(TObject *Sender)

{

Application->Terminate();

}

//---------------------------------------------------------------------------

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
2023年上半年GDP全球前十五强
 百态   2023-10-24
美众议院议长启动对拜登的弹劾调查
 百态   2023-09-13
上海、济南、武汉等多地出现不明坠落物
 探索   2023-09-06
印度或要将国名改为“巴拉特”
 百态   2023-09-06
男子为女友送行,买票不登机被捕
 百态   2023-08-20
手机地震预警功能怎么开?
 干货   2023-08-06
女子4年卖2套房花700多万做美容:不但没变美脸,面部还出现变形
 百态   2023-08-04
住户一楼被水淹 还冲来8头猪
 百态   2023-07-31
女子体内爬出大量瓜子状活虫
 百态   2023-07-25
地球连续35年收到神秘规律性信号,网友:不要回答!
 探索   2023-07-21
全球镓价格本周大涨27%
 探索   2023-07-09
钱都流向了那些不缺钱的人,苦都留给了能吃苦的人
 探索   2023-07-02
倩女手游刀客魅者强控制(强混乱强眩晕强睡眠)和对应控制抗性的关系
 百态   2020-08-20
美国5月9日最新疫情:美国确诊人数突破131万
 百态   2020-05-09
荷兰政府宣布将集体辞职
 干货   2020-04-30
倩女幽魂手游师徒任务情义春秋猜成语答案逍遥观:鹏程万里
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案神机营:射石饮羽
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案昆仑山:拔刀相助
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案天工阁:鬼斧神工
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案丝路古道:单枪匹马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:与虎谋皮
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:李代桃僵
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:指鹿为马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:小鸟依人
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:千金买邻
 干货   2019-11-12
 
推荐阅读
 
 
 
>>返回首頁<<
 
靜靜地坐在廢墟上,四周的荒凉一望無際,忽然覺得,淒涼也很美
© 2005- 王朝網路 版權所有