• 微软原版系统

  • 一键重装系统

  • 纯净系统

  • 在线技术客服

魔法猪系统重装大师 一键在线制作启动 U 盘 PE 系统 用一键重装的魔法拯救失去灵魂的系统
当前位置:首页 > 教程 > 电脑教程

如何在Listbox加背景图

时间:2015年04月02日 11:01:10    来源:魔法猪系统重装大师官网    人气:6981

如何在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);

如,何在,Listbox,加,背景,图,如,何在,Listb
Win7教程 更多>>
U盘教程 更多>>
Win10教程 更多>>
魔法猪学院 更多>>

Copyright © 2015-2023 魔法猪 粤ICP备19111771号 增值电信业务经营许可证 粤B2-20231006 魔法猪系统重装大师

本站发布的系统仅为个人学习测试使用,请在下载后24小时内删除,不得用于任何商业用途,否则后果自负,请支持购买微软正版软件。

在线客服 查看微信 返回顶部