Results 1 to 12 of 12

Thread: Ignoring events

  1. #1

    Thread Starter
    I wonder how many charact
    Join Date
    Feb 2001
    Location
    Savage, MN, USA
    Posts
    3,704

    Ignoring events

    I have some dynamically created forms...

    problem is (during test I did this), if you keep blindly clicking you sometimes BOUNCE - click (best way to describe it), so the mouse fires another event before the button is actually created, resulting in some errors in my program since the button contains data necessary to move on....

    So how do I tell my application to throw any click events out the window until its ready to receive them?

  2. #2
    Fanatic Member VBCrazyCoder's Avatar
    Join Date
    Apr 2003
    Posts
    681
    Can you just set a form level variable (blnAcceptClick). Set it to false when you want to ignore clicks, and set to True when you want to accept them. Then in you click event handler you would test the blnAcceptClick and if false then Exit Sub - otherwise proceed.

    Hope that helps.

  3. #3
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913
    Are you using WithEvents as part of your dynamic creation. If so, maybe you should consider using AddHandler to manually link events and not AddHandler for the click events until you are ready.
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

  4. #4

    Thread Starter
    I wonder how many charact
    Join Date
    Feb 2001
    Location
    Savage, MN, USA
    Posts
    3,704
    I was using AddHandler....

    and I moved it into the Form Activated event... same problem.

    Seems like either the event is firing twice from the old form...

    Anyway its really irking me because it never happens when I try it in debug mode... (i'm attributing that to perhaps the program is running slower, although I can't physically tell the difference in speed)...

    Unzip the following project.... http://www.sofa.com/dc.zip

    Open the unzip folder...

    execute the DinesenBravo shortcut first....

    Then run the WindowsApplicatino13 shortcut....

    Hit Start... New Sale .... (any sales rep)... any customer... (hit OK)...

    When you get to the invoice screen... hit New Item
    Click on the Jaymar button as fast as you can.... (clickin in the same spot)...

    After the error occurs... do it again but this time at normal speed... it works...

  5. #5
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913
    When I click the Jaymar button, it goes directly to another screen etrememly fast. You cant click on Jaymar fast enough. Not humanly possible.
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

  6. #6

    Thread Starter
    I wonder how many charact
    Join Date
    Feb 2001
    Location
    Savage, MN, USA
    Posts
    3,704
    Oh just keep trying... you'll get it

    No, its not a serious flaw... but it can happen... and no it doesn't crash the application... and the user could just try again... but it just irks me it exists...

  7. #7
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913
    No really. It is not possible to click Jaymar more than once on my system in a row. It is too fast. Like I said, no human could do it.
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

  8. #8
    Fanatic Member VBCrazyCoder's Avatar
    Join Date
    Apr 2003
    Posts
    681
    Maybe configure your mouse so that the right or left button acts as a double click. Then try it.

  9. #9

    Thread Starter
    I wonder how many charact
    Join Date
    Feb 2001
    Location
    Savage, MN, USA
    Posts
    3,704
    Can anyone else duplicate this behavior or is it just my Dell Optiplex?

  10. #10
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913
    Why not in the click event, go ahead and disable the image button, or something like that as the first line of code in the event?
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

  11. #11

    Thread Starter
    I wonder how many charact
    Join Date
    Feb 2001
    Location
    Savage, MN, USA
    Posts
    3,704
    Cander, yes when you click the button it goes to the next screen, but that's ok, because then you begin to replicate the behavior... keep clickin at the same spot.... and you'll go threw 2 more screens before you hit an error...

  12. #12
    Fanatic Member
    Join Date
    Sep 2002
    Posts
    518
    How about
    VB Code:
    1. If Sender Is btnFoo Then
    2.     MessageBox.Show("Boing")
    3. End If

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width