为什么在运行中不能显示出来? (双屏缓冲)
void __fastcall TForm1::Button1Click(TObject *Sender)
{
int FWidth = 0;
int FHeight = 0;
Graphics::TBitmap *FBMP = new Graphics::TBitmap;
FBMP->LoadFromFile("D:\\asap.bmp");
FHeight = FBMP->Height;
FWidth = FBMP->Width;
HDC DestDC = Image1->Canvas->Handle;
HDC WorkDC = CreateCompatibleDC(DestDC);
SelectObject(WorkDC, FBMP->Handle);
for (int i = 0; i <= FHeight -1 ; i++)
{
BitBlt(DestDC, 0, 0, FWidth, i, WorkDC, 0, FHeight - i, SRCCOPY);
Sleep(10);
//Application->ProcessMessages();
//Image1->Refresh();
}
}
而改成为 就行了,为什么
void __fastcall TForm1::SpeedButton2Click(TObject *Sender)
{
int FWidth = 0;
int FHeight = 0;
Graphics::TBitmap *FBMP = new Graphics::TBitmap;
FBMP->LoadFromFile("D:\\asap.bmp");
FHeight = FBMP->Height;
FWidth = FBMP->Width;
Image1->Canvas->Brush->Color = clBlack;
Image1->Canvas->FillRect(Image1->ClientRect);
this->DoubleBuffered = true;
for (int i = 0; i <= FHeight -1 ; i++)
{
TRect sur = TRect(0, 0, FWidth, i);
TRect des = TRect(0, FHeight - i, FWidth, FHeight);
Image1->Canvas->CopyRect(sur, FBMP->Canvas, des);
Image1->Refresh();
}
}