Solved

Ignore MouseClicks and Keyboard Inputs

Posted on 2004-08-27
7
306 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
Comment Utility
After the me.Refresh() place an Application.DoEvents() and see if that makes a difference.

Idle_Mind
0
 

Author Comment

by:mebjen
Comment Utility
Thanks Idle_Mind,

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

mb
0
 

Author Comment

by:mebjen
Comment Utility
WOW -

Idle _Mind,

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

mb
0
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 
LVL 85

Expert Comment

by:Mike Tomlinson
Comment Utility
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
Comment Utility
idle_mind,

I'm already doing that -

Any other thoughts?

mb
0
 
LVL 85

Expert Comment

by:Mike Tomlinson
Comment Utility
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
Comment Utility
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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Visual xHarbour 1 74
count8 challlenge 13 85
Counting documents in a Domino View 3 32
index Out OF Range Exception error 4 27
I know it’s not a new topic to discuss and it has lots of online contents already available over the net. But Then I thought it would be useful to this site’s visitors and can have online repository on vim most commonly used commands. This post h…
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.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
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…

744 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now