CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 10 of 10
  1. #1
    Join Date
    Aug 2003
    Location
    Sydney, Australia
    Posts
    1,900

    [RESOLVED] Double Click on Command Button ?

    I am having trouble replicating the problem, but from what I am seeing seems to suggest that an operator has somehow caused a process to run twice - my only explanation at this point is that perhaps they have clicked twice on a command button, causing the process to repeat itself (and in doing so, mess up the results and file updates).
    When the operator completes the invoice they click on a command button which activates the CLICK Event

    eg, What if the operators mouse was programmed to do a double click every time it was clicked once ?

    Has anyone else had a similar experience (or am I completely on the wrong track)

    Appreciate any feedback - happens infrequently but when it happens I lose an invoice

  2. #2
    Join Date
    Mar 2002
    Location
    Croatia
    Posts
    275

    Re: Double Click on Command Button ?

    From your description I couldn't see how your question is related to VB6.
    If you have VB6 source, you can add some debug.print information to check an trace how your command button is executed twice.

  3. #3
    Join Date
    Aug 2003
    Location
    Sydney, Australia
    Posts
    1,900

    Re: Double Click on Command Button ?

    see next post
    Last edited by George1111; September 25th, 2012 at 08:17 AM.

  4. #4
    Join Date
    Aug 2003
    Location
    Sydney, Australia
    Posts
    1,900

    Re: Double Click on Command Button ?

    The button is a VB6 Command Button on a VB6 Form (I have all the source code - Its my program)
    The click event causes code to be run which I am starting to believe has been run twice
    Under windows you are able to configure the mouse to send a double click when a single click is made - I was just wondering if anyone had experienced anything similar
    Configuring the mouse click behaviour (in the Control Panel) does not care if you are running VB6, VB.Net or Launching Interent Explorer - it will send a double click if thats the way it is configured

    What I will try is to set a flag the instant that the command button is clicked, so that I can test if the procedure has been activated - this way I may be able to trap a "second" launch of the click event

    I was just interested to hear if anyone else had experienced something similar (or is my theory totally wrong)

    Thanks for your interest

  5. #5
    Join Date
    Mar 2002
    Location
    Croatia
    Posts
    275

    Re: Double Click on Command Button ?

    Something similar yes, but not exactly. Double execution in my case was caused by a complex code, from somewhere in the program event was re-fired. My approach was to trace some debug info to a log file, monitor code execution to find from which point it was re-fired.

  6. #6
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,362

    Re: Double Click on Command Button ?

    Haven't had a double click on the same button issue. I have had an issue where I had 2 panels one overlays the other and each with a button in the same location. When the button is clicked the top panel becomes invisible and sometimes the click will cause the button underneath to click also. I temporarly disable the underlying button to stop this from happening.

    I'm not sure a double click would fire the click event twice though. Several controls have both a click and a double click event and I have never saw the click event fire twice from a double click, it could be different with a button where there is no double click event to fire but then yoru problem could be elsewhere.

    You may try adding as the first line in your click event a line to disable the button then later on in that same event enable it again. This may take care of the problem if that is in fact what is happening.
    Always use [code][/code] tags when posting code.

  7. #7
    Join Date
    Jul 2001
    Location
    Sunny South Africa
    Posts
    11,283

    Re: Double Click on Command Button ?

    Strangely enough, it may also be the mouse itself. Especially Optical mouses ( mice ), I am battling with mine sometimes clicking twice when it is not supposed to. I'd also Disable the button after it was clicked on, as DM suggested. Another not so viable ( I suppose ) option would be to use the SystemParametersInfo API with the SPI_SETMOUSE to set the mouse double click speed

  8. #8
    Join Date
    Dec 2001
    Posts
    6,332

    Re: Double Click on Command Button ?

    Quote Originally Posted by HanneSThEGreaT View Post
    Strangely enough, it may also be the mouse itself. Especially Optical mouses ( mice ), I am battling with mine sometimes clicking twice when it is not supposed to. I'd also Disable the button after it was clicked on, as DM suggested. Another not so viable ( I suppose ) option would be to use the SystemParametersInfo API with the SPI_SETMOUSE to set the mouse double click speed
    I had a mouse that was double-clicking, and even moving the cursor at random. Just plain random clicks and moves - really messed things up if I let it persist. Turned out to be the chip in the mouse was going flaky. A new mouse solved it.

    As for setting the double-click speed, probably not a good idea to alter the user's system settings. Better just to check the value, and if it's way off, notify the user. But either way, disabling the button should solve it if the button is indeed being clicked twice. Although there is the question of how long before enabling the button again. A timer could be enabled at the end of the code within the click event, and the timer could then disable itself, and enable the button.
    Please remember to rate the posts and threads that you find useful.
    How can something be both new and improved at the same time?

  9. #9
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,362

    Re: Double Click on Command Button ?

    I had some issues with my mouse as well. I used to play a game which popped up a menu when you clicked the mouse then dissappeared when you clicked again. The mouse was hitting double clicks about 3 out of 4 times no matter how careful you were so what would happen is the menu would popup and dissappear before you could make a selection. Sometimes you would accidently make a selection depending on the exact position of the mouse at the time.

    Very frustrating but a new mouse fixed the issue.

    After doing some testing here with a command button it looks like that type of mouse problem could cause the button click to fire twice.
    Always use [code][/code] tags when posting code.

  10. #10
    Join Date
    Aug 2003
    Location
    Sydney, Australia
    Posts
    1,900

    Re: Double Click on Command Button ?

    Thanks guys

    I think I'll go with the disable button after click

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

Featured