如何实现一个OwnerDraw的具体例子,这个对高手应该很简单,可我很菜;
若有:发到:[email protected] 多谢
若有:发到:[email protected] 多谢
解决方案 »
- 有没有人知道QQ2011版的截图是怎么做出来的?整屏变灰之后,还能取得鼠标所在位置的窗体句柄,求思路!
- 这个BOM表的树状结构(treeview)怎么设计>数据表的结构如何设计?
- 第4个100啰
- 接收到消息LParam处理问题
- ShowModal的问题
- 这个报表问题,困饶我两天了!大家帮忙看看吧~~~~
- 谁有世纪飞扬(http://www.cstsoft.com.cn/china/index.html)的 Instrument VCL Pack 图形仪表控件的解密程序(急)
- 有几个问题想问相信很多搞DELPHI开发的都想知道.
- tquery地插入数据语句中有的参数是空值,如何写
- Who can help me!Thanks!
- 大家讨论一下关于TClientDataSet.ApplyUpdate的问题吧
- Delphi6编译的程序在Win98下不兼容的问题
http://www.csdn.net/Develop/Read_Article.asp?Id=3488
我有点看不懂哪个例子,可否一个简单的,示意就行! 比如对 ComboBox 的项目实现自绘;我真的初学者,谢谢!
谢谢!!
最好用ComBoBox 来实现
procedure TForm1.FormCreate(Sender: TObject);
var i: integer;
begin
for i:=0 to imagelist1.Count-1 do
Combobox1.Items.Add(inttostr(i));
end;在OnItemDraw事件画图标及文本
procedure TForm1.ComboBox1DrawItem(Control: TWinControl; Index: Integer;
Rect: TRect; State: TOwnerDrawState);
begin
Combobox1.Canvas.FillRect(Rect);
imagelist1.Draw(Combobox1.Canvas,Rect.left,rect.top,index);
combobox1.canvas.TextOut(rect.Left+20,rect.top, inttostr(index));
end;
var Height: Integer);
begin
//改变列的高度
Height := 24;
end;procedure TForm1.ComboBox1DrawItem(Control: TWinControl; Index: Integer;
Rect: TRect; State: TOwnerDrawState);
var
s:string;
rc:TRect;
begin
//获得Index所在的行的内容
s := (Control as TCombobox).Items.Strings[Index];
with (Control as TCombobox).Canvas do
begin
Brush.Color := clRed;
Brush.Style := bsSolid;
rc.Left := rect.Left;
rc.top := rect.Top;
rc.Right := rc.Left +24;
rc.Bottom := rc.top + 24;
//填充背景
ComboBox1.Canvas.FillRect(rc);
//输出文字
Brush.Style := bsClear;
Pen.Color := clBlue;
Pen.Style := psSolid;
ComboBox1.Canvas.TextOut(30,8,s);
end;
end;
在onDrawItem事件中,Control是要绘制的控件,Index是要绘制的控件的Item索引,rect是绘制区域,State是Item状态,基本上你只需要获得rect以及控件地canvas,然后在canvas上面自由绘制九可以了。