The following function uses a Win32 function to draw a rectangle that will highlight a given object using the object coordinates
' Declare necessary APIs
Extern.Declare micHwnd, "GetDesktopWindow", "User32.DLL", "GetDesktopWindow"
Extern.Declare micULong, "GetWindowDC", "User32.DLL", "GetWindowDC", micHwnd
Extern.Declare micInteger, "ReleaseDC", "User32.DLL", "ReleaseDC", micHwnd, micULong
Extern.Declare micULong, "CreatePen", "Gdi32.DLL", "CreatePen", micInteger, micInteger, micDword
Extern.Declare micInteger, "SetROP2", "Gdi32.DLL", "SetROP2", micULong, micInteger
Extern.Declare micULong, "SelectObject", "Gdi32.DLL", "SelectObject", micULong, micULong
Extern.Declare micULong, "DeleteObject", "Gdi32.DLL", "DeleteObject", micULong
Extern.Declare micULong, "GetStockObject", "Gdi32.DLL", "GetStockObject", micInteger
Extern.Declare micULong, "Rectangle", "Gdi32.DLL", "Rectangle", micULong, micInteger, micInteger, micInteger, micInteger
Function HighlightRect (X, Y, W, H, Times)
hDC = Extern.GetWindowDC (Extern.GetDesktopWindow)
' Create a three pixel wide pen
hPen = Extern.CreatePen (6, 3, RGB(0, 0, 0)) ' PS_INSIDEFRAME, 3 , RGB(0, 0, 0)
Extern.SetROP2 hDC, 6 ' hDC, R2_NOT
Extern.SelectObject hDC, Extern.GetStockObject (5) ' NULL_BRUSH
Extern.Rectangle hDC, X, Y, X + W, Y + H
Extern.ReleaseDC Extern.GetDesktopWindow, hDC
No comments:
Post a Comment