Please help screenshot problums lazarus / 39-Graphics ---------------------------------------------------------------------- BenJones · 2011-07-17 15:21 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. Code: [Select]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; ---------------------------------------------------------------------- BlueIcaro · 2011-07-17 15:30 Did you tried this?: http://wiki.lazarus.freepascal.org/Developing_with_Graphics#Taking_a_s creenshot_of_the_screen /BlueIcaro ---------------------------------------------------------------------- typo · 2011-07-17 15:49 Replace this: Code: [Select]BitBlt(img.Canvas.Handle, 0, 0, img.Width, img.Height, dc, 0, 0, SRCCOPY); by this: Code: [Select]img.Picture.Bitmap.LoadFromDevice(dc); ---------------------------------------------------------------------- BenJones · 2011-07-17 16:26 Thanks both it now working.