How can I override a handler for a Form ControlBox

I have an form, and I'd like to have the controlbox on it (upper right corner close/max/min).

How do I override the handler for the close?

Learning the .NET Framework still. Whats the correct way to do this?

Thanks.

[224 byte] By [InquiringMinds] at [2007-12-17]
# 1
What device are you targeting? Only custom WinCE devices show you all controlbox elements; PPCs have either an "X" or an "OK" in the top right corner which you can control with the MinimizeBox property.

See if handling the Closing/Closed events gets you where you want to be.

Cheers
Daniel

DanielMoth at 2007-9-9 > top of Msdn Tech,Smart Device Development,.NET Compact Framework...
# 2
In Pocket PC applications, you either have an Minimize (X) or a Close (OK) button in the upper right corner. Minimize is the default, which keeps the application running in the background. You can change the X to OK by doing adding the following line to the Form's constructor or InitializeComponent() method:
' Change Minimize (x) to Close (ok)

Me.MinizeButton = False
To override the Closing event, add this method to your Form:
Private Sub Form1_Closing(sender As Object, e As System.ComponentModel.CancelEventArgs) _

Handles MyBase.Closing

MsgBox("Closing App")

' do stuff

End Sub
For more information about Pocket PC form factors using the .NET Compact Framework, see:
http://msdn2.microsoft.com/en-us/library/bxz0e21k(en-US,VS.80).aspx
Also, see the Pocket PC User Interface Guidelines:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/guide_ppc/html/ppc_pcconapplicationhelpforpocketpcs.asp
Hope this helps,

- Bruce Hamilton

.NET Compact Framework User Education

BruceHamilton at 2007-9-9 > top of Msdn Tech,Smart Device Development,.NET Compact Framework...
# 3
I got this to work but the property name is:

Me.MinimizeBox = False

Probably the confusion is that "X" means close in Windows XP but Minimize in the mobile O.S., in my case I am using CE 5.0. So obviously the Closed event is not raised when the window is minimized, even though the X intuitively should be "close". Instead, "ok" means close. Just my two cents.

HiTech2k at 2007-9-9 > top of Msdn Tech,Smart Device Development,.NET Compact Framework...