View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0021845LazarusLCLpublic2012-04-23 14:482013-10-04 19:47
ReporterTristan Linnell 
Assigned To 
PlatformOSOS Version
Product Version0.9.30.4Product Build 
Target VersionFixed in Version 
Summary0021845: Screenshot with GetDC not working on Mac OS X Lion 10.7
DescriptionI 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);
  BMP: TBitmap;
  ScreenDC: HDC;
  BMP := TBitmap.Create;
  ScreenDC := GetDC(0);
  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));


It is the example code from the Lazarus Wiki on taking screenshots.

Thank you,
TagsNo tags attached.
Fixed in Revision
Attached Files

- Relationships

-  Notes
Felipe Monteiro de Carvalho (developer)
2012-04-29 11:38

Yes, Apple broke our previous way of doing screenshots and introduced a new one which works only in 10.6+

LCL-CustomDrawn-Cocoa already uses the new method and it works fine.
Tristan Linnell (reporter)
2012-05-16 11:25

Is there any example code for the new technique anywhere?
Hans Luijten (reporter)
2013-10-04 19:47

Bug remains (Laz. 10.0.12) - even though it's Apple to blame.

A fix (as suggested in Lazarus Forums: [^]) would be nice to be able to keep working cross platform.

Sample code would be a nice temporary work around but I couldn't get the LCL-CustomDrawn-Cocoa to work (probably my lack of knowledge).

- Issue History
Date Modified Username Field Change
2012-04-23 14:48 Tristan Linnell New Issue
2012-04-23 14:48 Tristan Linnell Widgetset => Carbon
2012-04-29 11:38 Felipe Monteiro de Carvalho Note Added: 0059094
2012-05-16 11:25 Tristan Linnell Note Added: 0059643
2013-10-04 19:47 Hans Luijten Note Added: 0070536

MantisBT 1.2.12[^]
Copyright © 2000 - 2012 MantisBT Group
Powered by Mantis Bugtracker