如何在ComboBox中加入图片? 我想在ComboBox中加入下拉图片,如何做?请高手指教。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 ComboBox中不行试试其他的控件 在formshow中初始化combobox中的图片: combobox.Clear; file:= 'c:\bmp\'; filefound:=FindFirst(file+'*.bmp',faAnyFile,SearchRec); while filefound=0 do begin if (SearchRec.Name<>'.')and(SearchRec.Name<>'..')and (SearchRec.Attr<>faDirectory) then begin <font color =#ff0000><strong>Bitmap := TBitmap.Create; </font></strong> bitmap.LoadFromFile(file+SearchRec.Name); //var bitmap: TBitmap;已经创建 ComboBox.Items.AddObject(SearchRec.Name, bitmap); filefound:=FindNext(SearchRec); end; end; findclose(SearchRec);在ondrawitem事件中处理图像显示:procedure comboboxDrawItem(Control: TWinControl; Index: Integer; Rect: TRect; State: TOwnerDrawState);var Bitmap: TBitmap; destrect, sourcerect: TRect;begin with (Control as TComboBox).Canvas do begin FillRect(Rect); Bitmap := TBitmap(ComboBox.Items.Objects[Index]); //显示图形 if Bitmap <> nil then begin destrect:=bounds(Rect.Left,Rect.Top,32,32); sourcerect:=bounds(0, 0, 32,32); BrushCopy(destrect, Bitmap, sourcerect, clWhite); Offset := Bitmap.width; end; TextOut(Rect.Left + Offset +5, Rect.Top, Combobox.Items[Index]); end;end; 一个应该有难度的问题(折叠菜单) 手写程序不能在WORD里面输入字符,请求帮助,在其他程序如QQ里面都可以。百思不得其解 请求一个ord的问题,为什么每次返回值不一样???? CxPivotGrid难题 MM的病终于好了,可以天天见面了,高兴... (2) 关于后台监控程序的问题,请高手帮忙 高分:在窗口中使用鼠标右击,要找到相应控件名 如何在程序内部发送email?--不调用outlook 等软件 ado的一个问题 好看的笑话,笑死俺了!问题:listview如何加入图片? 用友问题 征求API函数SHFileOperation详解
combobox.Clear;
file:= 'c:\bmp\';
filefound:=FindFirst(file+'*.bmp',faAnyFile,SearchRec);
while filefound=0 do
begin
if (SearchRec.Name<>'.')and(SearchRec.Name<>'..')and (SearchRec.Attr<>faDirectory) then
begin
<font color =#ff0000><strong>Bitmap := TBitmap.Create; </font></strong>
bitmap.LoadFromFile(file+SearchRec.Name); //var bitmap: TBitmap;已经创建
ComboBox.Items.AddObject(SearchRec.Name, bitmap);
filefound:=FindNext(SearchRec);
end;
end;
findclose(SearchRec);在ondrawitem事件中处理图像显示:
procedure comboboxDrawItem(Control: TWinControl; Index: Integer;
Rect: TRect; State: TOwnerDrawState);
var Bitmap: TBitmap;
destrect, sourcerect: TRect;
begin
with (Control as TComboBox).Canvas do
begin
FillRect(Rect);
Bitmap := TBitmap(ComboBox.Items.Objects[Index]); //显示图形
if Bitmap <> nil then
begin
destrect:=bounds(Rect.Left,Rect.Top,32,32);
sourcerect:=bounds(0, 0, 32,32);
BrushCopy(destrect, Bitmap, sourcerect, clWhite);
Offset := Bitmap.width;
end;
TextOut(Rect.Left + Offset +5, Rect.Top, Combobox.Items[Index]);
end;
end;