Application.Run() does not show Form

J

Jon Brunson

Afternoon All,

In the code below, when it gets to Application.Run(frmMain), it does not
show the form on the device, any ideas why?

If I use frmMain.ShowDialog() it works fine, but then I can't use
Invoke() on the form later on, and I need to.

Help?

[VB.NET]

Private Shared frmSplash As Forms.SplashScreen

Public Shared Sub Main()

While Not File.Exists(Mobile.ApplicationLocation + "settings.xml")
Dim frmInitialize As New Forms.Initialize
If frmInitialize.ShowDialog() = DialogResult.Cancel Then Return
End While

frmSplash = New Forms.SplashScreen
frmSplash.Show()
Application.DoEvents()

Try
If Not (Directory.Exists(Mobile.ApplicationLocation + "Data")) Then
frmSplash.lblStatus.Text = "Creating Local Data Folder"
Directory.CreateDirectory(Mobile.ApplicationLocation + "Data")
End If

frmSplash.lblStatus.Text = "Connecting to Local Database"
PropertySurveys.Common.OpenDatabases()

Catch ex As InnovationException
frmSplash.Close()
MessageBox.Show(ex.Message, Common.ProductName,
MessageBoxButtons.OK, CType(ex.Severity, MessageBoxIcon),
MessageBoxDefaultButton.Button1)
Return

Catch ex As Exception
frmSplash.Close()
MessageBox.Show(ex.Message, Common.ProductName,
MessageBoxButtons.OK, MessageBoxIcon.Hand, MessageBoxDefaultButton.Button1)
Return

End Try

Dim frmWait As New Forms.PleaseWait("Loading")

frmSplash.lblStatus.Text = "Ready"

Dim frmLogin As New Forms.Login(frmWait)
frmSplash.Close()
frmSplash.Dispose()

If frmLogin.ShowDialog() = DialogResult.OK Then
frmLogin.Dispose()
frmWait.SetProgressBarValue(20)

Dim frmMain As New Forms.Procedures
frmWait.SetProgressBarValue(100)

frmWait.Close()
frmWait.Dispose()

Application.Run(frmMain)

End If

End Sub

[/VB.NET]
 
J

José Miguel Torres

Application.Run function expects a System.Windows.Forms.Form class not an
object.

regards
 
J

Jon Brunson

frmMain (Forms.Procedures) is inherited from the
System.Windows.Forms.Form class

José Miguel Torres said:
Application.Run function expects a System.Windows.Forms.Form class not an
object.

regards


--
José Miguel Torres
jtorres_diaz~~ARROBA~~terra.es
http://jmtorres.blogspot.com

Afternoon All,

In the code below, when it gets to Application.Run(frmMain), it does not
show the form on the device, any ideas why?

If I use frmMain.ShowDialog() it works fine, but then I can't use
Invoke() on the form later on, and I need to.

Help?

[VB.NET]

Private Shared frmSplash As Forms.SplashScreen

Public Shared Sub Main()

While Not File.Exists(Mobile.ApplicationLocation + "settings.xml")
Dim frmInitialize As New Forms.Initialize
If frmInitialize.ShowDialog() = DialogResult.Cancel Then Return
End While

frmSplash = New Forms.SplashScreen
frmSplash.Show()
Application.DoEvents()

Try
If Not (Directory.Exists(Mobile.ApplicationLocation + "Data")) Then
frmSplash.lblStatus.Text = "Creating Local Data Folder"
Directory.CreateDirectory(Mobile.ApplicationLocation + "Data")
End If

frmSplash.lblStatus.Text = "Connecting to Local Database"
PropertySurveys.Common.OpenDatabases()

Catch ex As InnovationException
frmSplash.Close()
MessageBox.Show(ex.Message, Common.ProductName,
MessageBoxButtons.OK, CType(ex.Severity, MessageBoxIcon),
MessageBoxDefaultButton.Button1)
Return

Catch ex As Exception
frmSplash.Close()
MessageBox.Show(ex.Message, Common.ProductName,
MessageBoxButtons.OK, MessageBoxIcon.Hand,
MessageBoxDefaultButton.Button1)

Return

End Try

Dim frmWait As New Forms.PleaseWait("Loading")

frmSplash.lblStatus.Text = "Ready"

Dim frmLogin As New Forms.Login(frmWait)
frmSplash.Close()
frmSplash.Dispose()

If frmLogin.ShowDialog() = DialogResult.OK Then
frmLogin.Dispose()
frmWait.SetProgressBarValue(20)

Dim frmMain As New Forms.Procedures
frmWait.SetProgressBarValue(100)

frmWait.Close()
frmWait.Dispose()

Application.Run(frmMain)

End If

End Sub

[/VB.NET]
 
Top