Combobox中加载图片
来源:互联网 发布:清真表情包 知乎 编辑:程序博客网 时间:2024/04/29 14:34
www.u8686.com-信息发布平台
Combobox中加载图片
...draw Bitmaps in a TComboBox?
// This code works also with a TListBox
var
Bitmap1, Bitmap2, Bitmap3, Bitmap4: TBitmap;
procedure TForm1.FormCreate(Sender: TObject);
begin
ComboBox1.Style := csOwnerDrawVariable;
//Set height of one item
ComboBox1.ItemHeight := 20;
//load all bitmaps
Bitmap1 := TBitmap.Create;
Bitmap1.LoadFromFile('chem16.bmp');
Bitmap2 := TBitmap.Create;
Bitmap2.LoadFromFile('chip16.bmp');
Bitmap3 := TBitmap.Create;
Bitmap3.LoadFromFile('factry16.bmp');
Bitmap4 := TBitmap.Create;
Bitmap4.LoadFromFile('skylin16.bmp');
//assign bitmaps with item objects - caption of the items: Bitmap 1 - Bitmap 4
ComboBox1.Items.AddObject('Bitmap 1', Bitmap1);
ComboBox1.Items.AddObject('Bitmap 2', Bitmap2);
ComboBox1.Items.AddObject('Bitmap 3', Bitmap3);
ComboBox1.Items.AddObject('Bitmap 4', Bitmap4);
end;
procedure TForm1.ComboBox1DrawItem(Control: TWinControl; Index: Integer;
Rect: TRect; State: TOwnerDrawState);
var
Bitmap: TBitmap;
Offset: Integer;
begin
offset := 0;
with ComboBox1.Canvas do
begin
FillRect(Rect);
Bitmap := TBitmap(ComboBox1.Items.Objects[Index]);
if Bitmap <> nil then
begin
//copy bitmap to combobox coordinate
BrushCopy(Bounds(Rect.Left + 2, Rect.Top + 2, Bitmap.Width,
Bitmap.Height), Bitmap, Bounds(0, 0, Bitmap.Width,
Bitmap.Height), clred);
Offset := Bitmap.Width + 8;
end;
//Set a caption to each item
TextOut(Rect.Left + Offset, Rect.Top, Combobox1.Items[Index]);
end;
end;
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
//free all bitmap objects
bitmap1.Free;
bitmap2.Free;
bitmap3.Free;
bitmap4.Free;
end;
- Combobox中加载图片
- easyui中combobox为什么没有加载json
- java 中加载图片
- android中加载图片
- AdvStringGrid 中加载图片
- adapter中加载图片
- 【ExtJs】ExtJs下gridpanel中ComboBox数据动态加载问题
- easyui-combobox加载json中对象的属性
- easyui-combobox加载json中对象的属性
- easyui中combotree与combobox并用动态加载数据
- easyui-combobox加载json中对象的属性(转)
- easyui-combobox加载json中对象的属性
- 图片加载之前显示 加载中或者加载中图片
- 在ComboBox下拉框数据中显示图片
- C#中使comboBox下拉列表显示图片
- Ext combobox数据加载
- ComboBox自动加载值
- Easyui中的combobox加载
- 如何通过CMOS设置开机密码
- 下载FTP服务器上文件
- javascript 验证
- JavaScript解疑(2)
- 图像处理函数库
- Combobox中加载图片
- pku 3009 Curling 2.0 DFS+剪枝
- Tcp socket程序编写
- .net 应用程序域
- form之间的通信
- 用Delphi设计代理服务器
- JQuery基础之(一)JQuery简介
- CLASS CL_DD_DOCUMENT 显示ALV top_of_page
- oracle索引分类