⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mainform.cpp

📁 C++ BUILDER精彩编程实例集锦(源码) 第一部分 界面设计 第二部分 程序设置
💻 CPP
字号:
//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#include "Mainform.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
        : TForm(Owner)
{
  this->ListBox1->Clear();
  this->ListBox1->Items->AddObject("第1 幅图像",this->Image1->Picture->Bitmap);
  this->ListBox1->Items->AddObject("第2 幅图像",this->Image2->Picture->Bitmap);
  this->ListBox1->Items->AddObject("第3 幅图像",this->Image3->Picture->Bitmap);
  this->ListBox1->Items->AddObject("第4 幅图像",this->Image4->Picture->Bitmap);
  SendMessage(this->ListBox1->Handle,LB_SETHORIZONTALEXTENT,500,0);//添加水平滚动条
}
//---------------------------------------------------------------------------
void __fastcall TForm1::ListBox1DrawItem(TWinControl *Control, int Index,
      TRect &Rect, TOwnerDrawState State)
{
  Graphics::TBitmap *pBmp;
  int     iPos = 2;   //说明文字显示位置值
  TCanvas *pCanvas = ((TListBox *)Control)->Canvas;
  pCanvas->FillRect(Rect);
  pBmp = (Graphics::TBitmap *)((TListBox *)Control)->Items->Objects[Index];
  if (pBmp)
  {
    pCanvas->CopyRect(Bounds(Rect.Left + iPos, Rect.Top, pBmp->Width, pBmp->Height), pBmp->Canvas,Bounds(0, 0, pBmp->Width, pBmp->Height));
    iPos += pBmp->Width + 4;
  }
  pCanvas->TextOut(Rect.Left + iPos, Rect.Top+20,((TListBox *)Control)->Items->Strings[Index]);
}
//---------------------------------------------------------------------------


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -