Difference between Form.Hide() and (X)

P

PeterB

What actually happens when I click the top-right (X) in a form?

Clicking (O) is equal to Form.Close() right? But (X) is not equal to
Form.Hide()

In a scenario I have a parentform-subform (form1-form2-form3-...-formN)
relation to a certain depth.

I have a button "Exit" that performs this.Hide()

If I close all forms with (X) until I reach the today screen, and then
launch the application again formN is displayed. If I close this form with
(X) or "Exit" the today screen is displayed again. But if I re-launch the
application here I get formN if (X) was clicked and formN-1 if "Exit" was
used. So we "advance" one form by clicking Exit instead of (X).

If I instead click on Exit on each form, and re-launch the application and
again nothing happens. In this case I need to activate it from the Running
Programs list. Maybe one could say that hiding is more powerful than (X) ??

Anyone willing to elaborate?

thanks,

Peter
 
G

Ginny Caughey [MVP]

Peter,

Clicking the X actually minimizes the form. If this isn't the behavior you
want, you can change the MinimizeBox property of the form to false and
you'll get OK instead of X. When you click OK, the form is closed rather
than minimized.

Hope this helps,
 
C

Chris Tacke, eMVP

The (x) is a minimize button, so all the events associated with minimize
fire. Hide simply sets its visible style bit to off.
 
P

PeterB

Ok, thanks! I think I understand it now, but CF doesn't support minimize
events, so how do you catch a minmizing form? I.e. how do you catch the (X)
click?

/ Peter
 
G

Geoff Schwab [MSFT]

I found this in the help...

Note Minimizing a form at run time generates a Resize event. The
WindowState property reflects the current state of the window. If you set
the WindowState property to FormWindowState.Minimized, the form is minimized
independently of whatever settings are in effect for the MinimizeBox and
FormBorderStyle properties.

You may be able to capture a minimize in OnResize and check the WindowState
of the form.

You may also be able to use OnDeactivate and OnActivate depending on what
you need to accomplish.

--
Geoff Schwab
Program Manager
Excell Data Corporation
http://msdn.com/mobility

This posting is provided "AS IS" with no warranties, and confers no rights.
 

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