How can I get a screenshot of only the desktop with icons, that is, so that the taskbar windows do not get into the screenshot, where is the start , but only the desktop with icons?

    2 answers 2

    Try:

    var DesktopBitmap: TBitmap; begin DesktopBitmap.GetDC(GetDesktopWindow); 

    See more here: Screen Shuffling with Delphi .

    • Writes unknown GetDC - delphikettle
    • With GetDC, the windows will still overlap the drawing. - delphikettle
    • one
      The point is to get the handle of the desktop. - michael
    • And the point ?! Here I get the handle, here I will copy the picture from the handle, but those windows that were on top of the desktop will still be there! - delphikettle
    • 2
      The compiler knows what GetDC is, just GetDC is a winapi function. It does not belong to the class TBitMap. It will be correct to just "GetDC (GetDesktopWindow);", after adding "windows" to the uses clause And where the function will return the value - choose for yourself. - teanYCH

    You can take a screenshot of any window using bitblt . This function, I think, is what you need. A screenshot of the desktop can be done like this:

     ... var bmp:Tbitmap; ... begin bmp := TbitMap.Create; bmp.Width := screen.Width; bmp.Height := screen.Height; bitblt(bmp.canvas.Handle, 0, 0, screen.Width, screen.Height, getdc(FindWindow('ProgMan', nil)), 0, 0, SRCCOPY); 
    • I tried, anyway, other windows get into the image! - delphikettle
    • Can't hit! FindWindow ('ProgMan', nil) is a desktop window. What is your windows version? - AseN
    • Windows XP! - delphikettle
    • Then try using this identifier: FindWindow ('Progman', 'Program Manager'); - AseN