473,509 Members | 2,828 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Is this a safe way to hide the main form?

I'm writing a tray application and I of course want to hide the main form
when the appstarts. I've experimented with a couple of techniques to do
this, including setting Opacity to 0, but this seems a bit kludgy. I ended
up doing this:

static void Main()
{
new MyAppForm();
Application.Run();
}

This differs from a normal Main by calling the void version of the Run
method and moving the new call out as a separate statement. I haven't been
able to find any good description as to whether this is a safe thing to do.
It seems to work fine and my service behavs as expected, responding properly
to its context menu accesses. I like this better than setting Opacity to 0.
Another solution I experiented with was to use the normal Run call:

Application.Run(new MyAppForm());

and in the constructor of the main form call Hide(), but for some reason
this doesn't work. So, unless someone has a better solution or tells me that
I shouldn't the void Run call, I'll stick with doing it this way.

Peter Steele
CIENA Corp.
Nov 16 '05 #1
2 3630
So, if you're not ever going to show your main form, why don't you create a
console application? Or why don't you get rid of your main form altogether?

-vJ

"Peter Steele" <ps*****@ciena.com> wrote in message
news:OF**************@TK2MSFTNGP10.phx.gbl...
I'm writing a tray application and I of course want to hide the main form
when the appstarts. I've experimented with a couple of techniques to do
this, including setting Opacity to 0, but this seems a bit kludgy. I ended
up doing this:

static void Main()
{
new MyAppForm();
Application.Run();
}

This differs from a normal Main by calling the void version of the Run
method and moving the new call out as a separate statement. I haven't been
able to find any good description as to whether this is a safe thing to do. It seems to work fine and my service behavs as expected, responding properly to its context menu accesses. I like this better than setting Opacity to 0. Another solution I experiented with was to use the normal Run call:

Application.Run(new MyAppForm());

and in the constructor of the main form call Hide(), but for some reason
this doesn't work. So, unless someone has a better solution or tells me that I shouldn't the void Run call, I'll stick with doing it this way.

Peter Steele
CIENA Corp.

Nov 16 '05 #2
Peter Steele wrote:
[...]

static void Main()
{
new MyAppForm();
Application.Run();
}

[...]


Check out this link:

http://msdn.microsoft.com/library/de...sinception.asp
- or -
http://makeashorterlink.com/?G1A022AB7

Side-note: should this be added to some faq?
Nov 16 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
73970
by: genetic.error | last post by:
I'm moving from Vb6 to VB.Net. I have a feeling this has come up before... The VS.Net MSDN file seems to state that the following should work: Form1.Show Form1.Visible = True Form1.Hide...
2
294
by: Peter Steele | last post by:
I'm writing a tray application and I of course want to hide the main form when the appstarts. I've experimented with a couple of techniques to do this, including setting Opacity to 0, but this...
5
2227
by: Kirk Graves | last post by:
Can anyone tell me why this code does not work? Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Me.Hide() End Sub If runs, but the...
4
1547
by: BrianDH | last post by:
Hi I have an application with 3 windows forms. One of which I load at startup but hide, then show/hide based on users click. How can I test to see if the windows is hidden, or is at the moment...
2
2753
by: gene kelley | last post by:
I have a dialog form, frmDetails, that is opened from the main form: frmDetails.ShowDialog() The only way I have provided to close this dialog is via the "X" button. If frmDetails is just...
10
6924
by: SQACPP | last post by:
Hi, I try to figure out how to use Callback procedure in a C++ form project The following code *work* perfectly on a console project #include "Windows.h" BOOL CALLBACK...
2
1917
by: =?Utf-8?B?VG9kZCBKYXNwZXJz?= | last post by:
Hey guys, I've got a MAIN form, which I have a series of navigational buttons on. When I open a secondary form from that form, I'd like to be able to HIDE the original form. The reason is, if...
0
7237
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7137
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7347
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7416
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7506
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5656
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
3218
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
1
779
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
443
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.