Date: 02-16-2022
Return to Index
created by gbSnippets
'Compilable Example: (Jose Includes)
#Compiler PBWin 9, PBWin 10
#Compile EXE
#Dim All
%Unicode=1
#Include "Win32API.inc"
%ID_Timer = 500
Global hDlg,hDC As Dword
Function PBMain () As Long
Dialog New Pixels, 0, "Locate Cursor",,, 175,100, %WS_OverlappedWindow To hDlg
Control Add Button, hDlg, 300, "Start", 10,10,100,20
Control Add Button, hDlg, 301, "Stop", 10,40,100,20
Dialog Show Modal hDlg, Call DlgProc
End Function
CallBack Function DlgProc() As Long
Local pt As PointAPI
Select Case Cb.Msg
Case %WM_Timer
Static Flag As Long
Flag = Flag Xor 1
If Flag Then
hDC = GetDC(%Null)
'save original pen/brush
Local origPen, origBrush As Dword
origPen = SelectObject(hdc, GetStockObject(%Null_Brush))
origBrush = SelectObject(hdc, GetStockObject(%DC_Pen))
SetDCPenColor(hdc, %Red)
GetCursorPos pt
Ellipse(hdc,pt.x-30,pt.y-30,pt.x+30,pt.y+30) 'left/top/right/bottom
'restore original pen/brush
SelectObject(hDC,origPen)
SelectObject(hDC,origBrush)
ReleaseDC(%Null, hDC)
Else
RedrawWindow %NULL, ByVal %NULL, ByVal %NULL, %RDW_INVALIDATE Or %RDW_UPDATENOW Or %RDW_ALLCHILDREN
End If
Case %WM_Command
Select Case Cb.Ctl
Case 300
SetTimer(Cb.Hndl, %ID_Timer, 250, ByVal %NULL) 'uses callback messages
Case 301
KillTimer Cb.Hndl, %ID_Timer
RedrawWindow %NULL, ByVal %NULL, ByVal %NULL, %RDW_INVALIDATE Or %RDW_UPDATENOW Or %RDW_ALLCHILDREN
End Select
End Select
End Function
'gbs_01027
'Date: 03-10-2012
http://www.garybeene.com/sw/gbsnippets.htm