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.Button2)
            If Result = DialogResult.Cancel Then
VFPSQLDeveloperAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

RonaldBiemansCommented:
Have you tried invalidating your form ?
0
VFPSQLDeveloperAuthor Commented:
Hi Ronald,

How do you do that?

Chris
0
RonaldBiemansCommented:
me.invalidate
0
Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

VFPSQLDeveloperAuthor Commented:
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.
0
RonaldBiemansCommented:
Hi VFPSQLDeveloper,

The progressbar displays over the dialogbox ?

Do you use a panel somewhere in your form ?
0
VFPSQLDeveloperAuthor Commented:
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??!!
0
RonaldBiemansCommented:
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.
0
VFPSQLDeveloperAuthor Commented:
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.
0
RonaldBiemansCommented:
It gets stranger by the minute :-), ok remove the hide, and could you try

me.resumelayout
me.invalidate
0
VFPSQLDeveloperAuthor Commented:
I don't see any properties for the form like resumelayout.
0
RonaldBiemansCommented:
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
0
VFPSQLDeveloperAuthor Commented:
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.Button2)
            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.LocalConnectionString = _
                   "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.TrackingOffWithIndexes, "PipelineErrorTable")
            ProgressBar1.Value += increment
            rda.Pull("Personnel", "SELECT Hand_Held_Logon, Hand_Held_Password FROM Personnel", RemoteConnectString, + _
                        RdaTrackOption.TrackingOffWithIndexes, "PersonnelErrorTable")
            ProgressBar1.Value += increment
            rda.Pull("ValveLocation", "SELECT * FROM Valve_Location", RemoteConnectString, + _
                        RdaTrackOption.TrackingOffWithIndexes, "ValveLocationErrorTable")
            ProgressBar1.Value += increment
            rda.Pull("ValveGroup", "SELECT * FROM Valve_Group", RemoteConnectString, + _
                        RdaTrackOption.TrackingOffWithIndexes, "ValveGroupErrorTable")
            ProgressBar1.Value += increment
            rda.Pull("ValveParameters", "SELECT * FROM Valve_Parameters", RemoteConnectString, + _
                        RdaTrackOption.TrackingOffWithIndexes, "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.TrackingOnWithIndexes, "HHStreetDataErrorTable")
                ProgressBar1.Value = 100    ' (Not exactly 100!)
                rda.Pull("HH_Valve_Data", "SELECT * FROM HH_Valve_Data WHERE Date = ''", RemoteConnectString, + _
                        RdaTrackOption.TrackingOnWithIndexes, "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
0
RonaldBiemansCommented:
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.Button2)
            If Result = DialogResult.Cancel Then
                Return
            End If
        End If

when you cancel here, is the form redrawn correctly (is the messagebox gone) ?
0
VFPSQLDeveloperAuthor Commented:
Yes. If you cancel the dialog the Form gets redrawn OK.
0
RonaldBiemansCommented:
Sh*t, I still can't recreate your problem on my IPac. Where did you put the me.invalidate ?
0
ptakjaCommented:
Try Application.DoEvents after the dialog box closes. I had the same problem on a PocketPC-based Symbol scanner. That fixed it.

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
VFPSQLDeveloperAuthor Commented:
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!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.