DelphiFan Magazine

Top Menu

Main Menu

  • DELPHI
  • CODE SAMPLES
  • FIREMONKEY
  • DATABASE
  • RELEASES
  • VIDEOS
  • REVIEW
  • TECH NEWS

logo

DelphiFan Magazine

  • DELPHI
  • CODE SAMPLES
  • FIREMONKEY
  • DATABASE
  • RELEASES
  • VIDEOS
  • REVIEW
  • TECH NEWS
  • How to add a server application written in UNIGUI to startup?

  • UniGUI Expiry Link Anonymizer

  • UniGUI Add CAPTCHA to the WEB project

  • UniGui. Unique hybrid of Delphi and JS

  • How to transform a blob field into string lines (varchar) in SQL Firebird?

CODE SAMPLESDELPHIFIREMONKEY
Home›CODE SAMPLES›Show image in Firemonkey TListBox

Show image in Firemonkey TListBox

By admin
December 15, 2020
195
0
Share:

Display images in Firemonkey TListBox

Introduce how to display in OnList event of TListBoxItem and how to display by placing TImage component on TListBoxItem.

How to display in the OnPaint event of TListBoxItem

Place a TButton component and a TListBox component on the form.

Describe the OnClick event of the TButton component.

procedure TForm2.Button1Click(Sender: TObject);
var
  Item: TListBoxItem;
begin
  Item := TListBoxItem.Create(nil);
  Item.Parent := ListBox1;
  Item.Height := 200;
  Item.OnPaint := ListBoxItemPaint;
end;
When the button is pressed, an item will be added to ListBox1.
The items of ListBox1 are drawn using the ListBoxItemPaint method of the form.
Add the ListBoxItemPaint method to the form.
type
  TForm2 = class(TForm)
    Button1: TButton;
    ListBox1: TListBox;
    procedure Button1Click(Sender: TObject);
  private
    { private Declaration }
    procedure ListBoxItemPaint(Sender: TObject; Canvas: TCanvas;
      const ARect: TRectF);
  public
    { public Declaration }
  end;
Use the ListBoxItemPaint method to draw the image.
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
How to place the TImage component at the top of the TListBoxItem
Place a TButton component and a TListBox component on the form.
Describe the OnClick event of the TButton component.
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;
When the button is pressed, an item will be added to ListBox1.
Put the TImage component on the added item, and display the image in the TImage component.
Tagsandroiddelphifiremonkeyfmximageslistboxtlistbox
Previous Article

Copy text to clipboard in Firemonkey applications

Next Article

View the output function list of DLL

0
Shares
  • 0
  • +
  • 0
  • 0
  • 0
  • 0

admin

Related articles More from author

  • CODE SAMPLESDELPHI

    Work with External program or Files in Delphi

    November 26, 2020
    By admin
  • CODE SAMPLESDELPHI

    Rapidly Use Delphi FireDAC In A Multithreaded Environment With The FireDAC.Pooling Sample

    September 14, 2020
    By admin
  • CODE SAMPLESDELPHI

    Example of how to use Intraweb

    November 20, 2020
    By admin
  • CODE SAMPLESDELPHI

    Customize the height of uniGUI Grid header

    October 1, 2020
    By admin
  • CODE SAMPLESDELPHI

    Good code samples for cxGrid Part2

    October 26, 2020
    By admin
  • CODE SAMPLESDELPHIFIREMONKEY

    Get device ID on Android from Delphi

    December 4, 2020
    By admin

Leave a reply Cancel reply

You may interested

  • CODE SAMPLESDELPHI

    Work with External program or Files in Delphi

  • CODE SAMPLESDELPHI

    How create a new uniGUI application

  • CODE SAMPLESDELPHI

    About memory data and JSON

  • LATEST REVIEWS

  • TOP REVIEWS

Timeline

  • January 27, 2021

    How to add a server application written in UNIGUI to startup?

  • January 27, 2021

    UniGUI Expiry Link Anonymizer

  • January 26, 2021

    UniGUI Add CAPTCHA to the WEB project

  • January 26, 2021

    UniGui. Unique hybrid of Delphi and JS

  • January 13, 2021

    How to transform a blob field into string lines (varchar) in SQL Firebird?

Latest Comments

Find us on Facebook

Follow Us on Instagram

logo

Our website, law, laws, copyright and aims to be respectful of individual rights. Our site, as defined in the law of 5651 serves as a provider of space. According to the law, contrary to the law of site management has no obligation to monitor content. Therefore, our site has adopted the principle of fit and remove. Works are subject to copyright laws and is shared in a manner that violated their legal rights, or professional associations, rights holders who, adsdelphi@gmail.com I can reach us at e-mail address. Complaints considered to be infringing on the examination of the content will be removed from our site.

About us

  • 660 Pennsylvania Avenue Southeast #100 Washington, DC 20003
  • 0123456789
  • adsdelphi@gmail.com
  • Recent

  • Popular

  • Comments

  • How to add a server application written in UNIGUI to startup?

    By admin
    January 27, 2021
  • UniGUI Expiry Link Anonymizer

    By admin
    January 27, 2021
  • UniGUI Add CAPTCHA to the WEB project

    By admin
    January 26, 2021
  • UniGui. Unique hybrid of Delphi and JS

    By admin
    January 26, 2021
  • How to add a server application written in UNIGUI to startup?

    By admin
    January 27, 2021
  • Amazing Cross Platform Email App Sample In Delphi 10.4.1 FireMonkey For Android And IOS

    By admin
    August 13, 2020
  • Critical Update Available For Delphi FireMonkey 10.4.1 On Android, IOS, OSX, Windows, And Linux

    By admin
    September 4, 2020
  • Setting up the IDE for your first Android Application in Delphi

    By admin
    September 7, 2020

Follow us

Find us on Facebook

© Copyright Delphifan Forum. All rights reserved.