How to hide a form???

B

Bob Rock

Hi Bob. I've been looking through these posts and trying a few things
myself. It is possible to hide the form in several of its events (such as
it's paint or visiblechanged) but that only works after the form is
displayed (however briefly) plus you then need to handle these events being
raised by another scenario other that the first time it is shown.

The solution is actually quite simple. Dont hide the form......

....no seriously.... all you need to do is (and this can be done at design
time) set the
form's WindowState property to FormWindowState.Minimized;

and the ShownInTaskbar property to false;

when you want the form to reappear the instance must have these properties
set to FormWindowState.Normal; (and if you want) ShownInTaskbar property to
true;

I do have reservations about exactly what you are trying to do and whether
what you are doing is really the best way to go about it, however Ive tried
the above and it works a treat.

Mark, if you read my previous post, you'll see that I found the correct
solution to this problem.
At this end of this thread I only want to say that I'm amazed by how
difficult is doing something that should be so simple as to hide a form.

Bob Rock
 
M

Mark Broadbent

I disagree. The "difficulty" is only because it is the First form of a
Windows Form Assembly otherwise it is easy, secondly even that being the
case we are still only talking about 2 properties to be set at design time
OR prior to passing the instance to the Application.Run method! If that is
difficult then Im a bit lost for words.

--

--

Br,
Mark Broadbent
mcdba , mcse+i
=============
 
B

Bob Rock

I disagree. The "difficulty" is only because it is the First form of a
Windows Form Assembly otherwise it is easy, secondly even that being the
case we are still only talking about 2 properties to be set at design time
OR prior to passing the instance to the Application.Run method! If that is
difficult then Im a bit lost for words.

--

--

Br,
Mark Broadbent
mcdba , mcse+i
=============

Mark, what you propose is not a solution. It's a work-around.
The correct solution, as I already posted, is given here:

http://msdn.microsoft.com/library/d...tsksettingformtobeinvisibleatitsinception.asp

And considering the code that the default Windows Application projects
generates, it is a lot of work!!

Bob Rock
 
M

Mark Broadbent

We will keep going around in circles so this is going to be my last post,
but please read carefully and hopefully it will be clear.

What you origionally wanted was to hide a startup form upon passing to the
Application loop.
The Microsoft way is still a workaround AND additionally is not firing all
the form events until the form has been shown by its ShowDialog method.

My solution IS but is hidden from the User Interface till an event occurs -I
used a timer to show it.
I doubted at the time that this was exactly what you wanted but what you
were asking to do isnt something usual with a windows form project.

Again just to reiterate the coding, excluding the management of a timer or
another similar kind of event to fire the code to bring the form back to the
UI, we are talking 4 lines of code in total.

Anyways Im happy that you ve got the solution you need

all the best,

Mark.


Mark Broadbent
mcdba , mcse+i
=============
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top