PDA

Click to See Complete Forum and Search --> : PPC Navigation Bar Help


berrick
Nov 20th, 2006, 09:00 AM
Hi hope some one can help,

I'm struggling to work out how i can trap when the 'x' on the ppc nav bar is tapped so i can close any open forms in my prog.

Or if anyone can suggest other ways i can do this.

the problem i'm having is that if a user presses the 'x' on the nav bar my active forms aren't closed and stay in memory.

Thanks in advance

Strider
Nov 20th, 2006, 09:26 AM
do you want to close the entire application when the user hits x on any forms button

berrick
Nov 20th, 2006, 10:40 AM
Sure that would work for me.

Just to be clear thought, it isn't the 'x' on the form like in windows its on the nav bar, a circle with an x in it.

thnxs for the reply.

Strider
Nov 20th, 2006, 10:48 AM
each form is on its own thead so when you close one form the rest stay open..

what you need to do is have a controller class that you declare the forms in and create the instances, this class needs to be passed into each forms contructor... and from this controller class you have methods that you call to show the form you want and then have a method exit app which closes and disposes all forms and exits the thread...

ill post a sample if u need..

berrick
Nov 20th, 2006, 11:16 AM
the sample sounds good, thnxs.

I understand about each form needing to be closed seperatley etc but the main thing i'm struggling to understand is how to test for the event to close all the froums

Strider
Nov 21st, 2006, 04:05 AM
this class needs to be called from the sub main in your code (recommend to place this in another class called main)


'controller class

public class mainctrl

private m_frm1 As Form1
private m_frm2 As Form2

public sub new()
End sub

public sub initialise()

m_frm1 = New Form1
m_frm1.Hide()

m_frm2 = New form2
m_frm2.Hide()

ShowForm1(nothing)

end sub

Public Sub ShowForm1(ByVal p_closingform As Form)
m_frm1.Show()
If Not p_closingform Is Nothing Then
P_closingform.hide()
End If
End Sub

Public Sub ShowForm2(ByVal p_closingform As Form)
m_frm1.Show()
P_closingform.hide()
End Sub

Public Sub ExitApp()
m_frm1.dispose
m_frm2.dispose
application.exit()
End Sub

End Class


'Form1

Private m_mainCtrl As mainCtrl

Public Sub New(ByVal p_mainCtrl)
Me.New()
m_mainCtrl = p_mainCtrl
End Sub

Public Sub btnShowForm2_Click() (ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSurveys.Click
m_mainctrl.ShowForm2(me)
End Sub

Public Sub btnExit_Click() (ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSurveys.Click
m_mainctrl.exitApp
End Sub

berrick
Nov 22nd, 2006, 05:12 AM
Thanks for the sample, I will give it a try soon

berrick
Nov 27th, 2006, 10:16 AM
Hi Strider,

Have tried your code but i'm having a few problems.
I'm new at all this.
I'm using visual studio 2k5 and seem to be having problems with the sub main part. I dont know how to make it?


Hoping you can help again :blush:

Strider
Nov 27th, 2006, 10:23 AM
i have no idea what VS2005 is like but in VS2003 you needed to have a sub main in the application. Generally you specified this in Project -> <ProjectName> Properties on the Main menu. In the general properties there was a startup object where you specifed a form or sub main where the project will launch from.

Public Class Main
Public Shared Sub Main()
Application.Run(New Form1)
End Sub
End Class

berrick
Nov 27th, 2006, 11:10 AM
Ahhhh thought some of your code looked 2k3. Unfortunately vs2k5 is totally different
from my limited exposure. This is one of the reasons it is so confussing to a newbie when try to self teach. Lots of examples of how to do things but most aren't for vs2k5 or PPC and they are just slightly different to give errors, hehe.

YOu do however still have the startup object and you can still specify form or sub main.

I just need to work out how to call it to utiliz your code example ;)

berrick
Dec 4th, 2006, 10:27 AM
@Strider,

I have had time try your code and as usual with VB2k5 and PPC things didnt go quite to plan but it dawned on me that your example rely's on a button on the form "btnExit" to be clicked to call "ExitApp()".

The problem i'm having is the button being tapped on the PPC is on the navigation bar, a system button and not on the form i have created.

This is the button event i'm trying to check for.

Have i understood your code correctly do you have any suggestions?

Hears hoping