Delphi XE8在Firemonkey TListBox中显示图像

2022-12-01 10:51:17 作者:admin

本文整理自网络,侵删。

 如何使用Delphi XE8在Firemonkey TListBox中显示图像
介绍如何在TListBoxItem的OnList事件中显示以及如何通过在TListBoxItem上放置TImage组件进行显示。
如何在TListBoxItem的OnPaint事件中显示在窗体上放置一个TButton组件和一个TListBox组件。
描述TButton组件的OnClick事件。
procedure TForm2.Button1Click(Sender: TObject);var  Item: TListBoxItem;begin  Item := TListBoxItem.Create(nil);  Item.Parent := ListBox1;  Item.Height := 200;  Item.OnPaint := ListBoxItemPaint;end;当按下按钮时,一个项目将添加到ListBox1。
ListBox1的项目是使用表单的ListBoxItemPaint方法绘制的。
将ListBoxItemPaint方法添加到窗体。
type  TForm2 = class(TForm)    Button1: TButton;    ListBox1: TListBox;    procedure Button1Click(Sender: TObject);  private    { private 宣言 }    procedure ListBoxItemPaint(Sender: TObject; Canvas: TCanvas;      const ARect: TRectF);  public    { public 宣言 }  end;使用ListBoxItemPaint方法绘制图像。
procedure TForm2.ListBoxItemPaint(Sender: TObject; Canvas: TCanvas;  const ARect: TRectF);const  IMAGEFILE_PATH =    'C:\Program Files (x86)\Embarcadero\Studio\16.0\Images\Splash\256Color\CHEMICAL.BMP';var  Bitmap: TBitmap;  SrcRect, DstRect: TRectF;begin  Bitmap := TBitmap.Create;  Bitmap.LoadFromFile(IMAGEFILE_PATH);
  SrcRect.Left := 0;  SrcRect.Top := 0;  SrcRect.Width := Bitmap.Width;  SrcRect.Height := Bitmap.Height;
  DstRect.Left := 0;  DstRect.Top := 0;  DstRect.Width := Bitmap.Width;  DstRect.Height := Bitmap.Height;
  Canvas.DrawBitmap(Bitmap, SrcRect, DstRect, 1.0, True);  Bitmap.Free;end;listbox01
如何将TImage组件放置在TListBoxItem的顶部在窗体上放置一个TButton组件和一个TListBox组件。
描述TButton组件的OnClick事件。
procedure TForm2.Button1Click(Sender: TObject);const  IMAGEFILE_PATH =    'C:\Program Files (x86)\Embarcadero\Studio\16.0\Images\Splash\256Color\CHEMICAL.BMP';var  Item: TListBoxItem;  Image: TImage;begin  Item := TListBoxItem.Create(nil);  Item.Parent := ListBox1;  Item.Height := 200;
  Image := TImage.Create(Item);  Image.Parent := Item;  Image.Width := 240;  Image.Height := 180;  Image.Bitmap.LoadFromFile(IMAGEFILE_PATH);end;当按下按钮时,一个项目将添加到ListBox1。
将TImage组件放在添加的项目上,并在TImage组件中显示图像。

相关阅读 >>

Delphi 进程保护

Delphi实现音频传输

Delphi 无窗体无界面exe怎么做?

Delphi 得到字符串拼音首字母

Delphi7判断字符是否是数字

Delphi createprocesswithlogonw用法

Delphi 获取网卡信息(支持多网卡)

Delphi在richedit控件中插入gif动画表情

Delphi twebbrowser控件编程

Delphi实时监视应用程序内存使用量

更多相关阅读请进入《Delphi》频道 >>



在线咨询 拨打电话