#include ONCE "window9.bi"

function  CreateCopyImageWindowClient (hWin as any ptr , iFlag as Long = 0) as Hbitmap export
	
	dim as Long iX , iY , iWidth , iHeight , iDepth
	
	if hWin andalso iFlag =  1 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
		
	elseif	hWin andalso iFlag =  0 then
	
		#ifdef __USE_GTK3__
		
		gdk_window_get_geometry(gtk_widget_get_window(hWin), @iX, @iY, @iWidth, @iHeight)
		
		#else
		
		gdk_window_get_geometry(gtk_widget_get_window(hWin), @iX, @iY, @iWidth, @iHeight, @iDepth)
		
		#endif

	EndIf
	
	if iFlag = 0 then
	
		#ifdef __USE_GTK3__
	
		return gdk_pixbuf_get_from_window (gtk_widget_get_window(hWin), 0, 0, iWidth, iHeight)
		
		#else
		
		return  gdk_pixbuf_get_from_drawable(NULL , gtk_widget_get_window(hWin), gdk_colormap_get_system(), 0, 0, 0, 0, iWidth, iHeight)
	
		#endif
	
	else
		
		#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