You have posted some code or a project that highlighted windows with the Spy++ style. I would be greatful if you could post it once again. :) Thanks in advance.
[Edited by Cbomb on 04-30-2000 at 06:17 PM]
Printable View
You have posted some code or a project that highlighted windows with the Spy++ style. I would be greatful if you could post it once again. :) Thanks in advance.
[Edited by Cbomb on 04-30-2000 at 06:17 PM]
Sure, no problem:
Code:'Add a Picturebox and a Timer Control to a Form
'
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Type POINTAPI
X As Long
Y As Long
End Type
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 GetWindowRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As Long
Private Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function ReleaseDC Lib "user32" (ByVal hwnd As Long, ByVal hdc As Long) As Long
Private Declare Function CreateRectRgn Lib "gdi32" (ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long
Private Declare Function InvertRgn Lib "gdi32" (ByVal hdc As Long, ByVal hRgn As Long) As Long
Private Declare Function CombineRgn Lib "gdi32" (ByVal hDestRgn As Long, ByVal hSrcRgn1 As Long, ByVal hSrcRgn2 As Long, ByVal nCombineMode As Long) As Long
Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer
Private Const RGN_XOR = 3
Private Const VK_LBUTTON = &H1
Private lRgn As Long
Private Sub Form_Load()
Timer1.Enabled = False
Timer1.Interval = 100
Screen.MouseIcon = LoadPicture("..\Common\Graphics\Cursors\Bullseye.cur")
Picture1 = Screen.MouseIcon
Picture1.AutoSize = True
End Sub
Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
lRgn = 0
Screen.MousePointer = vbCustom
Timer1.Enabled = True
End Sub
Private Sub Timer1_Timer()
Static lLastHwnd As Long
Dim tPOINT As POINTAPI
Dim tRECT As RECT
Dim lHwnd As Long
Dim lDC As Long
Dim lRgn1 As Long
Dim lRgn2 As Long
If GetAsyncKeyState(VK_LBUTTON) = 0 Then
Timer1.Enabled = False
lDC = GetDC(0)
Call InvertRgn(lDC, lRgn)
Screen.MousePointer = vbDefault
Exit Sub
End If
Call GetCursorPos(tPOINT)
lHwnd = WindowFromPoint(tPOINT.X, tPOINT.Y)
If lLastHwnd = lHwnd Then Exit Sub
lLastHwnd = lHwnd
lDC = GetDC(0)
Call InvertRgn(lDC, lRgn)
Call GetWindowRect(lHwnd, tRECT)
lRgn = CreateRectRgn(0, 0, 1, 1)
lRgn1 = CreateRectRgn(tRECT.Left, tRECT.Top, tRECT.Right, tRECT.Bottom)
lRgn2 = CreateRectRgn(tRECT.Left + 3, tRECT.Top + 3, tRECT.Right - 3, tRECT.Bottom - 3)
Call CombineRgn(lRgn, lRgn1, lRgn2, RGN_XOR)
Call InvertRgn(lDC, lRgn)
Call ReleaseDC(0, lDC)
End Sub