Option Explicit
Private Declare Function GetDesktopWindow Lib "User32" () As Long
Private Declare Function GetWindowDC Lib "User32" (ByVal hwnd As Long) As Long
Private Declare Function Ellipse Lib "gdi32" (ByVal hdc As Long, ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long
Private Declare Function CreateSolidBrush Lib "gdi32" (ByVal crColor As Long) As Long
Private Declare Function CreatePen Lib "gdi32" (ByVal nPenStyle As Long, ByVal nWidth As Long, ByVal crColor As Long) As Long
Private Declare Function ReleaseDC Lib "User32" (ByVal hwnd As Long, ByVal hdc As Long) As Long
Private Declare Function SelectObject Lib "gdi32" (ByVal hdc As Long, ByVal hObject As Long) As Long
Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long
Private Declare Function GetAsyncKeyState Lib "User32" (ByVal vKey As Long) As Integer
Private Const PS_SOLID = 0
Private Const PS_INSIDEFRAME = 6
Const VK_Q = &H51
Private Sub Command1_Click()
Timer1.Interval = 1
End Sub
Private Sub Command2_Click()
Timer1.Interval = 0
End Sub
Private Sub Command3_Click()
End
End Sub
Private Sub Form_Load()
'If GetAsyncKeyState(VK_Q) Then Command1 = True
End Sub
Private Sub Timer1_Timer()
Dim DC As Long, hwnd As Long
Dim oBr As Long, Br As Long, oPn As Long, Pn As Long
Dim Color As Long ' Цвет
Dim X As Long, Y As Long, pWidth As Long ' Координаты толщина
Dim eX As Long, eY As Long
Color = vbRed
hwnd = GetDesktopWindow
DC = GetWindowDC(hwnd)
Br = CreateSolidBrush(Color)
Pn = CreatePen(PS_SOLID Or PS_INSIDEFRAME, 1, Color)
oBr = SelectObject(DC, Br)
oPn = SelectObject(DC, Pn)
' Задаем координаты и толщину
X = (Screen.Width / Screen.TwipsPerPixelX) / 2
Y = (Screen.Height / Screen.TwipsPerPixelY) / 2
pWidth = 4
eX = X - (pWidth / 2)
eY = Y - (pWidth / 2)
Ellipse DC, eX, eY, eX + pWidth, eY + pWidth
SelectObject DC, oPn
SelectObject DC, oBr
DeleteObject Br
DeleteObject Pn
ReleaseDC hwnd, DC
End Sub
Private Sub Timer2_Timer()
If GetAsyncKeyState(VK_Q) Then Command1 = True
End Sub