procedure TForm1.ComboBox1DrawItem(Control: TWinControl; Index: Integer;
Rect: TRect; State: TOwnerDrawState);
var
Bitmap: TBitmap;
Offset: Integer;
begin
with (Control as TComboBox).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;
请解释一下
with (Control as TComboBox).Canvas do 这一句中 为什么要这样做啊 和
procedure TForm1.ComboBox1DrawItem(Control: TWinControl; Index: Integer;
里的 Control: TWinControl 的关系是什么
Rect: TRect; State: TOwnerDrawState);
var
Bitmap: TBitmap;
Offset: Integer;
begin
with (Control as TComboBox).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;
请解释一下
with (Control as TComboBox).Canvas do 这一句中 为什么要这样做啊 和
procedure TForm1.ComboBox1DrawItem(Control: TWinControl; Index: Integer;
里的 Control: TWinControl 的关系是什么
解决方案 »
- 怎么用Delphi实现监视sqlserver2000 insert update ? 触发器?
- 请问如何获得Edit的名字?
- fastReport 横向打印BUG 标签怪问题,很急!!!!
- 三层?? 郁闷,请大家指点米精
- 请问win95支持DecodeDate么?请帮忙。
- 一个动态产生DBEdit控件的绑定问题!!
- 哎,人气越来越差,把分散掉算了!(2)
- 来者有分!!!!!!!!!
- 我想插入平均值的列,为什么总提示我“Select one or more columns or computes prior to selecting this option"
- 各位大侠 请问在form 上可以既画前景又画背景吗(在同一区域)
- 请问这样会不会内存泄漏或其它问题?
- DELPHI5的资源编辑器用起来很不爽,有没有好点的?
TWinControl可以存储TComboBox对象
但TWinControl的机能有限, 调用美女还是要TComboBox出马
有问题请发信息到我的E-mail:[email protected]
begin
……
end;中间的属性基本都是(Control as TComboBox).Canvas 的属性,这样做避免重复录入,少打字
:OControl必须是一个TComboBox的实例,才能这样引用
Control as TComboBox
如果你要写一个通用函数的话,这个语句是最好的,多个TCombobox不修改代码也可以通用。