这是一个带图标的组合框,通过编译但是图标显示不出来阿~~
请帮我看看怎么回事情~~谢谢
unit unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
ComboBox1: TComboBox;
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);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;
MyBitmap1,Mybitmap2:TBitMap;
implementation{$R *.dfm}procedure TForm1.FormCreate(Sender:TObject);
begin
MyBitmap1:=TBitmap.Create;
MyBitmap1.LoadFromFile('3.bmp');
MyBitmap2:=TBitmap.Create;
MyBitmap2.LoadFromFile('4.bmp');
ComboBox1.Items.AddObject('Bitmap1', MyBitmap1);
ComboBox1.Items.AddObject('Bitmap2', MyBitmap2);
end;procedure TForm1.FormClose(Sender:TObject;var Action:TCloseAction);
begin
MyBitmap1.Free;
MyBitmap2.Free;
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
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; TextOut(Rect.Left+Offset,Rect.Top,ComboBox1.Items[Index]);
end;
end; procedure TForm1.ComboBox1MeasureItem(Control:TWinConTrol;
Index:Integer;var Height:Integer);
begin
height:=100;
end;
end.
请帮我看看怎么回事情~~谢谢
unit unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
ComboBox1: TComboBox;
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);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;
MyBitmap1,Mybitmap2:TBitMap;
implementation{$R *.dfm}procedure TForm1.FormCreate(Sender:TObject);
begin
MyBitmap1:=TBitmap.Create;
MyBitmap1.LoadFromFile('3.bmp');
MyBitmap2:=TBitmap.Create;
MyBitmap2.LoadFromFile('4.bmp');
ComboBox1.Items.AddObject('Bitmap1', MyBitmap1);
ComboBox1.Items.AddObject('Bitmap2', MyBitmap2);
end;procedure TForm1.FormClose(Sender:TObject;var Action:TCloseAction);
begin
MyBitmap1.Free;
MyBitmap2.Free;
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
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; TextOut(Rect.Left+Offset,Rect.Top,ComboBox1.Items[Index]);
end;
end; procedure TForm1.ComboBox1MeasureItem(Control:TWinConTrol;
Index:Integer;var Height:Integer);
begin
height:=100;
end;
end.
解决方案 »
- 关于FastReport
- 怎么样能判断数据库中是否有自己需要的库存在呢
- 方法引用问题 在线等待望朋友们可以给于解答thank
- 有关dbgrideh的一个问题
- 请教:两个不同的ADO连接中的数据表是否可以互相连接?
- 在Windows2003下怎么见虚拟目录!
- 怎样实现WebBrowser中另存为对话框功能?
- ?有那位高手知道如何生成truetype字体*.ttf格式文件,最好有源码,久问无应答(
- 请教:如何实现数字货币到英文大写的转换,问了很多次,没人能解???
- 关于循环语句 while
- 不好意思另开一贴问 clientdateset保存xml 100分不够再+
- 急急...Delphi中如何实现在运行时动态增加控件呢?
MyBitmap1.LoadFromFile('3.bmp');
MyBitmap2:=TBitmap.Create;
MyBitmap2.LoadFromFile('4.bmp');其他属性呢?visible top left 等等