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::BitBtn1Click(TObject *Sender)
  16. {
  17.   if(BitBtn1->Tag==0)
  18.     BitBtn1->Glyph->Assign(Image1->Picture->Bitmap);
  19.   else if(BitBtn1->Tag==1)
  20.     BitBtn1->Glyph->Assign(Image2->Picture->Bitmap);
  21.   else
  22.     BitBtn1->Glyph->Assign(Image3->Picture->Bitmap);
  23.   BitBtn1->Tag++;
  24.   if(BitBtn1->Tag>=3)BitBtn1->Tag=0;
  25. }
  26. //---------------------------------------------------------------------------
  27. void __fastcall TForm1::BitBtn2Click(TObject *Sender)
  28. {
  29.   AnsiString bmpfile;
  30.   Graphics::TBitmap *Bitmap1 = new Graphics::TBitmap();
  31.   if(BitBtn2->Tag==0)
  32.     bmpfile="te1.bmp";
  33.   else if(BitBtn2->Tag==1)
  34.     bmpfile="te2.bmp";
  35.   else
  36.     bmpfile="te3.bmp";
  37.   try
  38.   {
  39.     Bitmap1->LoadFromFile(bmpfile);
  40.     BitBtn2->Glyph->Assign(Bitmap1);
  41.   }
  42.   catch (...)
  43.   {
  44.     ShowMessage("打开文件错误!");
  45.   }
  46.   BitBtn2->Tag++;
  47.   if(BitBtn2->Tag>=3)BitBtn2->Tag=0;
  48.   delete Bitmap1;
  49. }
  50. //---------------------------------------------------------------------------