Solved

Ignore MouseClicks and Keyboard Inputs

Posted on 2004-08-27
7
309 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
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 
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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

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.
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

856 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