BMP.cpp
上传用户:lulishicai
上传日期:2010-03-01
资源大小:13202k
文件大小:2k
源码类别:

Delphi/CppBuilder

开发平台:

C++ Builder

  1. //---------------------------------------------------------------------------
  2. #include <vcl.h>
  3. #pragma hdrstop
  4. #include "BMP.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::FormCreate(TObject *Sender)
  16. {
  17. Form1->DirectoryListBox1->Drive='c';
  18. //设置控件的缺省路径
  19. }
  20. //---------------------------------------------------------------------------
  21. void __fastcall TForm1::FileListBox1Click(TObject *Sender)
  22. {
  23. Form1->Image1->Picture->LoadFromFile(Form1->FileListBox1->FileName);
  24. Form1->Image2->Picture->LoadFromFile(Form1->FileListBox1->FileName);
  25. //读取图象信息
  26. if (Form1->Image1->Width>Form1->Image2->Width)
  27.    {
  28.    Form1->ScrollBar1->Visible=true;
  29.    Form1->ScrollBar1->Max=Form1->Image1->Width-Image2->Width;
  30.    }
  31.    //如果图象尺寸比显示区域大,那么显示滚动条
  32.    else
  33.    Form1->ScrollBar1->Visible=false;
  34. if (Form1->Image1->Height>Form1->Image2->Height)
  35.    {
  36.    Form1->ScrollBar2->Visible=true;
  37.    Form1->ScrollBar2->Max=Form1->Image1->Height-Image2->Height;
  38.    }
  39.    //如果图象尺寸比显示区域大,那么显示滚动条
  40.    else
  41.    Form1->ScrollBar2->Visible=false;
  42. }
  43. //---------------------------------------------------------------------------
  44. void __fastcall TForm1::ScrollBar1Scroll(TObject *Sender,
  45.       TScrollCode ScrollCode, int &ScrollPos)
  46. {
  47. Form1->Image1->Left=-Form1->ScrollBar1->Position;
  48. //滚动显示图象
  49. }
  50. //---------------------------------------------------------------------------
  51. void __fastcall TForm1::ScrollBar2Scroll(TObject *Sender,
  52.       TScrollCode ScrollCode, int &ScrollPos)
  53. {
  54. Form1->Image1->Top=-Form1->ScrollBar2->Position;
  55. //滚动显示图象
  56. }
  57. //---------------------------------------------------------------------------
  58.