用BCB开拓非凡的屏幕显示结果
副标题#e#
以前,措施员在DOS平台下开拓应用软件时,城市操作DOS的开放性特点,通过间断编写出一些非凡的显示结果,以此来给本身的措施增加一些有趣的特色。 然而,跟着面向Windows的编程和可视化的第四代开拓东西的慢慢利用,人们越来越被Windows的统一的编程气势气魄所束缚,同时由于Windows直接打点间断,想用本来的要领来实现一些非凡的显示结果变得越来越坚苦了。
那么,在Windows时代措施员如何来实现窗口的非凡结果呢?实际上,由于整个Windows是图形显示系统,因此对系统而言,用户措施的每一个界面、窗口都是系统的一个画布。措施员可以操作这一特点来实现窗口的非凡结果。
最近笔者操作C++ Builder 5.0 Enterprise乐成的实现了该项成果,现先容如下:
1、在BCB中成立一个工程文件project1.dpr,在Form1中添加如下控件:
控件名称 属性 值
TForm Color clBTnText
TMainMenu Name MainMneu1
TImage Name Image1
Align alClient
AutoSize True
同时在 MainMenu1控件中增加一个菜单项,其属性为:
Name Caption
Items1 图像从中间往阁下分出
Items2 图像从阁下往中间合进
Items3 图像从中间往上下分出
Items4 图像从上下往中间合进
Items5 图像从左移入
Items6 图像从右移入
Items7 图像从上移入
Items8 图像从下移入
Items9 图像从左刷屏显示
Items10 图像从右刷屏显示
Items11 图像从上刷屏显示
Items12 图像从下刷屏显示
Items13 图像从上往下流水
Items14 图像从下往上流水
Items15 图像圆形展出
Items16 图像阁下错移
Items17 图像上下错移
同时在Unit.cpp中的private中添加如下变量:
private:
BITMAP bm;
Graphics::TBitmap *Bitmap1;
int i,j;
int WideHalf;
TRect Dest1,Source1,Dest2,Source2;
int HeightHalf;
HRGN MyRgn;
#p#副标题#e#
2、在Form1的OnCreate事件中添加如下代码:
void __fastcall TForm1::FormCreate(Tobject *Sender)//举办图像特效显示的初始化操纵// { Graphics::Tbitmap *Bitmap1 = new Graphics::Tbitmap();//界说一个图象句柄// Bitmap1->LoadFromFile("C:\\factory.bmp");//设定所要特效显示的图象为factory.bmp// if(GetDeviceCaps(Form1->Canvas->Handle,BITSPIXEL)==8)//取得显示窗口的颜色属性// { GetObject(Bitmap1->Handle,sizeof(BITMAP),(LPSTR)&bm); if (bm.bmBitsPixel==8)//假如特效显示的图象颜色属性为256色// { SelectPalette(Form1->Canvas->Handle,Bitmap1->Palette,FALSE);//从特效显示的颜色画板中提取配色方案// RealizePalette(Form1->Canvas->Handle); //在显示窗口中配置配色方案// } Bitmap->HandleType=bmDDB; } }
3、在Items1的OnClieck事件中添加如下代码:
void__fastcall TForm1::Item1Click(TObject *Sender)
{ //图象从中间往阁下分出//
Form1->Refresh( );
WideHalf=Bitmap1->Width/2+Bitmap1->Width%2;
for(i=0;i<=WideHalf; i++)
{
Dest1=Rect(WideHalf-i,0,WideHalf+i,Bitmap1->Height);
Source1=Rect(WideHalf-i,0,WideHalf+i,Bitmap1->Height);
Form1->Canvas->CopyRect(Dest1,Bitmap1->Canvas,Source1);
for(j=0;j<10000;j++);//图像的延迟显示//
}
}
4、在Items2的OnClieck事件中添加如下代码:
void__fastcall TForm1::Item2Click(TObject *Sender)
{ //图像从阁下往中间合进//
Form1->Refresh( );
WideHalf=Bitmap1->Width/2+Bitmap1->Width%2;
Form1->Refresh( );
for(i=0;i<=WideHalf;i++)
{
Source1=Dest1=Rect(0,0,i,Bitmap1->Height);
Source2=Dest2=Rect(Bitmap1->Width-i,0,Bitmap->Width,Bitmap1->Height);
Form1->Canvas->CopyRect(Dest1,Bimap1->Canvas,Source1);
Form1->Canvas->CopyRect(Dest2,Bitmap1->Canvas,Source2);
for(j=0;j<10000;j++);
}
}
5、在Items3的OnClieck事件中添加如下代码:
#p#分页标题#e#
void__fastcall TForm1::Item3Click(TObject *Sender)
{ //图像从中间往上下分出//
Form1->Refresh( );
HeightHAlf=Bittmap1->Height/2+Bitmap1->Height%2;
for(i=0;i<=HeightHalf;i++)
{
Dest1=Rect(0,HeightHalf-i,Bitmap1->Width,HeightHalf);
Source1=Rect(0,0,BmpHandle->Width,i);
Dest2=Rect(0,HeightHaf,Bitmap1->Width,HeightHalf+i);
Source2=Rect(0,Bitmap1->Height-i,Bitmap1->Width,Bitmap1->height);
Form1->Canvas->CopyRect(Dest1,BmpHandle->Canvas,Source1);
Form1->Canvas->CopyRect(Dest2,BmpHandle->Canvas,Source2);
for(j=0;j<10000;j++);
}
}
6、在Items4的OnClieck事件中添加如下代码:void__fastcall TForm1::Item4Click(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++);
}
}
7、在Items5的OnClieck事件中添加如下代码:void__fastcall TForm1::Item5Click(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++);
}
}
8、在Items6的OnClieck事件中添加如下代码:
void__fastcall TForm1::Item6Click(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++);
}
}
9、在Items7的OnClieck事件中添加如下代码:
void__fastcall TForm1::Item7Click(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<10000;j++);
}
}
10、在Items8的OnClieck事件中添加如下代码:void__fastcall TForm1::Item8Click(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++);
}
}
11、在Items9的OnClieck事件中添加如下代码:void__fastcall TForm1::Item9Click(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++);
}
}
12、在Items10的OnClieck事件中添加如下代码:
#p#分页标题#e#
void__fastcall TForm1::Item10Click(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++);
}
}
13、在Items11的OnClieck事件中添加如下代码:
void__fastcall TForm1::Item11Click(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++);
}
}
14、在Items12的OnClieck事件中添加如下代码:void__fastcall TForm1::Item12Click(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++);
}
}
15、在Items13的OnClieck事件中添加如下代码:void__fastcall TForm1::Item13Click(TObject *Sender)
{ //图像从上往下流水//
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,j+1);
Form1->Canvas->CopyRect(Dest1,Bitmap1->Canvas,Source1);
for(j=0;j<10000;j++);
}
}
}
16、在Items14的OnClieck事件中添加如下代码:
void__fastcall TForm1::Item14Click(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++);
}
}
}
17、在Items15的OnClieck事件中添加如下代码:void__fastcall TForm1::Item15Click(TObject *Sender)
{ //图像圆形展出//
Form1->Refresh( );
int j1=sqrt(Bitmap1->Width*Bitmap1->Width+
Bitmap1->Height*Bitmap1->Height)/2+4;
for (i=1;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++);
}
}
18、在Items16的OnClieck事件中添加如下代码:void__fastcall TForm1::Item16Click(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++);
}
}
#p#分页标题#e#
19、在Items17的OnClieck事件中添加如下代码:
void__fastcall TForm1::Item17Click(Tobject *Sender) { //图像上下错移// Form1->Refresh( ); WideHalf=Bitmap1->Width/2+Bitmap1->Width%2; Source1=Rect(0,0,WideHalf,Bitmap1->Height); Source2=Rect(WideHalf,0,Bitmap1->Width,Bitmap1->Height); for(i=0;i<=Bitmap1->Height;i++) { Dest1=Rect(0,0-Bitmap1->Height+I,WideHalf,0+i); Dest2=Rect(WideHalf,Bitmap1->Height-I,Bitmap1->Width, Bitmap1->Height+Bitmap1->Top); //上面这条代码大概有错。其时有乱码。:( Form1->Canvas->MoveTo(0,0-Bitmap1->Height+i-1); Form1->Canvas->LineTo(WideHalf,0-Bitmap1->Height+i-1); Form1->Canvas->CopyRect(Dest1,Bitmap1->Canvas,Source1); Form1->Canvas->MoveTo(WideHalf,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++); } }
以上措施在C++ Builder5.0Enterpriseh和Win98/WinME通过。