Basic4ppc - Windows Mobile Development  

Go Back   Basic4ppc - Windows Mobile Development > Main Category > Questions & Help Needed
Home Register FAQ Members List Search Today's Posts Mark Forums Read

Questions & Help Needed Post any question regarding Basic4ppc.


Close(ok) Button


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 06-03-2008, 12:07 PM
Knows the basics
 
Join Date: Apr 2008
Location: Duesseldorf, Germany
Posts: 71
Default Close(ok) Button

Hello,

i've got a question regarding the close/ok button every device app does have in the upper right corner.

My App has two ways to exit out of it.One is through a button and the other one is by use of the menu.I do some cleanup before i really terminate the application.

This looks like this:


Code:
Sub Button3_Click
' Quit Button
ExitApp
End Sub

...

Sub Menu5_Click
' Menu Quit
ExitApp
End Sub

...


Sub ExitApp
...
do some clean up
...
AppClose
End Sub

If the user pushes the close/ok button, the app just terminates without doing any of my cleanup tasks.
To have the cleanup also done in this case, i just added the following:

Code:
Sub Form1_Close
ExitApp
End Sub
This does not work as i expected.I get some excpetion messages related to file access and some (for me ) unpredictable behavior ( infinite loop for instance).Maybe these exceptions have to do with the form1 closure.


- can someone explain, why these exceptions occur..? I ran through the code, but i cannot explain this behavior, even then if i take into account that my form is ( probably ) already closed by the OS..?

-Is there a chance to just catch the close/ok button event without having the OS close the form..?


cheers

TWELVE
Reply With Quote
  #2 (permalink)  
Old 06-03-2008, 03:31 PM
Senior Member
 
Join Date: May 2007
Posts: 130
Awards Showcase
Beta Tester 
Total Awards: 1
Default

Hi twelve,

Is it maybe the application was just minimized or just hide in backround when when closing the form?

ie. when using the formlib.dll library.
form1.New1("form1",B4PObject(1)) '1st form library to enable minimize button
form1.MinimizeBox=True 'X' or 'OK' press just hide in background


make form1.MinimizeBox=false to disable.
__________________
Rioven

Sony Ericsson XPERIA X1i WM6.1
480x800 Display Resolution
with QWERTY keyboard

Last edited by Rioven : 06-03-2008 at 03:36 PM. Reason: added last line
Reply With Quote
  #3 (permalink)  
Old 06-03-2008, 03:50 PM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 3,186
Default

AppClose closes the main form and therefore launches Sub Form1_Close which then calls AppClose again.

The simplest solution is to move your cleanup code into Sub Form1_Close.

You can use Form.CancelClose to cancel the closing process.
Reply With Quote
  #4 (permalink)  
Old 06-04-2008, 06:40 AM
Knows the basics
 
Join Date: Apr 2008
Location: Duesseldorf, Germany
Posts: 71
Default

Quote:
AppClose closes the main form and therefore launches Sub Form1_Close which then calls AppClose again.

The simplest solution is to move your cleanup code into Sub Form1_Close.
This was exactly the issue.I didn't know that AppClose calls the Form1_Close Sub.Is that documented somewhere in the manual ? If so i didn't find it.

Quote:
You can use Form.CancelClose to cancel the closing process.

How is the syntax then, do you have an example piece of code..?


The Basic4PPC help is very poor, often i do not understand how a certain instruction or parameter does work, sometimes i don't even understand what the instruction does.


@Rioven: no i do not use the fullscreen stuff from the formlib, yet.

kind regards


TWELVE
Reply With Quote
  #5 (permalink)  
Old 06-04-2008, 07:38 AM
Senior Member
 
Join Date: May 2007
Posts: 130
Awards Showcase
Beta Tester 
Total Awards: 1
Default

Hi TWELVE,
This works for me.

Code:
Sub Form1_Close
If Msgbox("quit application?","",cMsgboxYesNo,cMsgboxQuestion)=cyes Then
DoSomeCleanUp 
AppClose
Else
form1.CancelClose
End If
End Sub
Quote:
@Rioven: no i do not use the fullscreen stuff from the formlib, yet.
Not for fullscreen but for the 'x' or 'ok' button on top right of the form to give you an option just to hide in background or to terminate the application. Most applications does use the hiding in background.
__________________
Rioven

Sony Ericsson XPERIA X1i WM6.1
480x800 Display Resolution
with QWERTY keyboard
Reply With Quote
  #6 (permalink)  
Old 06-04-2008, 04:22 PM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 3,186
Default

Quote:
How is the syntax then, do you have an example piece of code..?
Did you follow the link in my previous?
Reply With Quote
  #7 (permalink)  
Old 06-05-2008, 09:06 AM
Knows the basics
 
Join Date: Apr 2008
Location: Duesseldorf, Germany
Posts: 71
Default

Quote:
Did you follow the link in my previous?
Erel,

i'm sorry, did not realize that this was a link..

cheers

TWELVE
Reply With Quote
  #8 (permalink)  
Old 06-06-2008, 07:33 PM
Knows the basics
 
Join Date: Aug 2007
Location: Arkansas
Posts: 60
Default

I have full screen on my ppc App. But I get a double take with Msgbox.
I have to accepet Yes or No twice to get it to work.

Code:
Sub ImageButtonExitForm1_Click
  Msgbox ("Do you want to quit?",, cMsgBoxYesNo)
    Form1.Close
 End Sub

Sub Form1_Close
     If Msgbox ("Do you want to quit?",, cMsgBoxYesNo) = cNo Then
          Form1.CancelClose
		
     End If
End Sub

Last edited by cdeane : 06-06-2008 at 07:57 PM.
Reply With Quote
  #9 (permalink)  
Old 06-07-2008, 10:40 PM
Knows the basics
 
Join Date: Aug 2007
Location: Arkansas
Posts: 60
Default

So I asume there is no way to use this CancelClose in full screen format?
Reply With Quote
  #10 (permalink)  
Old 06-08-2008, 05:51 AM
Standa's Avatar
Junior Member
 
Join Date: May 2007
Location: Czech Republic
Posts: 26
Awards Showcase
Beta Tester 
Total Awards: 1
Default

Hi, try this:
Code:
Sub ImageButtonExitForm1_Click
    Form1.Close
End Sub

Sub Form1_Close
     If Msgbox ("Do you want to quit?",, cMsgBoxYesNo) = cNo Then
          Form1.CancelClose	
     End If
End Sub
__________________
XDA Flame
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
minimize or close? Byak@ Questions & Help Needed 3 09-28-2008 05:18 PM
Improved Close Event RandomCoder Basic4ppc Wishlist 5 09-26-2008 07:00 PM
HIDE TITLE BAR ? hide title, minimize , max and Close button (FOR DESSKTOP EXE) pegamaster Questions & Help Needed 0 07-04-2008 03:59 PM
close button kavka Questions & Help Needed 4 02-27-2008 10:29 AM
SQLite Open Close - how often? sloopa Questions & Help Needed 3 05-01-2007 03:01 PM


All times are GMT. The time now is 02:17 PM.


Powered by vBulletin® Version 3.6.12
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.1.0