Hi,
I have been using the following code to take screenshots of my app window for the last few years, with no problems. With Mac OS X 10.7 Lion however, the resulting image is all black.
procedure TfrmMain.CaptureScreenshot(var Image: TBitmap);
var
BMP: TBitmap;
ScreenDC: HDC;
begin
BMP := TBitmap.Create;
ScreenDC := GetDC(0);
BMP.LoadFromDevice(ScreenDC);
ReleaseDC(0, ScreenDC);
Image.SetSize(Self.Width, Self.Height);
Image.Canvas.CopyRect(Rect(0, 0, Self.Width - 1, Self.Height - 1), BMP.Canvas,
Rect(Self.Left, Self.Top, Self.Left + Self.Width - 1, Self.Top + Self.Height - 1 + 22));
BMP.Free;
end;It is the example code from the Lazarus Wiki on taking screenshots.
I have reported in the bug here:
http://bugs.freepascal.org/view.php?id=21845and it was mentioned that Apple broke this ability with 10.7, and that I can use LCL-CustomDrawn-Cocoa or a "new [method] which works only in 10.6+"
I was wondering if anyone had managed to get this to work and could provide me with some example code or pointers where to find the information for the technique.
I would prefer to keep my app compiled against the Carbon widgetset if I can.
Thank you,
Tristan