Solved

Ignore MouseClicks and Keyboard Inputs

Posted on 2004-08-27
7
310 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Recommendation vb6 to vb.net or others 14 205
Base1 Encode/Decode 3 86
egit plugin on eclipse 8 99
some keys in my laptop is not working. any suggestion 6 48
Displaying an arrayList in a listView using the default adapter is rarely the best solution. To get full control of your display data, and to be able to refresh it after editing, requires the use of a custom adapter.
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
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 …

749 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