Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Me.Hide does not hide me

Status
Not open for further replies.

dave755

IS-IT--Management
May 3, 2001
69
US
I have an app that is to run as a system tray icon. It has a simple control panel in the "frmTimer" module.

My problem is that the form is displayed after launch, even though it is not supposed to be. Here is an excerpt from the code in qustion:

---------------
Code:
    Private Sub frmTimer_Load(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles MyBase.Load

        ... init code cut for clarity ...

        Me.Hide()
    End Sub

    Private Sub cmdClose_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdClose.Click
	Me.Hide()
    End Sub
----------------

After frmTimer_Load() runs, the form IS displayed - not hidden. Clicking the "Close" button to invoke cmdClose_Click() works perfectly.

Any enlightenment would be most appreciated.


Dave Gee
 
... and how (why?) did you think you could hide yourself?


So an 'advanced' search. Keyword "SysTray".




MichaelRed
m.red@att.net

Searching for employment in all the wrong places
 
You cant hide a form in its load event, it is not yet been made visible.

Two solutions depending on how the form is loaded. If its done by form.show in sub main or another form use load form instead of show. If its the startup object set the visible property to false.

Hope this helps.
 
i think, if you remove the line Me.Hide in the load event, p`robably you have the solution. remember, in the load event you execute the code for LOAD and not for SHOW the form, if you call an event who refers to the form, it will be visible.
 
Leoncito I think your comments only apply to MDI Child forms and removing the me.hide does not stop the form from becoming visible. As a guess the only reason for using a form in this way is to access a timer control, in which case this should probably be the only form.
 
My thanks to all responders. Your insights were most helpful (as usual). Here is how I solved the problem:

Firstly, it appears that SonOfEmidec1100 is correct. The form can't be hidden in the Load() method. BTW: I did take the Me.Hide call out of there - with no change in behavior.

So, I created a 2 second timer and a flag to go with it. When the timer ticks, I check the flag to decide whether to hide or show. With this method, the form shows momentarily after launch, but then disappears. Crude, but effective.

An aside: I found the Microsoft article referenced by MichaelRed to be a classic case of "You're in a balloon 30 feet off the ground." - completely factually accurate, but totally unhelpful. It contains a large amount of sample code, but only minimal explanation of how/why that code might be applicable to my situation.

Dave Gee
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top