RT。俺用了一句Inherited;好象不解决问题……在TListBox中。比如:
procedure TfrmHiQuery.lstResultDrawItem(Control: TWinControl;
Index: Integer; Rect: TRect; State: TOwnerDrawState);
var
sExecStat: AnsiString;
begin
with lstResult do
begin
sExecStat := ......;
if sExecStat = 'done' then
Canvas.Font.Color := clGreen;
end; inherited;
end;则运行后lstResult中什么也显示不出来了……
procedure TfrmHiQuery.lstResultDrawItem(Control: TWinControl;
Index: Integer; Rect: TRect; State: TOwnerDrawState);
var
sExecStat: AnsiString;
begin
with lstResult do
begin
sExecStat := ......;
if sExecStat = 'done' then
Canvas.Font.Color := clGreen;
end; inherited;
end;则运行后lstResult中什么也显示不出来了……
解决方案 »
- 自定义控件字体
- ******有关mxOutlookBarPro控件实现特定效果的问题******在线等
- 程序路径的问题!
- Webbrowser getAdjacentText 应该怎么使用?(难,高手进)
- 怎样寻找变量?
- 呜呜呜呜... VCLSkin有BUG!
- 怎么写这句SQL语句?
- 如何让query的指针指向某一条记录
- DELPHI有这样的控件....
- 关于oracle数据库查询中条件语句组合方式的问题
- fastreport报表中的一页显示word文件,该文件以image字段类型存储在sqlserver2000???
- delphi中调用html界面时,如何控制html中button的click事件!
Rect: TRect; State: TOwnerDrawState);
begin
if TListBox(Control).Items[index]='done' then
begin
TListBox(Control).Canvas.Font.Color:=clblack;
TListBox(Control).Canvas.TextRect(rect,rect.Left,rect.Top,TListBox(Control).Items[index]);
end
else
begin
TListBox(Control).Canvas.Font.Color:=clred;
TListBox(Control).Canvas.TextRect(rect,rect.Left,rect.Top,TListBox(Control).Items[index]);
end;
end;
procedure TForm1.ListBox1DrawItem(Control: TWinControl; Index: Integer;
Rect: TRect; State: TOwnerDrawState);
begin
//
end;
if Assigned(FOnDrawItem) then FOnDrawItem(Self, Index, Rect, State) else
begin
//下面是inherited部分
FCanvas.FillRect(Rect);
if Index < Count then
begin
Flags := DrawTextBiDiModeFlags(DT_SINGLELINE or DT_VCENTER or DT_NOPREFIX);
if not UseRightToLeftAlignment then
Inc(Rect.Left, 2)
else
Dec(Rect.Right, 2);
Data := '';
if (Style in [lbVirtual, lbVirtualOwnerDraw]) then
Data := DoGetData(Index)
else
Data := Items[Index];
DrawText(FCanvas.Handle, PChar(Data), Length(Data), Rect, Flags);
end;//从上面的代码看出 你要是重写了这个事件的话,你的代码就完全替代了inherited,就必须处理所有的情况
注:lstResult的Style已经设为lbOwnerDrawFixed。