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

📄 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::OpenClick(TObject *Sender)
{
        if(OpenPictureDialog1->Execute())
        {
                Image1->Picture->LoadFromFile(OpenPictureDialog1->FileName);
                Left_Roll->Enabled=true;
                Right_Roll->Enabled=true;
                Top_Pull->Enabled=true;
                Bottom_Pull->Enabled=true;
        }
}
//---------------------------------------------------------------------------
void __fastcall TForm1::ExitClick(TObject *Sender)
{
        Form1->Close();
}
//---------------------------------------------------------------------------
//左侧滚动效果
void __fastcall TForm1::Left_RollClick(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;
	for(int i=0;i<=width;i++)
	{
		myBitmap->Canvas->CopyRect(Rect(0,0,i,height),
                                Image1->Canvas,Rect(0,0,i,height));
		Form1->Canvas->Draw(18,18,myBitmap);
		Application->ProcessMessages();
		Sleep(6);
	}
	delete myBitmap;
}
//---------------------------------------------------------------------------
//右侧滚动效果
void __fastcall TForm1::Right_RollClick(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;
        for(int i=0;i<=width;i++)
        {
                myBitmap->Canvas->CopyRect(Rect(width-i,0,width,height),
				Image1->Canvas,Rect(width-i,0,width,height));
		Form1->Canvas->Draw(18,18,myBitmap);
		Application->ProcessMessages();
		Sleep(6);
        }
        delete myBitmap;
}
//---------------------------------------------------------------------------
//向上推拉效果
void __fastcall TForm1::Top_PullClick(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;
        for(int i=0;i<=height;i++)
        {
                myBitmap->Canvas->CopyRect(Rect(0,height-i,width,height),
				Image1->Canvas,Rect(0,0,width,i));
		Form1->Canvas->Draw(18,18,myBitmap);
		Application->ProcessMessages();
		Sleep(6);
        }
        delete myBitmap;
}
//---------------------------------------------------------------------------
//向下推拉效果
void __fastcall TForm1::Bottom_PullClick(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;
        for(int i=0;i<=height;i++)
        {
                myBitmap->Canvas->CopyRect(Rect(0,0,width,i),
				Image1->Canvas,Rect(0,height-i,width,height));
		Form1->Canvas->Draw(18,18,myBitmap);
		Application->ProcessMessages();
		Sleep(6);
        }
        delete myBitmap;
}
//---------------------------------------------------------------------------



⌨️ 快捷键说明

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