How to capture the entire screen (including the messagedlg dialog)?

Giganews Newsgroups
Subject:How to capture the entire screen (including the messagedlg dialog)?
Posted by: Enrico Pergola
Date:Thu, 29 Apr 2010

Hi
I have this bit of code that works partially in capturing the screen

procedure CaptureScreen(bmp: TBitMap);
var c: TCanvas;
    Desktop: HDC;
begin
  Desktop := GetDC(0);
  try
    bmp.PixelFormat := pf32bit;
    bmp.Width:=screen.Width;
    bmp.Height:=screen.Height;
    BitBlt(bmp.Canvas.Handle, 0, 0, bmp.Width, bmp.Height, Desktop, 0, 0, SRCCOPY);
finally
    ReleaseDC(0, Desktop);
end;
end;
This captures the screen, BUT not the dialog form (from messagedlg) that is shown in the middle of the screen: the dialog simply disappear in the bmp image.
Is there a way to capture every single pixel of the screen as it is seen by the user (i.e. including
everything drawn on the screen, in this case including the dialog form)?
Thanks
--
E.P.

Replies