如何在combox中加入图片!急急! 谢谢了 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 在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; 用第三方控件吧。如DevExpress等等要不就自己写他的OnDrawItem和OnMeasureItem事件。 想提高开发效率,请教如何写一个带参数的sql语句执行函数. 窗体标题栏的高度是否可以改变 关于stringGrid的Cell内容修改恢复及显示格式问题。。。 我的DELPHI软件的问题 我调用存储过程哪错了????? 怎么访问一个类的私有或者保护函数? 请教?! 问一下,大家现在都在用 Delphi 几点零的版本?? 6.0 还是 7.0 哪一个更稳定呢?? dajiashuo 关于日期转换的一个小小问题,请指教! 如何让编辑控件只接受数字? 介绍点学intraweb的书.
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;
如DevExpress等等要不就自己写他的OnDrawItem和OnMeasureItem事件。