#Include once "window9.bi"

function CreateCopyImageRect(ByVal window_ As HWND,ByVal x As Integer,ByVal y As Integer,ByVal width_ As Integer,ByVal height_ As Integer) As HBITMAP Export
  Dim as integer w,h
  Dim as HWND DSKWND = window_
  w = width_ 
  h = height_ 
  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, x, y, srcCOPY )
  Function=CopyImage(bitmap,IMAGE_BITMAP,0,0,LR_COPYRETURNORG)
  DeleteDC(display_dc)
  DeleteDC(bitmap_dc)
  DeleteObject(Bitmap)
End Function
