Visual Basic Programming Code Examples Visual Basic > Code Snippets Code Examples Capture window under mouse Capture window under mouse Private Const SRCCOPY = &HCC0020 Private Type POINTAPI X As Long Y As Long End Type Private Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long Private Declare Function BitBlt Lib "gdi32" (ByVal hDestDC As Long, ByVal X As Long, ByVal Y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As Long) As Long Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long Private Declare Function WindowFromPoint Lib "user32" (ByVal xPoint As Long, ByVal yPoint As Long) As Long Private Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal X As Long, ByVal Y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long Private Sub Form_Load() Timer1.Enabled = True Timer1.Interval = 400 SetWindowPos Me.hwnd, -1, 0, 0, 0, 0, 1 Form1.AutoRedraw = True End Sub Private Sub Timer1_Timer() Dim xy As POINTAPI Dim wnd As Long, wndc As Long GetCursorPos xy wnd = WindowFromPoint(xy.X, xy.Y) wndc = GetDC(wnd) Form1.Refresh BitBlt Me.hdc, 0, 0, Screen.Width, Screen.Height, wndc, 0, 0, SRCCOPY End Sub