VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Capture the window under mouse into the form using GetDC,BitBlt,GetCursorPos and WindowFromPoint AP

by Karthikeyan (187 Submissions)
Category: Windows API Call/Explanation
Compatability: Visual Basic 5.0
Difficulty: Unknown Difficulty
Originally Published: Sat 17th February 2001
Date Added: Mon 8th February 2021
Rating: (1 Votes)

Capture the window under mouse into the form using GetDC,BitBlt,GetCursorPos and WindowFromPoint API

API Declarations


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

Rate Capture the window under mouse into the form using GetDC,BitBlt,GetCursorPos and WindowFromPoint AP



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
'Visit my Homepage at
'http://www.geocities.com/marskarthik
'http://marskarthik.virtualave.net
'Email: [email protected]

Download this snippet    Add to My Saved Code

Capture the window under mouse into the form using GetDC,BitBlt,GetCursorPos and WindowFromPoint AP Comments

No comments have been posted about Capture the window under mouse into the form using GetDC,BitBlt,GetCursorPos and WindowFromPoint AP. Why not be the first to post a comment about Capture the window under mouse into the form using GetDC,BitBlt,GetCursorPos and WindowFromPoint AP.

Post your comment

Subject:
Message:
0/1000 characters