⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 unit1.cpp

📁 <<C++Builder 6实用编程100例>>随书光盘
💻 CPP
字号:
//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
        : TForm(Owner)
{
}
//---------------------------------------------------------------------------


void __fastcall TForm1::Button1Click(TObject *Sender)
{
        if(OpenPictureDialog1->Execute())
        {
                Image1->Picture->LoadFromFile(OpenPictureDialog1->FileName);
                Button2->Enabled=true;
                Button3->Enabled=true;
        }
}
//---------------------------------------------------------------------------
//向外爆炸效果
void __fastcall TForm1::Button2Click(TObject *Sender)
{
        Graphics::TBitmap* myBitmap;
        myBitmap=new Graphics::TBitmap;
        myBitmap->Width=Image1->Width;
        myBitmap->Height=Image1->Height;
        int width,height;
        width=Image1->Width;
        height=Image1->Height;
        TRect myRect;
        for(int i=0;i<=40;i++)
        {
                myRect.Left=width/2-width*i/80;
                myRect.Top=height/2-height*i/80;
                myRect.Right=width-width/2+width*i/80;
                myRect.Bottom=height-height/2+height*i/80;
                myBitmap->Canvas->CopyRect(myRect,Image1->Canvas,myRect);
                Form1->Canvas->Draw(18,18,myBitmap);     
                Sleep(30);
                Application->ProcessMessages();
        }
        delete myBitmap;
}
//---------------------------------------------------------------------------
//向内爆炸效果
void __fastcall TForm1::Button3Click(TObject *Sender)
{
        Graphics::TBitmap* myBitmap;
        myBitmap=new Graphics::TBitmap;
        myBitmap->Width=Image1->Width;
        myBitmap->Height=Image1->Height;
        int width,height;
        width=Image1->Width;
        height=Image1->Height;
        TRect myRect;
        for(int i=0;i<=20;i++)
        {
                //上半部分
                myRect.Left=0;
                myRect.Top=0;
                myRect.Right=width;
                myRect.Bottom=height*i/40;
                myBitmap->Canvas->CopyRect(myRect,Image1->Canvas,myRect);
                Form1->Canvas->Draw(18,18,myBitmap);
                // 下半部分
                myRect.Left=0;
                myRect.Top=height-height*i/40;
                myRect.Right=width;
                myRect.Bottom=height;
                myBitmap->Canvas->CopyRect(myRect,Image1->Canvas,myRect);
                Form1->Canvas->Draw(18,18,myBitmap);
                //左半部分
                myRect.Left=0;
                myRect.Top=0;
                myRect.Right=width*i/40;
                myRect.Bottom=height;
                myBitmap->Canvas->CopyRect(myRect,Image1->Canvas,myRect);
                Form1->Canvas->Draw(18,18,myBitmap);
                //右半部分
                myRect.Left=width-width*i/40;
                myRect.Top=0;
                myRect.Right=width;
                myRect.Bottom=height;
                myBitmap->Canvas->CopyRect(myRect,Image1->Canvas,myRect);
                Form1->Canvas->Draw(18,18,myBitmap);

                Application->ProcessMessages();
                Sleep(60);
        }
        delete myBitmap;
}
//---------------------------------------------------------------------------

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -