procedure TChdaForm.TrVwCustomDrawItem(Sender: TCustomTreeView;
Node: TTreeNode; State: TCustomDrawState; var DefaultDraw: Boolean);
var
i:Integer;
Ds:TAdoDataSet;
begin
Ds:=TAdoDataSet.Create(nil);
try
Ds.Connection:=FCn;
for i:=0 to Node.Count-1 do
begin
Ds.CommandText:=' select isnull(f_color,0) as f_color,isnull(f_bold,0) as f_bold from '+TABLENAME+
' where '+BMFIELD+'='''+copy(Node.Item[i].Text,1,pos(' ',Node.Item[i].Text)-1)+''' and '+
' f_jb=(select isnull(f_jb,0)+1 from '+TABLENAME+' where '+BMFIELD+'='''+copy(Node.Text,1,pos(' ',Node.Text)-1)+''')';
Ds.open;
if Ds.Bof and Ds.Eof then Exit
else
begin
Ds.First;
with (Sender as TTreeview).Canvas.Font do
begin
Color:=Ds.FieldValues['f_color'];
case Ds.FieldValues['f_bold'] of
0: Style:=Style-[fsBold];
1: Style:=Style+[fsBold];
end;
end;
end;
Ds.Close;
end;
finally
Ds.Close;
Ds.Free;
end;
end;
Node: TTreeNode; State: TCustomDrawState; var DefaultDraw: Boolean);
var
i:Integer;
Ds:TAdoDataSet;
begin
Ds:=TAdoDataSet.Create(nil);
try
Ds.Connection:=FCn;
for i:=0 to Node.Count-1 do
begin
Ds.CommandText:=' select isnull(f_color,0) as f_color,isnull(f_bold,0) as f_bold from '+TABLENAME+
' where '+BMFIELD+'='''+copy(Node.Item[i].Text,1,pos(' ',Node.Item[i].Text)-1)+''' and '+
' f_jb=(select isnull(f_jb,0)+1 from '+TABLENAME+' where '+BMFIELD+'='''+copy(Node.Text,1,pos(' ',Node.Text)-1)+''')';
Ds.open;
if Ds.Bof and Ds.Eof then Exit
else
begin
Ds.First;
with (Sender as TTreeview).Canvas.Font do
begin
Color:=Ds.FieldValues['f_color'];
case Ds.FieldValues['f_bold'] of
0: Style:=Style-[fsBold];
1: Style:=Style+[fsBold];
end;
end;
end;
Ds.Close;
end;
finally
Ds.Close;
Ds.Free;
end;
end;
canvas.textout or else
Node: TTreeNode; State: TCustomDrawState; var DefaultDraw: Boolean);
var
i:Integer;
Ds:TAdoDataSet;
begin
Ds:=TAdoDataSet.Create(nil);
try
Ds.Connection:=FCn;
Ds.CommandText:=' select isnull(f_color,0) as f_color,isnull(f_bold,0) as f_bold from '+TABLENAME+
' where '+BMFIELD+'='''+copy(Node.Text,1,pos(' ',Node.Text)-1)+''' ';
Ds.open;
if Ds.Bof and Ds.Eof then Exit
else
begin
Ds.First;
with (Sender as TTreeview).Canvas.Font do
begin
Color:=Ds.FieldValues['f_color'];
case Ds.FieldValues['f_bold'] of
0: Style:=Style-[fsBold];
1: Style:=Style+[fsBold];
end;
end;
end;
finally
Ds.Close;
Ds.Free;
end;
end;
type
PRec = ^TRec;
TRec = record
ID: string;
Mc:string;
Color: Integer;
Bold:Integer;
Flag: ShortInt;
end;
...
var
ptr: Prec;
...
with (Sender as TTreeview).Canvas.Font do
begin
if Assigned(Node.Data) and (copy(Node.Text,1,pos(' ',Node.Text)-1)=PRec(Node.Data)^.ID) then
begin
if TrVw.Selected=Node then Color:=clWhite
else Color:= PRec(Node.Data)^.color;
case PRec(Node.Data)^.bold of
0: Style:=Style-[fsBold];
1: Style:=Style+[fsBold];
end;
end;
end;
...