473,799 Members | 2,972 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Catching the _closing event on Windows Mobile 5.0

Hello Everyone,

I am writing a Windows Mobile 5.0 application using VS 2..8 in VB.NET.
When someone clicks the "Exit" menu option, which generates a
button_click() event, I find it easy to display an "Are you sure?"
MessgeBox before the application closes. That way, if they
accidentally selected exit, they have a chance to back out. But I also
want to catch the _closing() event on the form in case the user clicks
the application close X on the top of the application. When I use the
following code, it doesn't do anything at all:

Private Sub MainForm_Closin g(ByVal sender As System.Object, ByVal e
As _
System.Componen tModel.CancelEv entArgs) Handles
MyBase.Closing

Dim rs As Integer

rs = MessageBox.Show ("Are you sure you want to exit?",
"Confirm Exit", MessageBoxButto ns.OKCancel,
MessageBoxIcon. Exclamation, MessageBoxDefau ltButton.Button 1)
If (rs = vbOK) Then
Application.Exi t()
Else
Return
End If
End Sub

Am I doing this wrong? How can I best deal with this event? Is it even
possible?

Thanks!
Anthony
Jun 27 '08 #1
3 1829
On Apr 22, 6:50 am, "Anthony P." <papill...@gmai l.comwrote:
Hello Everyone,

I am writing a Windows Mobile 5.0 application using VS 2..8 in VB.NET.
When someone clicks the "Exit" menu option, which generates a
button_click() event, I find it easy to display an "Are you sure?"
MessgeBox before the application closes. That way, if they
accidentally selected exit, they have a chance to back out. But I also
want to catch the _closing() event on the form in case the user clicks
the application close X on the top of the application. When I use the
following code, it doesn't do anything at all:

Private Sub MainForm_Closin g(ByVal sender As System.Object, ByVal e
As _
System.Componen tModel.CancelEv entArgs) Handles
MyBase.Closing

Dim rs As Integer

rs = MessageBox.Show ("Are you sure you want to exit?",
"Confirm Exit", MessageBoxButto ns.OKCancel,
MessageBoxIcon. Exclamation, MessageBoxDefau ltButton.Button 1)
If (rs = vbOK) Then
Application.Exi t()
Else
Return
End If
End Sub

Am I doing this wrong? How can I best deal with this event? Is it even
possible?

Thanks!
Anthony
Hi Anthony,

I hope that works for you and fixes your problem:

Private Sub MainForm_Closin g(ByVal sender As System.Object, ByVal e As
System.Componen tModel.CancelEv entArgs) Handles MyBase.Closing

Dim rs As Integer

' Define MsgBox
rs = MessageBox.Show ("Are you sure you want to exit?", "Confirm Exit",
MessageBoxButto ns.OKCancel, MessageBoxIcon. Exclamation,
MessageBoxDefau ltButton.Button 1)

' Exit if OK is clicked
If rs = vbOK Then
Application.Exi t()

' Else stay awake
Else
e.Cancel = True

End If

End Sub
Hope this helps,

Onur Güzel

Jun 27 '08 #2
Thank you Onur!
I'm not sure if it worked for me or not because I'm not at my dev
machine but I can already see some changes I need to make. Thanks for
your input!

Anthony
Jun 27 '08 #3
On Apr 23, 12:28*am, "Anthony P." <papill...@gmai l.comwrote:
Thank you Onur!
I'm not sure if it worked for me or not because I'm not at my dev
machine but I can already see some changes I need to make. Thanks for
your input!

Anthony
Anthony, i tested it on my machine and worked, i hope the same effect
for you :-)

Let us know,

Regards,

Onur Güzel
Jun 27 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
4991
by: Olli Piepponen | last post by:
Hi, I'm having a little problem catching keystrokes under Windows. I did a little research and found that with mscvrt.getch() one can cath a single key that is pressed. However this doesn't work when the program is run on the backround and not as the primary task. What I would like to have is a same sort of function that would also work when the program is being run on the background. I'm trying to implement a program that would listen...
5
2262
by: Ron L | last post by:
I have an MDI application with a number of child windows. In each child window I am catching the Closing event and having the child window decide if it should set cancel to true. The intent here is to ensure that no child window can close while it is in a state where user entered information can be lost. I have just noticed that while the Closing event is caught if I click the X on the child window, it is not caught if I click the X on...
3
17221
by: Elp | last post by:
Hi, I've developped a Window Form C# application which main form contains several activex controls. No problems most of the time but on some machine, the application crashes when the main form is closed with a NullReferenceException caused by the DisposeAxControl which, i guess, is supposed to dispose one of my ActiveX. This is not a big problem as the application is closing anyway but i'd like to suppress this crash message. However,...
0
2224
by: Nick White [MSFT] | last post by:
Hello fellow Microsoft Windows Mobile and Embedded enthusiasts: I invite you to peruse the list below of upcoming technical chats and Webcasts offered by the Windows Mobile and Embedded Devices Group. For the full list of upcoming Windows Mobile and Embedded chats, to review archived chat sessions, or to request a reminder for a chat, visit http://msdn.microsoft.com/embedded/community/community/chats/. Also, the Windows Mobile and...
2
1309
by: Eric Sabine | last post by:
I built a generic exception handler form which allows the user to get information from it, print it, email it, etc. for exceptions for which I explicitly didn't handle in code, such as missing permissions on a stored procedure, etc. I use this exception handler in all of my applications and it can be called as simply as follows try ... catch ex as sqlexception ExceptionHandler(ex, otherData1, otherData2)
0
3439
by: =?Utf-8?B?Q2hhcmxlcw==?= | last post by:
Like many people, I normally use Yahoo! Mail via the web and like to keep all my emails stored on the Yahoo! server. However sometimes I can’t get access to a PC/the web and I download my emails to a PDA/palmtop via POP3. The PDA uses Windows Mobile software. Since using the PDA, I have had the problem of emails disappearing from the Yahoo! server. However I think I now understand how to avoid this. It seems that Windows Mobile is...
4
2835
by: =?Utf-8?B?VGFtbXkgTmVqYWRpYW4=?= | last post by:
I am creating an application for windows mobile using Visual C# windows. I am using visual studio 2008 and I have windows Microsoft Vista on my computer. I also downloaded the professional and standards SDK windows mobile. However some tools and properties are not available such as FontColor, RichTextBox, FlowLayoutPanel . The tools I needed are mostly under System.Windows.Forms name space which already included in my application. I also...
7
3256
by: cj2 | last post by:
I saw a MS demo a few years back where they developed a web page and the software automatically rendered it for different devices. Is this what I'm looking for? http://www.asp.net/mobile/ Much of the info looks old. I have a MSDN account where can I download it or is it already in VS 2008 and I just don't know how to find it? I'm mainly interested in having simple pages render in Internet Explorer
9
3718
by: =?Utf-8?B?RGFuaWVs?= | last post by:
Hi, I downloaded the sample application that the Microsoft video ASPNETAJAXForWinMobile described but it doesn't work on my Windows Mobile 6 emulator. After enabling the script error reporting of the mobile IE, it pops up several JScript error and the ajax behavior is not funtional at all. Where can I look for any possible issue? Thanks.
0
9546
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10491
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10268
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10031
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6809
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5467
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5593
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4146
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2941
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.