473,396 Members | 1,929 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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 3622
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
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
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
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
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
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
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
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
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
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
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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,...

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.