#include ONCE "window9.bi"

function CreateCopyImageDesktop () as Hbitmap export
	
	dim as GdkWindow ptr hWin = gdk_get_default_root_window()
	
	dim as gint iX , iY , iWidth , iHeight , iDepth
	
	if hWin then
		
		#ifdef __USE_GTK3__
		
		gdk_window_get_geometry(hWin, @iX, @iY, @iWidth, @iHeight)
		
		#else
		
		gdk_window_get_geometry(hWin, @iX, @iY, @iWidth, @iHeight , @iDepth)
		
		#endif

	EndIf
	
	if iWidth <> 0 andalso iHeight <> 0 then
		
		#ifdef __USE_GTK3__
		
		return gdk_pixbuf_get_from_window (hWin, 0, 0, iWidth, iHeight)
		
		#else
		
		return  gdk_pixbuf_get_from_drawable(NULL , hWin, gdk_colormap_get_system(), 0, 0, 0, 0, iWidth, iHeight)
		
		#endif

	EndIf	

End Function