VFPSQLDeveloper
asked on
MessageBox.Show Difference between VB .NET CE Device Emulator and actual CE Device
I'm writing an application in VB .NET for two CE devices. When I show a message to the User with MessageBox.Show it does what you would expect when running in the Emulator. When I run it on either of the two devices (Symbol & Psion Workabout Pro) the dialog stays on the Form after the user has hit the OK button, until the Sub code has completed (I need to other things in the Sub for an OK response). Is there a way I can manually clear the MessageBox Dialog?
The command used is as follows:
Result = MessageBox.Show("Are you sure you wish to overwrite all the Data on this Device?", "Clear Data", MessageBoxButtons.OKCancel , MessageBoxIcon.Exclamation , MessageBoxDefaultButton.Bu tton2)
If Result = DialogResult.Cancel Then
The command used is as follows:
Result = MessageBox.Show("Are you sure you wish to overwrite all the Data on this Device?", "Clear Data", MessageBoxButtons.OKCancel
If Result = DialogResult.Cancel Then
Have you tried invalidating your form ?
ASKER
Hi Ronald,
How do you do that?
Chris
How do you do that?
Chris
me.invalidate
ASKER
No it still left the dialog on the form. I use a progressbar after the dialog and it displays over the top of it. The only thing that clears it is when endsub is reached.
Hi VFPSQLDeveloper,
The progressbar displays over the dialogbox ?
Do you use a panel somewhere in your form ?
The progressbar displays over the dialogbox ?
Do you use a panel somewhere in your form ?
ASKER
Yes the progressbar appears in the middle of the dialog.
There isn't a panel on the form, it has 3 buttons a checkbox and the progressbar.
Should be really simple (shouldn't it?), or is it just me??!!
There isn't a panel on the form, it has 3 buttons a checkbox and the progressbar.
Should be really simple (shouldn't it?), or is it just me??!!
Yes it should ;-), it seems the form isn't invalidating itself, could you try hiding the form and then showing it, I want to see if it redraws itself then.
ASKER
The Hide makes the whole Form disappear (as you would expect), the show does not bring it back. It stays hidden through all the calls to the progress bar until another messagebox.show is called (to show action complete). The progress bar is not visible on the form when it returns.
It gets stranger by the minute :-), ok remove the hide, and could you try
me.resumelayout
me.invalidate
me.resumelayout
me.invalidate
ASKER
I don't see any properties for the form like resumelayout.
Sorry about that, the compactframework doesn't support that (bugger),
I tried to recreate your problem on my IPaq, but it seems to work there.
could you post some code so I can have a look, maybe there is something in there we've overlooked
I tried to recreate your problem on my IPaq, but it seems to work there.
could you post some code so I can have a look, maybe there is something in there we've overlooked
ASKER
I've included exerything that could possibly be relevant:
This is the button on the Form that imports data into a SQL CE Database and optionally resets some data. It's the 'Are you sure you wish to overwrite' messagebox that causes the problem...
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim sqlEngine As SqlCeEngine
Dim cn As SqlCeConnection
Dim rda As SqlCeRemoteDataAccess
Dim Result As DialogResult
' Check with User if Data has been selected
If CheckBox1.Checked Then
Result = MessageBox.Show("Are you sure you wish to overwrite all the Data on this Device?", "Clear Data", MessageBoxButtons.OKCancel , MessageBoxIcon.Exclamation , MessageBoxDefaultButton.Bu tton2)
If Result = DialogResult.Cancel Then
Return
End If
End If
Try
' Show Progress Bar
ProgressBar1.Visible = True
' Create Database
If (Not File.Exists("\My Documents\PmsCE.sdf")) Then
sqlEngine = New SqlCeEngine
sqlEngine.LocalConnectionS tring = _
"Data Source=\My Documents\PmsCE.sdf;" + _
"Password=Pipelines;"
sqlEngine.CreateDatabase()
sqlEngine.Dispose()
Else
' Open the Connection to the Database
cn = New SqlCeConnection("Data Source=\My Documents\PmsCE.sdf;" + _
"Password=Pipelines;")
cn.Open()
Dim cmd As SqlCeCommand = cn.CreateCommand() '
' Drop the Tables
cmd.CommandText = "DROP TABLE Pipeline"
cmd.ExecuteNonQuery()
cmd.CommandText = "DROP TABLE Personnel"
cmd.ExecuteNonQuery()
cmd.CommandText = "DROP TABLE ValveLocation"
cmd.ExecuteNonQuery()
cmd.CommandText = "DROP TABLE ValveGroup"
cmd.ExecuteNonQuery()
cmd.CommandText = "DROP TABLE ValveParameters"
cmd.ExecuteNonQuery()
' Drop Data Tables If Required
If CheckBox1.Checked Then
cmd.CommandText = "DROP TABLE HH_Street_Data"
cmd.ExecuteNonQuery()
cmd.CommandText = "DROP TABLE HH_Valve_Data"
cmd.ExecuteNonQuery()
End If
' Close the Connection
If cn.State <> ConnectionState.Closed Then
cn.Close()
End If
End If
' Calculate Increment, based on Data being Cleared
Dim increment As Single
If CheckBox1.Checked Then
increment = 15
Else
increment = 20
End If
' Instantiate the RDA Object
rda = New SqlCeRemoteDataAccess
' Use Release Defined Internet Logon & URL
rda.InternetLogin = InternetLogin
rda.InternetUrl = InternetUrl
rda.LocalConnectionString = _
"Data Source=\My Documents\PmsCE.sdf;" + _
"SSCE:Database Password=Pipelines;"
ProgressBar1.Value = increment
' Pull Template Tables from SQL Server & Tell Users
rda.Pull("Pipeline", "SELECT * FROM Pipeline", RemoteConnectString, + _
RdaTrackOption.TrackingOff WithIndexe s, "PipelineErrorTable")
ProgressBar1.Value += increment
rda.Pull("Personnel", "SELECT Hand_Held_Logon, Hand_Held_Password FROM Personnel", RemoteConnectString, + _
RdaTrackOption.TrackingOff WithIndexe s, "PersonnelErrorTable")
ProgressBar1.Value += increment
rda.Pull("ValveLocation", "SELECT * FROM Valve_Location", RemoteConnectString, + _
RdaTrackOption.TrackingOff WithIndexe s, "ValveLocationErrorTable")
ProgressBar1.Value += increment
rda.Pull("ValveGroup", "SELECT * FROM Valve_Group", RemoteConnectString, + _
RdaTrackOption.TrackingOff WithIndexe s, "ValveGroupErrorTable")
ProgressBar1.Value += increment
rda.Pull("ValveParameters" , "SELECT * FROM Valve_Parameters", RemoteConnectString, + _
RdaTrackOption.TrackingOff WithIndexe s, "ValveParametersErrorTable ")
' Pull Data Tables If Required, Ensure No Data is Pulled
If CheckBox1.Checked Then
ProgressBar1.Value += increment
rda.Pull("HH_Street_Data", "SELECT * FROM HH_Street_Data WHERE Datetime = ''", RemoteConnectString, + _
RdaTrackOption.TrackingOnW ithIndexes , "HHStreetDataErrorTable")
ProgressBar1.Value = 100 ' (Not exactly 100!)
rda.Pull("HH_Valve_Data", "SELECT * FROM HH_Valve_Data WHERE Date = ''", RemoteConnectString, + _
RdaTrackOption.TrackingOnW ithIndexes , "HHValveDataErrorTable")
End If
' Remove Progress Bar & Tell User
ProgressBar1.Visible = False
MessageBox.Show("Tables Imported OK")
Me.Dispose()
Catch sqlex As SqlCeException
ShowErrors(sqlex)
Catch ex As Exception
MessageBox.Show(ex.Message )
Finally
rda.Dispose()
End Try
End Sub
This is the Form Load method, in case theirs anything that may affect it in there...
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
' If No Database Exists, Don't bother with Login
If Directory.Exists("\My Documents\PmsCE.sdf") Then
#If DEBUG Then
' Ignore Login for Debug
#Else
' Show Login Form & Hide Main Form
Me.Visible = False
Dim login As New Pms_Common.Pms_Login
login.ShowDialog()
' Determine if Login was OK
If (login.DialogResult = DialogResult.OK) Then
' Show Main Form
Me.Visible = True
' Store Sucessful Logon
Logon = login.ReturnLogon
Else
' End Program
Return
End If
#End If
End If
' Create Connection String, Logon & URL, based on Debug
#If DEBUG Then
RemoteConnectString = "Provider=SQLOLEDB;" + _
"Data Source=localhost;" + _
"UID=Pms;PWD=pipelines;" + _
"WSID=LAPTOP;" + _
"Database=Pms"
InternetLogin = "IUSR_LAPTOP"
InternetUrl = "http://192.168.1.13/VirtualDir/sscesa20.dll"
#Else
' Change to Production Configuration When Known
RemoteConnectString = "Provider=SQLOLEDB;" + _
"Data Source=localhost;" + _
"UID=Pms;PWD=pipelines;" + _
"WSID=LAPTOP;" + _
"Database=Pms"
InternetLogin = "IUSR_LAPTOP"
InternetUrl = "http://192.168.1.13/VirtualDir/sscesa20.dll"
#End If
End Sub
This is the button on the Form that imports data into a SQL CE Database and optionally resets some data. It's the 'Are you sure you wish to overwrite' messagebox that causes the problem...
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim sqlEngine As SqlCeEngine
Dim cn As SqlCeConnection
Dim rda As SqlCeRemoteDataAccess
Dim Result As DialogResult
' Check with User if Data has been selected
If CheckBox1.Checked Then
Result = MessageBox.Show("Are you sure you wish to overwrite all the Data on this Device?", "Clear Data", MessageBoxButtons.OKCancel
If Result = DialogResult.Cancel Then
Return
End If
End If
Try
' Show Progress Bar
ProgressBar1.Visible = True
' Create Database
If (Not File.Exists("\My Documents\PmsCE.sdf")) Then
sqlEngine = New SqlCeEngine
sqlEngine.LocalConnectionS
"Data Source=\My Documents\PmsCE.sdf;" + _
"Password=Pipelines;"
sqlEngine.CreateDatabase()
sqlEngine.Dispose()
Else
' Open the Connection to the Database
cn = New SqlCeConnection("Data Source=\My Documents\PmsCE.sdf;" + _
"Password=Pipelines;")
cn.Open()
Dim cmd As SqlCeCommand = cn.CreateCommand() '
' Drop the Tables
cmd.CommandText = "DROP TABLE Pipeline"
cmd.ExecuteNonQuery()
cmd.CommandText = "DROP TABLE Personnel"
cmd.ExecuteNonQuery()
cmd.CommandText = "DROP TABLE ValveLocation"
cmd.ExecuteNonQuery()
cmd.CommandText = "DROP TABLE ValveGroup"
cmd.ExecuteNonQuery()
cmd.CommandText = "DROP TABLE ValveParameters"
cmd.ExecuteNonQuery()
' Drop Data Tables If Required
If CheckBox1.Checked Then
cmd.CommandText = "DROP TABLE HH_Street_Data"
cmd.ExecuteNonQuery()
cmd.CommandText = "DROP TABLE HH_Valve_Data"
cmd.ExecuteNonQuery()
End If
' Close the Connection
If cn.State <> ConnectionState.Closed Then
cn.Close()
End If
End If
' Calculate Increment, based on Data being Cleared
Dim increment As Single
If CheckBox1.Checked Then
increment = 15
Else
increment = 20
End If
' Instantiate the RDA Object
rda = New SqlCeRemoteDataAccess
' Use Release Defined Internet Logon & URL
rda.InternetLogin = InternetLogin
rda.InternetUrl = InternetUrl
rda.LocalConnectionString = _
"Data Source=\My Documents\PmsCE.sdf;" + _
"SSCE:Database Password=Pipelines;"
ProgressBar1.Value = increment
' Pull Template Tables from SQL Server & Tell Users
rda.Pull("Pipeline", "SELECT * FROM Pipeline", RemoteConnectString, + _
RdaTrackOption.TrackingOff
ProgressBar1.Value += increment
rda.Pull("Personnel", "SELECT Hand_Held_Logon, Hand_Held_Password FROM Personnel", RemoteConnectString, + _
RdaTrackOption.TrackingOff
ProgressBar1.Value += increment
rda.Pull("ValveLocation", "SELECT * FROM Valve_Location", RemoteConnectString, + _
RdaTrackOption.TrackingOff
ProgressBar1.Value += increment
rda.Pull("ValveGroup", "SELECT * FROM Valve_Group", RemoteConnectString, + _
RdaTrackOption.TrackingOff
ProgressBar1.Value += increment
rda.Pull("ValveParameters"
RdaTrackOption.TrackingOff
' Pull Data Tables If Required, Ensure No Data is Pulled
If CheckBox1.Checked Then
ProgressBar1.Value += increment
rda.Pull("HH_Street_Data",
RdaTrackOption.TrackingOnW
ProgressBar1.Value = 100 ' (Not exactly 100!)
rda.Pull("HH_Valve_Data", "SELECT * FROM HH_Valve_Data WHERE Date = ''", RemoteConnectString, + _
RdaTrackOption.TrackingOnW
End If
' Remove Progress Bar & Tell User
ProgressBar1.Visible = False
MessageBox.Show("Tables Imported OK")
Me.Dispose()
Catch sqlex As SqlCeException
ShowErrors(sqlex)
Catch ex As Exception
MessageBox.Show(ex.Message
Finally
rda.Dispose()
End Try
End Sub
This is the Form Load method, in case theirs anything that may affect it in there...
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
' If No Database Exists, Don't bother with Login
If Directory.Exists("\My Documents\PmsCE.sdf") Then
#If DEBUG Then
' Ignore Login for Debug
#Else
' Show Login Form & Hide Main Form
Me.Visible = False
Dim login As New Pms_Common.Pms_Login
login.ShowDialog()
' Determine if Login was OK
If (login.DialogResult = DialogResult.OK) Then
' Show Main Form
Me.Visible = True
' Store Sucessful Logon
Logon = login.ReturnLogon
Else
' End Program
Return
End If
#End If
End If
' Create Connection String, Logon & URL, based on Debug
#If DEBUG Then
RemoteConnectString = "Provider=SQLOLEDB;" + _
"Data Source=localhost;" + _
"UID=Pms;PWD=pipelines;" + _
"WSID=LAPTOP;" + _
"Database=Pms"
InternetLogin = "IUSR_LAPTOP"
InternetUrl = "http://192.168.1.13/VirtualDir/sscesa20.dll"
#Else
' Change to Production Configuration When Known
RemoteConnectString = "Provider=SQLOLEDB;" + _
"Data Source=localhost;" + _
"UID=Pms;PWD=pipelines;" + _
"WSID=LAPTOP;" + _
"Database=Pms"
InternetLogin = "IUSR_LAPTOP"
InternetUrl = "http://192.168.1.13/VirtualDir/sscesa20.dll"
#End If
End Sub
just a quick question
If CheckBox1.Checked Then
Result = MessageBox.Show("Are you sure you wish to overwrite all the Data on this Device?", "Clear Data", MessageBoxButtons.OKCancel , MessageBoxIcon.Exclamation , MessageBoxDefaultButton.Bu tton2)
If Result = DialogResult.Cancel Then
Return
End If
End If
when you cancel here, is the form redrawn correctly (is the messagebox gone) ?
If CheckBox1.Checked Then
Result = MessageBox.Show("Are you sure you wish to overwrite all the Data on this Device?", "Clear Data", MessageBoxButtons.OKCancel
If Result = DialogResult.Cancel Then
Return
End If
End If
when you cancel here, is the form redrawn correctly (is the messagebox gone) ?
ASKER
Yes. If you cancel the dialog the Form gets redrawn OK.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Sorry I didn't get back yesterday, I was on site all day.
Hooray! the DoEvents fixed it - Many thanks ptakja. Would anyone be offended if I awarded points Ronald as well as ptakja, as you can see he had a damn good try to find the problem!
Hooray! the DoEvents fixed it - Many thanks ptakja. Would anyone be offended if I awarded points Ronald as well as ptakja, as you can see he had a damn good try to find the problem!