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

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.   BK = new Graphics::TBitmap();
  14.   BK->Width=PaintBox1->Width;
  15.   BK->Height=PaintBox1->Height;
  16.   blFlash=True;
  17.   xx=20;yy=20;
  18. }
  19. //---------------------------------------------------------------------------
  20. void __fastcall TForm1::PaintBox1Paint(TObject *Sender)
  21. {
  22.   if(blFlash)
  23.   {
  24.     PaintBox1->Canvas->Brush->Color=clWhite;
  25.     PaintBox1->Canvas->FillRect(TRect(0,0,PaintBox1->Width,PaintBox1->Height));
  26.     PaintBox1->Canvas->TextOut(xx,yy,"中华人民共和国");
  27.     xx+=6;yy+=6;
  28.   }
  29.   else
  30.   {
  31.     BK->Canvas->Brush->Color=clWhite;
  32.     BK->Canvas->FillRect(TRect(0,0,BK->Width,BK->Height));
  33.     BK->Canvas->TextOut(xx,yy,"全国人民代表大会");
  34. //    PaintBox1->Canvas->CopyMode=cmSrcCopy;
  35.     BitBlt(PaintBox1->Canvas->Handle,0,0,PaintBox1->Width,PaintBox1->Height,BK->Canvas->Handle,0,0,SRCCOPY);
  36. //    PaintBox1->Canvas->CopyRect(Rect(0,0,PaintBox1->Width,PaintBox1->Height),BK->Canvas,Rect(0,0,PaintBox1->Width,PaintBox1->Height));
  37.     xx+=6;yy+=6;
  38.   }
  39. }
  40. //---------------------------------------------------------------------------
  41. void __fastcall TForm1::Button1Click(TObject *Sender)
  42. {
  43.   blFlash=True;
  44.   PaintBox1->Invalidate();
  45. }
  46. //---------------------------------------------------------------------------
  47. void __fastcall TForm1::FormDestroy(TObject *Sender)
  48. {
  49.   delete BK;
  50. }
  51. //---------------------------------------------------------------------------
  52. void __fastcall TForm1::Button2Click(TObject *Sender)
  53. {
  54.   blFlash=False;
  55.   PaintBox1->Invalidate();
  56. }
  57. //---------------------------------------------------------------------------