Display (X) button on a windows form

S

Sreenish

Hi All,

How can I display the close button (X), on the top-right hand corner of a
windows form. I can see the (X) button on the form during design time, but
when the application is executed on pocket PC, (X) button changes to OK
button. Is there a way to do this?

Thanks in advance,
Sreenish
 
T

Tim Wilson

The "X" is known as the smart minimize button and does not really close your
application, just minimizes it into the background. Are you working on a
basic Pocket PC (not Pocket PC 2002 or 2003) device?
 
K

Katie Schaeffer [MSFT]

Hi Sreenish,

If .MinimizeBox is set to false, the 'X' becomes an 'ok'. Also if you show
a form via .ShowDialog (instead of .Show), .netCF will automatically make
the form have an 'ok' because it's a modal dialog.

So to answer your question, if you want an 'X', you'll need to ensure
..MinimizeBox is set to 'true', and that you've shown the form via .Show
(instead of .ShowDialog).

Keep in mind that clicking 'ok' truely closes the form, where as clicking
on 'X' only minimizes the form.

-Katie

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

***.Net Compact Framework Info***
Faq:
http://msdn.microsoft.com/mobility/prodtechinfo/devtools/netcf/FAQ/default.a
spx
QuickStarts: http://samples.gotdotnet.com/quickstart/CompactFramework/
Samples:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnnetcomp/h
tml/CompactfxTechArt.asp

--------------------
| From: "Sreenish" <[email protected]>
| Subject: Display (X) button on a windows form
| Date: Mon, 5 Jan 2004 16:01:37 -0600
| Lines: 11
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
| Message-ID: <#Ix0#[email protected]>
| Newsgroups: microsoft.public.dotnet.framework.compactframework
| NNTP-Posting-Host: 66.150.213.8
| Path:
cpmsftngxa07.phx.gbl!cpmsftngxa06.phx.gbl!cpmsftngxa09.phx.gbl!TK2MSFTNGP08.
phx.gbl!TK2MSFTNGP09.phx.gbl
| Xref: cpmsftngxa07.phx.gbl
microsoft.public.dotnet.framework.compactframework:42182
| X-Tomcat-NG: microsoft.public.dotnet.framework.compactframework
|
| Hi All,
|
| How can I display the close button (X), on the top-right hand corner of a
| windows form. I can see the (X) button on the form during design time,
but
| when the application is executed on pocket PC, (X) button changes to OK
| button. Is there a way to do this?
|
| Thanks in advance,
| Sreenish
|
|
|
 
M

Mark Johnson

This code will ensure that ressing X will close the program properly and
not obly hide it

if (Environment.OSVersion.Platform == PlatformID.WinCE)
{
if (MainForm.MinimizeBox == true) // this is allways true if you don't
change it in the Designer
{// Problem : The User clicks on the "X" Control and the Program will
be hidden but not closed.
// this.ControlBox=false; // The "X/OK" will not be shown when false!
// This changes the "X" to "OK", the Application will be closed when
used
MainForm.MinimizeBox=false; // this is not Documented and may not
allways work (Pocket PC 2002 : OK)
// FormMainFrame_Closing is allways called, either thru "OK" or a
Close()
MainForm.Closing += new
System.ComponentModel.CancelEventHandler(FormMainFrame_Closing);
// This Method insures that this is done only one time
}
} // if (Environment.OSVersion.Platform == PlatformID.WinCE)

Mark Johnson, Berlin Germany
(e-mail address removed)
 
M

Mike

Why did Microsoft choose to make this so confusing? When
you click on the X in regular (PC) Windows, it CLOSES the
program, it doesn't minimize it. There is a different
graphic to minimize ("_"). Having an X show when you set
MinimizeBox to True just doesn't make sense for Windows
developers.
 
G

Ginny Caughey [MVP]

Mike,

I think the reason was so PPC apps would appear to load instantly. Often
users don't really care if an app is closed or hidden - they just want it
out of their way - then they want to load it again without a long wait.
Still, I agree that it can be confusing and all my commercial PPC apps use
MinimizeBox = false.
 

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