Hi all I been racking my head for over an hour with this bit of code, I am trying to make a program to capture a screen shot of my desktop. but my code seems to be produceing a black image., the only way it works if I use text out and write some text on it then it saves ok but i do not want to really do that can someone please have a look at my code incase i done something wrong thanks.
procedure TForm1.Button1Click(Sender: TObject);
var
dc: HDC;
img: TImage;
begin
//Get desktop window dc
dc := GetDc(GetDesktopWindow);
//Create the image
img := Timage.Create(self);
//set image width and height
img.Width := screen.Width;
img.Height := screen.Height;
//Hide form we do not want it included in our screeny
Form1.Visible := False;
sleep(500);
//Take screen shot of desktop window
BitBlt(img.Canvas.Handle, 0, 0, img.Width, img.Height, dc, 0, 0, SRCCOPY);
//img.Canvas.TextOut(90,0,'Screeny shot by ben');
//save the image
img.Picture.SaveToFile('c:\out\benny.bmp');
//Show the main form
Form1.Visible := True;
//Clear up time
ReleaseDc(GetDesktopWindow, dc);
img.Free;
end;