Unit1.cpp
上传用户:lhxd_sz
上传日期:2014-10-02
资源大小:38814k
文件大小:1k
源码类别:

VC书籍

开发平台:

C++ Builder

  1. //---------------------------------------------------------------------------
  2. #include <vcl.h>
  3. #pragma hdrstop
  4. #include "Unit1.h"
  5. //---------------------------------------------------------------------------
  6. #pragma package(smart_init)
  7. #pragma resource "*.dfm"
  8. TForm1 *Form1;
  9. //---------------------------------------------------------------------------
  10. __fastcall TForm1::TForm1(TComponent* Owner)
  11.         : TForm(Owner)
  12. {
  13. }
  14. //---------------------------------------------------------------------------
  15. void __fastcall TForm1::PaintBox1Paint(TObject *Sender)
  16. {
  17.   int ii,jj,rows,cols,ww;
  18.   HDC ddc;
  19.   Graphics::TBitmap *bmp;
  20.   bmp = new Graphics::TBitmap();
  21.   bmp->LoadFromFile("te.bmp");
  22.   ddc=GetDC(ScrollBox1->Handle);
  23.   ww=ScrollBox1->HorzScrollBar->Range;
  24.   if(ww<ScrollBox1->Width)ww=ScrollBox1->Width;
  25.   cols=ww/bmp->Width;
  26.   ww=ScrollBox1->VertScrollBar->Range;
  27.   if(ww<ScrollBox1->Height)ww=ScrollBox1->Height;
  28.   rows=ww/bmp->Height;
  29.   for(ii=0;ii<rows;ii++)
  30.     for(jj=0;jj<cols;jj++)
  31.       BitBlt(ddc,jj*bmp->Width,ii*bmp->Height,bmp->Width,bmp->Height,bmp->Canvas->Handle,0,0,SRCCOPY);
  32.   delete bmp;
  33. }
  34. //---------------------------------------------------------------------------