;;; xtlang wrappers ;;;;;
(bind-func bitmap_from_window
  (lambda (window_name:i8*)
    (let ((hwnd (if (null? window_name)
                    (GetForegroundWindow)
                    (FindWindowA window_name null)))
          (rc (RECT 0 0 0 0)))
      (if (null? hwnd)
          (begin (println "could not find window named" (Str hwnd))
                 (tuple 0 0 3:i32 (cast null i8*)))
          (let ((PW_CLIENTONLY 1) ;; to grab full window set to 0
                (DIB_RGB_COLORS 0)
                (BI_RGB 0)
                (BI_PNG:i32 5)
                (res (GetClientRect hwnd rc)) ;; fills rc
                (hdcScreen (GetDC null))
                (info:BITMAPINFO* (alloc))
                (hdc (CreateCompatibleDC hdcScreen))
                (bmp (CreateCompatibleBitmap hdcScreen
                                             (- (right rc) (left rc))
                                             (- (bottom rc) (top rc)))))