#include once "window9.bi"

Function CreateCopyImageDesktop() As HBITMAP Export
	Dim as integer w,h
	Dim as HWND DSKWND = GetDesktopWindow()
	Dim as RECT r
	GetClientRect( DSKWND, Cast(LPRECT,@r) )
	w = r.right - r.left
	h = r.bottom - r.top
	Dim as HDC display_dc      = GetDC( DSKWND )
	dim as HDC bitmap_dc       = CreateCompatibleDC( display_dc )
	dim as HBITMAP bitmap      = CreateCompatibleBitmap( display_dc, w, h )
	dim as HGDIOBJ null_bitmap = SelectObject( bitmap_dc, bitmap )
	BitBlt( bitmap_dc, 0, 0, w, h, display_dc, 0, 0, SRCCOPY )
	Function=CopyImage(bitmap,IMAGE_BITMAP,0,0,LR_COPYRETURNORG)
	DeleteDC(display_dc) 
	DeleteDC(bitmap_dc)
	DeleteObject(Bitmap)
End Function

