Platform: Laz 1.8.4, FPC 3.0.4, Dev OS: Windows Server 2016 Target OS: Same as Dev OS.
Background: I have a TPanel with two TImage components on it, displaying two photos (one in each TImage)
Goal: I want to copy to clipboard, the full contents of the TPanel with both images, into one image that I can then paste into MS Paint
So far, I have found only this:
var
r : Trect;
ScreenCanvas: TCanvas;
bmp: TBitmap;
begin
r := pnlPrcClnFotoVwrLftRgtContainer.BoundsRect;
MapWindowPoints( Handle, HWND_DESKTOP, r, 2 );
ScreenCanvas := TCanvas.Create;
try
ScreenCanvas.Handle := GetDC( 0 );
try
bmp:= TBitmap.Create;
Try
bmp.Width := Panel1.Width;
bmp.Height:= Panel1.Height;
bmp.Canvas.CopyRect( bmp.Canvas.ClipRect, Screencanvas, r );
Clipboard.Assign(bmp);
Finally
bmp.free;
End;
finally
ReleaseDC( 0, ScreenCanvas.Handle );
ScreenCanvas.Handle := 0;
End;
finally
ScreenCanvas.Free;
end;
end;
Problem: MapWindowPoints is not recognized by Lazarus. Will it cause problems if I simply include the unit
pmwin
in my Lazarus USES clause?
Alternatively, is there a better, simpler, "Lazarus" way of doing this?