T
Tony Vitonis
Hello. I've written an app that I want to "live" in the system tray.
I want it to start up with just a tray icon showing, and if the user
selects "Settings..." from the icon's context menu, to display a
window that will allow him to change settings. When he hits "OK" or
"Cancel", the window should hide again.
At first, I tried putting a "Me.Visible = False" in the form's Load
event, but apparently that code runs before the command can be
effective. I moved the line to the Activate event, which hid the form
at startup just fine; however, when I tried to set Me.Visible to True
in another part of the code, I saw the Form.Activate event running
again, re-hiding the form.
On my second try, I created a form-level variable, WindowVisible, put
Me.Visible = WindowVisible in the Form.Activate event, and set
WindowVisible in the code where necessary. This works fine, but it
seems a little kludgy to me, as if I'm trying to work around something
I don't understand.
My questions are:
1. Is there a better way to hide a form at startup?
2. Is there a better way to approach the whole problem?
3. Where can I read a summary of the order in which form events are
raised, and for what reasons?
Thanks a lot.
I want it to start up with just a tray icon showing, and if the user
selects "Settings..." from the icon's context menu, to display a
window that will allow him to change settings. When he hits "OK" or
"Cancel", the window should hide again.
At first, I tried putting a "Me.Visible = False" in the form's Load
event, but apparently that code runs before the command can be
effective. I moved the line to the Activate event, which hid the form
at startup just fine; however, when I tried to set Me.Visible to True
in another part of the code, I saw the Form.Activate event running
again, re-hiding the form.
On my second try, I created a form-level variable, WindowVisible, put
Me.Visible = WindowVisible in the Form.Activate event, and set
WindowVisible in the code where necessary. This works fine, but it
seems a little kludgy to me, as if I'm trying to work around something
I don't understand.
My questions are:
1. Is there a better way to hide a form at startup?
2. Is there a better way to approach the whole problem?
3. Where can I read a summary of the order in which form events are
raised, and for what reasons?
Thanks a lot.