Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

MessageBox.Show Difference between VB .NET CE Device Emulator and actual CE Device

Posted on 2004-11-29
17
Medium Priority
?
265 Views
Last Modified: 2010-04-23
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
0
Comment
Question by:VFPSQLDeveloper
  • 8
  • 8
17 Comments
 
LVL 25

Expert Comment

by:RonaldBiemans
ID: 12695619
Have you tried invalidating your form ?
0
 

Author Comment

by:VFPSQLDeveloper
ID: 12695771
Hi Ronald,

How do you do that?

Chris
0
 
LVL 25

Expert Comment

by:RonaldBiemans
ID: 12695808
me.invalidate
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Comment

by:VFPSQLDeveloper
ID: 12695932
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
 
LVL 25

Expert Comment

by:RonaldBiemans
ID: 12695973
Hi VFPSQLDeveloper,

The progressbar displays over the dialogbox ?

Do you use a panel somewhere in your form ?
0
 

Author Comment

by:VFPSQLDeveloper
ID: 12696033
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
 
LVL 25

Expert Comment

by:RonaldBiemans
ID: 12696059
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
 

Author Comment

by:VFPSQLDeveloper
ID: 12696197
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
 
LVL 25

Expert Comment

by:RonaldBiemans
ID: 12696260
It gets stranger by the minute :-), ok remove the hide, and could you try

me.resumelayout
me.invalidate
0
 

Author Comment

by:VFPSQLDeveloper
ID: 12696304
I don't see any properties for the form like resumelayout.
0
 
LVL 25

Expert Comment

by:RonaldBiemans
ID: 12696799
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
 

Author Comment

by:VFPSQLDeveloper
ID: 12697353
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
 
LVL 25

Expert Comment

by:RonaldBiemans
ID: 12697428
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
 

Author Comment

by:VFPSQLDeveloper
ID: 12697592
Yes. If you cancel the dialog the Form gets redrawn OK.
0
 
LVL 25

Assisted Solution

by:RonaldBiemans
RonaldBiemans earned 400 total points
ID: 12703557
Sh*t, I still can't recreate your problem on my IPac. Where did you put the me.invalidate ?
0
 
LVL 14

Accepted Solution

by:
ptakja earned 1600 total points
ID: 12705805
Try Application.DoEvents after the dialog box closes. I had the same problem on a PocketPC-based Symbol scanner. That fixed it.

0
 

Author Comment

by:VFPSQLDeveloper
ID: 12713633
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

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question