How to MakeScreenshot fullpage on Delphi

76 Views Asked by At

How to "MakeScreenshoot" FullPage on TListBox or VertScrollbox? I code like this, but the result not full. Some component not captured when i uses "Makescreenshoot".

vsReceipt is a TVertScrollBox, inside which there is lbReceipt (TListBox). I changed to using an anchor because sometimes the default component I use uses Align > Client. Then I adjusted the Height vsReceipt against lbReceipt using lbReceipt.ContentBounds.Size.cy + 24; When I use the "MakeScreenshoot" function, some parts are not captured.

    var ABitmap : TBitmap;
    var OldHeight := vsReceipt.Height;
    var AAlign := vsReceipt.Align;
    var AAnchor := vsReceipt.Anchors;
    try
      vsReceipt.Align := TAlignLayout.None;
      vsReceipt.Anchors := [TAnchorKind.akLeft, TAnchorKind.akTop, TAnchorKind.akRight];
      vsReceipt.Height := lbReceipt.ContentBounds.Size.cy + 24;
      ABitmap := lbReceipt.MakeScreenshot;
      if Assigned(ABitmap) then begin
        ABitmap.SaveToFile('bfaprintreceipt.png');
        ABitmap.DisposeOf;
      end;
    finally
      vsReceipt.Align := AAlign;
      vsReceipt.Height := OldHeight;
      vsReceipt.Anchors := AAnchor;
    end;

And the result like this

Result

I want result like this

enter image description here

0

There are 0 best solutions below