Solved

Ignore MouseClicks and Keyboard Inputs

Posted on 2004-08-27
7
308 Views
Last Modified: 2010-04-17
Guru's,

My windowsApp (vs2003 / vb.NET) has a buttonClickEvent reads each row in a dataTable, and is controled via a thread.sleep(1000) - and the screen refreshes via me.Refresh() - to update different textBoxes

Problem - while this is going if a mouseClick or keyBoardEnter is pressed - the mouse turns to a wait (or hourGlass) and the textBoxes cease to refresh - until the last dataRow is read - then the cursor(wait) turns back to an arrow and we're good to go.

Is there a way for me to ignore keyboard and mouseClick inputs - during this??

mb
0
Comment
Question by:mebjen
  • 4
  • 3
7 Comments
 
LVL 85

Accepted Solution

by:
Mike Tomlinson earned 125 total points
ID: 11918244
After the me.Refresh() place an Application.DoEvents() and see if that makes a difference.

Idle_Mind
0
 

Author Comment

by:mebjen
ID: 11918271
Thanks Idle_Mind,

I'm going to have to bone up on the Application.DoEvents() -

mb
0
 

Author Comment

by:mebjen
ID: 11918284
WOW -

Idle _Mind,

It works great for mouseClicks but not for the ENTER key on the keyboard.

mb
0
Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

 
LVL 85

Expert Comment

by:Mike Tomlinson
ID: 11918305
If the button that initiates the process was the last control to have the focus, (which it most likely is if you just clicked it...) then when you press enter, it will click it again.  This may be causing the problem.

To avoid this, disable the button when it is clicked and then reenable it after your process is complete:

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Button1.Enabled = False

        ' do some stuff in here....

        Button1.Enabled = True
    End Sub

Idle_Mind
0
 

Author Comment

by:mebjen
ID: 11918318
idle_mind,

I'm already doing that -

Any other thoughts?

mb
0
 
LVL 85

Expert Comment

by:Mike Tomlinson
ID: 11918343
I would have to know more about the form layout and see the code to make any other suggestions.

Idle_Mind
0
 

Author Comment

by:mebjen
ID: 11918389
Idle_Mind,

Hopefully this will help, it's only the buttonClick -

The application has over 5000 lines of code -

Private Sub btnSimTempInc_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSimTempInc.Click
        btnSimTempInc.Enabled = False
       tbxLF1.Text = ""
        tbxLF2.Text = ""
        tbxLF3.Text = ""
        tbxLF1.BackColor = Color.White
        tbxLF2.BackColor = Color.White
        tbxLF3.BackColor = Color.White
        lblLFInfMsg.BackColor = Color.White
        lblLFInfMsg.Text = ""
        Dim tbl As DataTable = dsSimTempInc.Tables(0)
        Dim row As DataRow
        For Each row In tbl.Rows
            Thread.Sleep(1000)
           
            If row(1).ToString = 1 Then
                   
                If row(5) Is DBNull.Value Then
                    tLF.EdgeColor = Color.Green
                    tbxLF1.Text = row(2).ToString
                    tbxLF2.Text = row(3).ToString
                    tbxLF2.BackColor = Color.White
                    If row(4) > 0 Then
                        tbxLF3.Text = "+ " & row(4).ToString
                    Else
                        tbxLF3.Text = row(4).ToString
                    End If

                Else
                   
                    tbxLF1.Text = row(3).ToString
                    tbxLF2.Text = row(5).ToString
                    If row(7) > 0 Then
                        tbxLF3.Text = "+ " & row(7).ToString
                    Else
                        tbxLF3.Text = row(7).ToString
                    End If
                   
                    Select Case row(2)
                        Case Is = 1
                            tbxLF1.BackColor = Color.Yellow

                        Case Is = 2
                            tbxLF1.BackColor = Color.Yellow

                        Case Is = 3
                            tbxLF1.BackColor = Color.Red

                        Case Is = 4
                            tbxLF1.BackColor = Color.Red

                    End Select
                   
                    Select Case row(4)
                        Case Is = 2
                            tbxLF2.BackColor = Color.Yellow
                        Case Is = 4
                            tbxLF2.BackColor = Color.Red
                    End Select
                   
                    Select Case row(6)
                        Case Is = 1
                            lblLFInfMsg.Text = "test1"
                            lblLFInfMsg.ForeColor = Color.Black
                            lblLFInfMsg.BackColor = Color.Yellow
                            lblLFInfMsg.Visible = True
                            tbxLF3.BackColor = Color.Yellow
                        Case Is = 2
                            lblLFInfMsg.Text = "test2"
                            lblLFInfMsg.ForeColor = Color.Black
                            lblLFInfMsg.BackColor = Color.Yellow
                            lblLFInfMsg.Visible = True
                            tbxLF3.BackColor = Color.Yellow
                        Case Is = 3
                            lblLFInfMsg.Text = "test3"
                            lblLFInfMsg.ForeColor = Color.Black
                            lblLFInfMsg.BackColor = Color.Red
                            lblLFInfMsg.Visible = True
                            tbxLF3.BackColor = Color.Red
                        Case Is = 4
                            lblLFInfMsg.Text = "test1"
                            lblLFInfMsg.ForeColor = Color.Black
                            lblLFInfMsg.BackColor = Color.Red
                            lblLFInfMsg.Visible = True
                            tbxLF3.BackColor = Color.Red
                    End Select
                   
                    If row(2) < 3 And row(4) < 3 And row(6) < 3 Then
                        tLF.EdgeColor = Color.Yellow
                    Else
                        tLF.EdgeColor = Color.Red
                    End If
                End If
            End If
            Me.Refresh()
            Application.DoEvents()
        Next
               btnSimTempInc.Enabled = True
           End Sub


mb
0

Featured Post

ScreenConnect 6.0 Free Trial

Want empowering updates? You're in the right place! Discover new features in ScreenConnect 6.0, based on partner feedback, to keep you business operating smoothly and optimally (the way it should be). Explore all of the extras and enhancements for yourself!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
C Programming - If Statement 8 78
C# Error - Add Failed 12 89
Regular Expression Calculator Tester 2 74
Math Equation 23 88
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Computer science students often experience many of the same frustrations when going through their engineering courses. This article presents seven tips I found useful when completing a bachelors and masters degree in computing which I believe may he…
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

831 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