如何在TvirualTree中内联绘制节点? [英] how to draw nodes inline in TvirualTree?
问题描述
我目前正在Tvirtualdrawtree
内使用绘画前的on绘制一些图像.这是我的绘图代码
I am currently drawing some images inside Tvirtualdrawtree
using on before paint. Here is my drawing code
procedure TForm2.VDTAniBeforeCellPaint(Sender: TBaseVirtualTree;
TargetCanvas: TCanvas; Node: PVirtualNode; Column: TColumnIndex;
CellPaintMode: TVTCellPaintMode; CellRect: TRect; var ContentRect: TRect);
var
Data: PAnimeData;
NewRect: TRect;
R: TRect;
begin
//
if not Assigned(Node) then
begin
exit;
end;
Data := VDTAni.GetNodeData(Node);
case Column of
0, 1 ,2, 3, 4, 5, 6, 7:
begin
TargetCanvas.Brush.Style := bsClear;
TargetCanvas.FillRect(CellRect);
NewRect := ContentRect;
NewRect.Left := NewRect.Left;
NewRect.Width := 55;
NewRect.Height := 55;
NewRect.Top := NewRect.Top + 2;
NewRect.Bottom := NewRect.Bottom;
if Column = 0 then
begin
with NewRect do
begin
TargetCanvas.StretchDraw( NewRect, Data.FObject.anmigraphic);
end;
end;
end;
绘制的图像是垂直出现的.我想水平显示它们,例如下面的图片
The images drawn comes vertically. I want to show them horizontally for example as in this following image
这是数据结构
type
TAnmiClass = class
private
Fanmigraphic : TGifImage;
public
property anmigraphic: TGifImage read Fanmigraphic write Fanmigraphic;
public
constructor Create;
destructor Destroy; override;
end;
type
PAnimeData = ^TAnimeData;
TAnimeData = record
FObject: TAnmiClass;
end;
推荐答案
您说的是
绘制的图像是垂直出现的
the images drawn comes vertically
那是因为只有在列为0时才绘制:
That is because you draw only if column is 0:
if Column = 0 then
begin
with NewRect do
begin
TargetCanvas.StretchDraw( NewRect, Data.FObject.anmigraphic);
end;
end;
您没有显示Data
的结构,但我怀疑每个Data
中都有几张图像.不能根据您的代码确定如何处理不同的图像,因此我仅以一对<
和>
中的伪代码形式显示该部分.
You did not show the structure of Data
but I suspect you have several images in each Data
. It can not be determined from your code, how you can address the different images, so I show that part only as pseudocode in a pair of <
and >
.
如果您想在不同的列中绘制不同的图像,建议使用以下内容:
If you want to draw different images in different columns, I suggest something like:
case Column of
0: TargetCanvas.StretchDraw( NewRect, Data.FObject.anmigraphic);
1: TargetCanvas.StretchDraw( NewRect, Data.FObject.<reference to second image>);
7: TargetCanvas.StretchDraw( NewRect, Data.FObject.<reference to eight image>);
end;
代替上面显示的代码.
这篇关于如何在TvirualTree中内联绘制节点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!