如何在Listbox加背景图
发布时间:2021-12-28 13:11:09阅读:88435次来源:HarmonyOS下载网 如何在Listbox加背景图: 1. 建立一个窗体 2. 放一个ComboBox和Listbox 3. 改变Component的Style为csOwnerDrawVariable和ListBox的Style为lbOwnerDrawVariable。 4. 声明5个TBitmap的全局变量 5. 覆盖Form的OnCreate. 6. 覆盖ComboBox的OnDraw. 7. 覆盖ComboBox的OnMeasureItem. 8. 释放资源在Form的OnClose. unit Ownerdrw; interface uses SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TForm1 = class(TForm) ComboBox1: TComboBox; ListBox1: TListBox; procedure FormCreate(Sender: TObject); procedure FormClose(Sender: TObject; var Action: TCloseAction); procedure ComboBox1DrawItem(Control: TWinControl; Index: Integer; Rect: TRect; State: TOwnerDrawState); procedure ComboBox1MeasureItem(Control: TWinControl; Index: Integer; var Height: Integer); procedure ListBox1DrawItem(Control: TWinControl; Index: Integer; Rect: TRect; State: TOwnerDrawState); procedure ListBox1MeasureItem(Control: TWinControl; Index: Integer; var Height: Integer); private { Private declarations } public { Public declarations } end; var Form1: TForm1; TheBitmap1, TheBitmap2, TheBitmap3, TheBitmap4, TheBitmap5 : TBitmap; implementation {$R *.DFM} procedure TForm1.FormCreate(Sender: TObject); begin TheBitmap1 := TBitmap.Create; TheBitmap1.LoadFromFile('C:\delphi\images\buttons\globe.bmp'); TheBitmap2 := TBitmap.Create; TheBitmap2.LoadFromFile('C:\delphi\images\buttons\video.bmp'); TheBitmap3 := TBitmap.Create; TheBitmap3.LoadFromFile('C:\delphi\images\buttons\gears.bmp'); TheBitmap4 := TBitmap.Create; TheBitmap4.LoadFromFile('C:\delphi\images\buttons\key.bmp'); TheBitmap5 := TBitmap.Create; TheBitmap5.LoadFromFile('C:\delphi\images\buttons\tools.bmp'); ComboBox1.Items.AddObject('Bitmap1: Globe', TheBitmap1); ComboBox1.Items.AddObject('Bitmap2: Video', TheBitmap2); ComboBox1.Items.AddObject('Bitmap3: Gears', TheBitmap3); 更多 0
- 华硕怎么win10系统(华硕如何装win10系统)
华硕怎么装win10系统电脑用着用着,突然冒出些奇奇怪怪的毛病,例如运行卡顿、缓慢。这时候啊,重装系统可能就是你的救命稻草!虽然重装意味着你得和电脑上的所有数据暂时说拜拜,但它能让你的电脑焕然一新。想要轻松搞定?一键重装系统工具是你的不二之
- 怎么快速重装win10系统,如何快速重装win10系统
怎么快速重装win10系统用着Win10,是不是偶尔会遇到系统卡顿、崩溃或者慢得像蜗牛爬?别担心,咱们有绝招,那就是重装系统。在线重装和U盘启动盘重装,哪个更简单?当然是在线重装啦,一键搞定,省心省力。只要提前做好数据备份,重要文件一个都不