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.


Problem with closing forms


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 03-10-2010, 08:52 AM
Senior Member
 
Join Date: Apr 2009
Posts: 109
Default Problem with closing forms

Hi,

I have run into a problem trying to close a form. It does not happen on the desktop just on the device.

if i press the button 'btnCreditCancel' this is in the sub

Sub btnCreditCancel_Click
Credit.Close
End Sub

The name of the form is Credit

The form does not close. i suspect that the program flow is going back to the calling routine and then opening the form again

i put a message box after the calling statement but it gets executed as soon as the form is shown not when the form is closed.

Question 1 how can i find out program flow
Question 2 how can i fix my problem

thanks

Joe

Edit:
i fixed the problem but it does not seem elegant. This is the sub that calls the form and as i suspected it was being executed over and over again. It must get executed as the credit form is closed. So when the calling form is receiving the focus the radio button must be having it's click event fired because it was the last item selected. Is there a way of avoiding this without having to set flags?

Sub trxTypeCard_Click
If CreditFormCalled=True Then
CreditFormCalled=False
Return
End If
CreditCardOk=False
trxType=1
Credit.Show
CreditFormCalled=True
End Sub

Thanks to all and any for some insight!

Last edited by Smee : 03-10-2010 at 09:09 AM. Reason: partially fixed
Reply With Quote
  #2 (permalink)  
Old 03-10-2010, 05:43 PM
klaus's Avatar
Basic4ppc Expert
 
Join Date: Oct 2007
Location: Switzerland
Posts: 1,797
Awards Showcase
Forum Contributer Beta Tester Competition Winner 
Total Awards: 3
Default

Could you post the code, or part of it, so we could look at it to try to give you a more 'elegant' solution ?

Best regards.
__________________
Klaus
Switzerland
Reply With Quote
  #3 (permalink)  
Old 03-10-2010, 07:42 PM
Senior Member
 
Join Date: Apr 2009
Posts: 109
Default

Klaus,

This is calling sub

Sub trxTypeCard_Click
CreditCardOk=False
trxType=1
Credit.Show
End Sub

this is the called form

Sub Credit_Show
Password=""
txtPassword.Text =""
txtCardNo.Text=""
End Sub

Sub btnCreditCancel_Click
Credit.Close
End Sub

Sub Credit_Close
If CreditCardOk=False Then
Msgbox("Credit Denied")
trxType=0
trxTypeCash.Checked=True
end If
End Sub

trxTypeCash is a radio button on the calling form

Hope this helps

Thanks

Joe
Reply With Quote
  #4 (permalink)  
Old 03-11-2010, 08:30 AM
klaus's Avatar
Basic4ppc Expert
 
Join Date: Oct 2007
Location: Switzerland
Posts: 1,797
Awards Showcase
Forum Contributer Beta Tester Competition Winner 
Total Awards: 3
Default

I have tried your code in a small test program, it works well !

So, you should post your sbp file to be able to find what's wrong in your program.

Best regards.
Attached Files
File Type: sbp FormClose.sbp (1.3 KB, 2 views)
__________________
Klaus
Switzerland
Reply With Quote
  #5 (permalink)  
Old 03-11-2010, 10:11 AM
Senior Member
 
Join Date: Apr 2009
Posts: 109
Default

Thank you for testing Klaus

Yes it works for me too but only on the desktop. The problem occurs only on the device. Didyou test on the device or desktop only?

thanks again

Joe
Reply With Quote
  #6 (permalink)  
Old 03-11-2010, 11:02 AM
klaus's Avatar
Basic4ppc Expert
 
Join Date: Oct 2007
Location: Switzerland
Posts: 1,797
Awards Showcase
Forum Contributer Beta Tester Competition Winner 
Total Awards: 3
Default

The test program works fine on my htc Touch HD, optimized compiled.

Best regards.
__________________
Klaus
Switzerland
Reply With Quote
  #7 (permalink)  
Old 03-11-2010, 12:31 PM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 3,839
Awards Showcase
Innovator medal Beta Tester Forum Contributer 
Total Awards: 3
Default

I don't think Klaus' code will show the problem as it doesn't have a Credit.Show in trxTypeCard_Click which is probably what the problem is. I have noticed in the past that (.NET and not just Basic4ppc) RadioButtons and CheckBoxes can fire their Click events at unexpected times.
__________________
Sorry, but I don't answer questions by PM or email.
Please post your queries in the forum.
Reply With Quote
  #8 (permalink)  
Old 03-11-2010, 04:01 PM
klaus's Avatar
Basic4ppc Expert
 
Join Date: Oct 2007
Location: Switzerland
Posts: 1,797
Awards Showcase
Forum Contributer Beta Tester Competition Winner 
Total Awards: 3
Default

I remembered too that there is some strange behaviour with radiobuttons.

Have a look here : Unwanted Click Event

Try, in the IDE, to send back the radiobutton to ensure that it doesn't get the focus when you close form2.

Best regards.
__________________
Klaus
Switzerland
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
Program not closing completely derez Questions & Help Needed 9 07-28-2009 10:29 AM
Error when closing help - not sure if its my PC though badkarma Bug Reports 1 03-13-2009 07:48 PM
Problems opening closing forms admben25 Questions & Help Needed 3 11-03-2008 04:08 AM
Problem Adding panel in tabpages to multiple Forms mozaharul Questions & Help Needed 2 04-28-2008 09:49 AM
Merging forms skipper Questions & Help Needed 2 01-10-2008 12:18 PM


All times are GMT. The time now is 11:45 PM.


Powered by vBulletin® Version 3.6.12
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0