读书人

请问cbc下面实现百叶窗的程序为什么

发布时间: 2012-02-19 19:43:38 作者: rapoo

请教,cbc下面实现百叶窗的程序为什么不行阿??
在form中建了一个bitbtn和两个image,其中image1已经load了图片并且visible设为False。image2空白。结果一点击bitbtn,图片位置就变成了白色,请问为什么阿??

代码如下:
//------------------------------------

#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::BitBtn1Click(TObject *Sender)
{

//纵向百叶窗效果
Graphics::TBitmap *Bitmap = new Graphics::TBitmap();
Bitmap-> Height = Image1-> Height;
Bitmap-> Width = Image1-> Width;
int w=int((Image1-> Picture-> Bitmap-> Width +19)/20); //每页的宽度
for(int x=0;x <=w;x++)
{
for(int y=0;y <20;y++)
{
Bitmap-> Canvas-> CopyRect(Rect(y*w+x-1,0,y*w+x,
Image1-> Picture-> Bitmap-> Height),Image1-> Picture-> Bitmap-> Canvas,
Rect(y*w+x-1,0,y*w+x,Image1-> Picture-> Bitmap-> Height));
}
Image2-> Picture-> Bitmap-> Assign(Bitmap);
//暂停
::Sleep(100);
Application-> ProcessMessages();
}
delete Bitmap;

}
//------------------------------------


[解决办法]
http://topic.csdn.net/t/20051021/10/4341008.html
[解决办法]
//暂停
::Sleep(100);
Application-> ProcessMessages();

这两句交换一下
[解决办法]
我测试了一下没有问题啊,看看是不是图片格式不对

读书人网 >C++ Builder

热点推荐