by Natter » Tue Apr 05, 2016 1:33 pm
hDeskTop:=GetWindowDc(FindWindow(...))
siz:=GetWndRect(hDeskTop)
hDC := CreateCompatibleDC( hDeskTop )
hBmp := CreateCompatibleBitMap( hDC, siz[4]-siz[2], siz[3]-siz[1])
hOldBmp:=SelectObject(hDc, hBmp)
BitBlt(hDc, 0, 0, siz[4]-siz[2], siz[3]-siz[1], hDeskTop, 0, 0, 13369376) //SCRCOPY
oImg:=GdiBmp():New()
oImg:hBmp:=Gdip_FromHBitmap(hBmp,, HasAlpha(hBmp))
oImg:Save("test.bmp")
SelectObject(hDc, hOldBmp)
DeleteDC(hDc)
DeleteObject(hOldBmp)
ReleaseDC(0, hDeskTop)
It works and I get a screenshot of a window to a bitmap file, but only in black and white. How can I get color bitmap ?