vb 求大神?
发布网友
发布时间:2024-10-21 03:44
我来回答
共1个回答
热心网友
时间:2024-11-19 09:32
建议你下载一个叫“spyxx-vb”的源码,它实现就是你所说的所有功能,这个源码你可以直接拿来使用,很好用。
我摘录一下,你要的那部分功能
Private Sub tmr_Timer() Dim pnt As POINTAPI Dim newPen&, oldPen& 'Dim SnapHwnd& Dim DeskHwnd&, DeskDC& Dim oldRop2& DeskHwnd& = GetDesktopWindow() '取得桌面句柄 DeskDC& = GetWindowDC(DeskHwnd&) '取得桌面设备场景 ' oldRop2& = SetROP2(DeskDC&, 10) GetCursorPos pnt '取得鼠标坐标 SnapHwnd = WindowFromPoint(pnt.X, pnt.Y) '取得鼠标指针处窗口句柄 GetWindowRect SnapHwnd, rc '获得窗口矩形 If rc.Left < 0 Then rc.Left = 0 If rc.Top < 0 Then rc.Top = 0 If rc.Right > Screen.Width / 15 Then rc.Right = Screen.Width / 15 If rc.Bottom > Screen.Height / 15 Then rc.Bottom = Screen.Height / 15 newPen& = CreatePen(0, 3, &H0) '建立新画笔,载入DeskDC oldPen& = SelectObject(DeskDC, newPen) Rectangle DeskDC, rc.Left, rc.Top, rc.Right, rc.Bottom '在指示窗口周围显示闪烁矩形 Sleep tmr.Interval '设置闪烁时间间隔 Rectangle DeskDC, rc.Left, rc.Top, rc.Right, rc.Bottom SetROP2 DeskDC, oldRop2 SelectObject DeskDC, oldPen DeleteObject newPen ReleaseDC DeskHwnd, DeskDC: DeskDC = 0End Sub