1

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

enter image description here

Here is the data structure

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;
Ian Boyd
  • 246,734
  • 253
  • 869
  • 1,219
Vlark.Lopin
  • 762
  • 10
  • 21
  • There's nothing built in to that control to allow that. There used to be a library by Jim Kueneman, Virtual Shell Tools, providing a virtual explorer tree based on the virtual tree view, and it implemented all the familiar icon layouts supported by traditional list-view controls. You might find it helpful, if you can find it anymore. – Rob Kennedy Aug 07 '16 at 03:01
  • i know it cannot be done with tree view property thats why i created 8 columns to draw them side by side but the issue each column is got duplicated with the same image until its draw the second node – Vlark.Lopin Aug 07 '16 at 08:07

1 Answers1

1

You said:

the images drawn comes vertically

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;

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;

instead of the code shown above.

Tom Brunberg
  • 20,312
  • 8
  • 37
  • 54
  • i added the data structure to the question i dont have eight images i just wanted to draw each node side by side – Vlark.Lopin Aug 07 '16 at 08:42
  • @Vlark.Lopin Perhaps you should rearrange your images, 8 per node. There is no apparent way to draw 8 nodes side by side in columns. – Tom Brunberg Aug 07 '16 at 10:55
  • so i should get ride of columns ? and how to re arrange that image per node – Vlark.Lopin Aug 07 '16 at 11:32
  • No, you keep the columns. You store 8 images in a node's data, say in an array. Then you use the `Column` as an index to that array. – Tom Brunberg Aug 07 '16 at 12:19
  • i really don't know how to do that in coding – Vlark.Lopin Aug 07 '16 at 12:58
  • You don't know how to do what in coding? Storing 8 images in an array in a nodes data or using the `Column` argument of `OnBeforeCellPaint` as an index? – Tom Brunberg Aug 07 '16 at 13:17
  • This list will not have only 8 images it could be 100 or 1000. listing the images as 8 at one line it was an example that if i have 100 images i wanted to store them side by side and i tried to achieve the drawing side by side but i was wrong . what i dont know is your suggestion Storing 8 images in array what is that or using the column as long as this is an answer or attempt to get the close idea this answer should be edited by showing coding example . because case of columns by drwaing values to each columns wasn't really answer . – Vlark.Lopin Aug 07 '16 at 13:33
  • @Vlark.Lopin The point is that TVirtualDrawTree doesn't support drawing **nodes** beside each other and as free flow filling up to the right and continuing on a new line etc. I assume that sometimes the width is sufficient for only six (or whatever) images, so you will have different number of images per row depending on window width, image sizes etc. Whatever number of images you have (say 80 for the example), if you have determined that eigth will fit in a row, then divide the 80 images into 10 nodes, each having 8 images and each image displayed in its own column. (continues...) – Tom Brunberg Aug 07 '16 at 21:52
  • (...continuation) This is standard for the VT and supports scrolling (which your initial idea doesn't). If you meet obstacles with this please post a new question. – Tom Brunberg Aug 07 '16 at 21:53