Any suggestion is welcome!

PLH

Well-known member
Joined
Dec 18, 2004
Messages
48
Location
Los Angeles, CA - USA
Programming Experience
Beginner
How to hide my application

Hello there, I have an app that may run at startup. The problem I have is that if the user wants it to run at startup of windows he has a chose to make it invisible which I could not get it done. I used Me.Opacity = 0 which works fin on XP but it isn't supported on Window 98. This has to be done in the Forms load event. I tried Me.visible = False and Me.hide() but nether of this doesn’t work in the forms load section. I wander if there is any other way that I can try. Thanks
 
Last edited by a moderator:
You should have a look at services.
But if a service doesn't meet your needs, you could use a 'Sub Main' procedure as the startup object rather than a form. If you don't need a visible form at the start of the app, there's no need to load one then make it invisible; or is there?
Perhaps you could explain the purpose of the app, which could lead to a better solution.
 
just in case you do need to have any form hidden on load:

make a form level boolean and in the load event of the form set it to either true or false

then in the form's activated event check the boolean value and if it's true, hide the form

although throught that form you do need to keep track of when the form needs to be hidden or not because the activated event fires everytime the form get focus
 
Note that hiding or showing a form in its Load event handler is pointless because the Load event is raised before the form becomes visible anyway, and it always becomes visible once the event handler completes. It is the Activated event that is raised when the form is first made visible and then whenever the form gets focus after that. The problem with hiding the form in the Activated event handler is it will become visible for a split second.

A form can be made completely hidden by setting its WindowState to Minimised and its ShowInTaskbar property to False.
 
Thanks guys for your suggestions. Even though I don’t need to make the form invisible I found a way to do it. I just set the Top property of the form outside the visible area and it works fine.

 
PLH said:
Thanks guys for your suggestions. Even though I don’t need to make the form invisible I found a way to do it. I just set the Top property of the form outside the visible area and it works fine.

When you're working with multiple windows and you want to get one of them out of the way, do you drag it off the screen? No, you minimise it. Then, when you restore it, it is exactly where it was before. That's exactly why forms can be minimised, so why use a hack?
 
That sounds like an anomoly. Minimising an app should make it disappear from the screen and only be visible in the taskbar. When you try it do you remove your code that sets the Top property? Perhaps doing both messes things up. If you have removed that code, I'd be interested to see a screen shot because what you report should not happen. I have created apps that run in the system tray and to achieve that I set the WindowState of the main form to Minimised and the ShowInTaskbar property to False. To show the form, I handle the DoubleClick event of the NotifyIcon and simply set the WindowState to Normal and ShowInTaskbar to True and , presto, instant main window with no issues.
 
The reason it didn’t work in my app is that the ShowInTaskbar was set to false in the forms property, but it works when I set it to true and change it in run time. Thanks alot for your help.
 
Last edited:
I just did a little test and found that it depends on the order in which things are done. If you minimise a form whose ShowInTaskbar property is False, the window icon is displayed in the lower left of the desktop. If you set the ShowInTaskbar property of an already minimised form to False, however, the window will disappear without a trace. I'd guess it has been done that way so that you are able to not show a window in the taskbar but still have access to it if it is minimised.
 
I found a very wierd thing. My app uses com (Windows player). It seems it is not posible to make the form invisible. I just created a new form and set
Me.WindowState = FormWindowState.Minimized

Me.ShowInTaskbar = False

it worked like you sad but when I added the com it doesn't.
Isn't it od?
 
Just curious: by Windows Player do you mean the Windows Media Player?
I tried it with the Media Player COM control and had no problem (I have version 10).
Has is it acting with the COM control?
 
Back
Top