Thanks to netmaestro for this high performance timer code I snagged from elsewhere on the forum.
By capturing the #WM_MOUSEACTIVATE message, you can imitate the effect of a modal window by calling MessageBeep_(#MB_OK) along with FlashWindow(hWnd), which was my intent. It works great when you want to halt your main process until another one you just launched exits.
Code: Select all
;/ The default blink rate for Windows is four blinks with a 60 ms delay
Procedure FlashWindow(hWnd, Count=4, Timeout=60)
Protected Timer.TIMECAPS
Protected i
Protected OldStyle
;/ Set the window to a non-popup child so that it imitates a modal
;/ window and does not blink any borders around the currently
;/ highlighted control or other selection
OldStyle=GetWindowLongPtr_(hWnd,#GWL_STYLE)
SetWindowLongPtr_(hWnd,#GWL_STYLE,OldStyle&(~#WS_POPUP)|#WS_CHILD)
;/ Get timer capabilities
timeGetDevCaps_(@Timer,SizeOf(TIMECAPS))
;/ Reset timer resolution to lowest possible (usually 1)
timeBeginPeriod_(Timer\wPeriodMin)
;/ Blink the window by changing the foreground window between the
;/ target hWnd and the desktop
SetForegroundWindow_(GetDesktopWindow_())
For i=1 To Count
SetForegroundWindow_(hWnd)
Sleep_(Timeout)
SetForegroundWindow_(GetDesktopWindow_())
Sleep_(Timeout)
Next i
;/ Restore the old window style
SetWindowLongPtr_(hWnd,#GWL_STYLE,OldStyle)
;/ Reset timer resolution to normal
timeEndPeriod_(Timer\wPeriodMin)
EndProcedure