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, hOverlay,hDC As Dword
Function PBMain () As Long
Dialog New Pixels, 0, "Timer",,, 150,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_InitDialog
Dialog New Pixels, 0, "Overlay",0,0,60,60, %WS_Popup Or %WS_Visible, %WS_Ex_Layered To hOverlay
Dialog Show Modeless hOverlay
SetLayeredWindowAttributes(hOverlay, %Red, 255, %LWA_ALPHA or %LWA_Colorkey)
Case %WM_Timer
Static Flag,Counter As Long
Flag = Flag Xor 1
If Flag Then
hDC = GetDC(hOverlay)
GetCursorPos pt
Dialog Set Loc hOverlay, pt.x-30, pt.y-30
'save original pen/brush
Local origPen, origBrush As Dword
origPen = SelectObject(hdc,GetStockObject(%DC_Pen))
origBrush = SelectObject(hdc,GetStockObject(%DC_Brush))
SetDCPenColor(hdc, %Red)
SetDCBrushColor(hdc, %Red)
Rectangle(hdc,0,0,60,60) 'left/top/right/bottom
SetDCPenColor(hdc, %Blue)
Ellipse(hdc,0,0,60,60) 'left/top/right/bottom
'restore original pen/brush
SelectObject(hDC,origPen)
SelectObject(hDC,origBrush)
ReleaseDC(hOverlay, hDC)
Else
Dialog Redraw hOverlay
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
Dialog Redraw hOverlay
End Select
End Select
End Function
'gbs_01028
'Date: 03-10-2012
http://www.garybeene.com/sw/gbsnippets.htm