DFPITC
asked on
Setting Form to Hide using Deactivate for VB.Net app
I am developing a form with a tray icon.
I want it so you can click on the tray icon to show the form or hide the form.
I also want it so if you click away from the form (eg: the desktop) it also hides the form.
Now, using the form event "deactivate" I can put a Me.Hide() to hide the form.
The tray icon click event has code like the following:
How to I tell the deactivate event not to run me.Hide() if the tray icon is clicked. (preferrable)
Alternatively, how do I tell the tray icon click event not to run the code if deactivate just hid the form
(i'd rather not use timers)
When the form is active, looking at the event order (with a debug window) the event chain is:
I want it so you can click on the tray icon to show the form or hide the form.
I also want it so if you click away from the form (eg: the desktop) it also hides the form.
Now, using the form event "deactivate" I can put a Me.Hide() to hide the form.
The tray icon click event has code like the following:
if Me.Visible Then
Me.Hide()
Else
Me.Show()
Me.Activate()
End If
The problem I have is, when the form is visible, and I click the tray icon, the deactivate event fires, which hides the form, THEN the form click event fires which reactivates it.How to I tell the deactivate event not to run me.Hide() if the tray icon is clicked. (preferrable)
Alternatively, how do I tell the tray icon click event not to run the code if deactivate just hid the form
(i'd rather not use timers)
When the form is active, looking at the event order (with a debug window) the event chain is:
deactivate
tray mousedown
tray mouseup
tray mouseclick
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.