x_terminat_or_3
asked on
LostFocus event for borderless form
Hi all
I'm making an app that displays a topmost borderless form. I want to hide the form if it loses focus, but since it's borderless, it seems no LostFoucs, DeActivate events are fired. Also, I tried the subclassing with GetWindowProc, and the message isn't fired there as well.
How to detect lostfocus for borderless forms?
With kind regards
Ramses (ps, pts will be raised to max if I get a working reply within 3hrs)
I'm making an app that displays a topmost borderless form. I want to hide the form if it loses focus, but since it's borderless, it seems no LostFoucs, DeActivate events are fired. Also, I tried the subclassing with GetWindowProc, and the message isn't fired there as well.
How to detect lostfocus for borderless forms?
With kind regards
Ramses (ps, pts will be raised to max if I get a working reply within 3hrs)
Ignore that last comment from me. I should have tested it first.
Never mind - back to the drawing board...
Never mind - back to the drawing board...
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks. Stupid me for not figuring out myself!
Place a timer on your window
In declarations:
Private Declare Function GetForegroundWindow Lib "user32" () As Long
Then for your timer...
Private Sub Timer1_Timer()
Static blnGotFocus as Boolean
Timer1.Enabled = False
if not blnGotFocus = GetForegroundWindow = Me.hWnd Then
blnGotFocus = Not blnGotFocus
if blnGotFocus Then
cls
print "I've got focus"
Else
cls
print "I've got focus"
End If
End If
Timer1.Enabled = True
End Sub