CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 10 of 10
  1. #1
    Join Date
    Jul 2005
    Location
    Quebec, Canada
    Posts
    75

    Lightbulb Flushing the mouse buffer

    I would like to know how you can clear the mouse clicks. Here is my problem.

    I use an image as a button with mouse_move, mouse_up and mouse_down events. But what happens is that when I click once, if I click to fast a seconde time, the down effect of the button won't happen because the system taks the other click as a double click instead of a seperate new click.

    I would like to know if there is a way I can flush the last click so that the system does not count it as first click in a double click. In that case the button will reply to the mouse down event and not the mouse_dblclick event.

    Thanks in advance.
    David Richard

  2. #2
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: Flushing the mouse buffer

    Use a DoEvent() statement, to keep things moving, or use a new thread for the separate process. That's where VB.Net comes in handy.
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  3. #3
    Join Date
    Jul 2005
    Location
    Quebec, Canada
    Posts
    75

    Wink Re: Flushing the mouse buffer

    I cannot move to VB.NET so I need to work with VB6. All my applications are with VB6. The DoEvent does not work. I really need to flush the last click event of the mouse.

    Please do not suggest to move to VB.NET any more. I posted the request here in the VB6 forums because that is what I need. I know VB.NET is better and take's in charge a lot more stuff but I'm used to VB6 and that is the environment I am using.
    David Richard

  4. #4
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: Flushing the mouse buffer

    Then do it the VB6 way. As soon as they click once, DISABLE the click event.
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

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

    Re: Flushing the mouse buffer

    You could just place code in the double click event that calls the code ran by the mouse down. Assuming that the mouse down event is not already running when they do this. Seems simple enough.
    Always use [code][/code] tags when posting code.

  6. #6
    Join Date
    Jul 2005
    Location
    Quebec, Canada
    Posts
    75

    Re: Flushing the mouse buffer

    I cannot disable the click because the user needs to be able to click several times on the image. And, I cannot also use the DblClick event because there is no control over the mouse button pressed. I really need to flush the mouse buffer.

    I tried a lot of stuff and nothing works. I found out a small piece of code but it does not do exactly what I want.

    Code:
      Private Const PM_REMOVE = &H1
      Private Const WM_MOUSEFIRST = &H200
      Private Const WM_MOUSELAST = &H209
    
      Type POINT_TYPE
        x As Long
        y As Long
      End Type
      
      Private Type Msg
        hWnd As Long
        message As Long
        Wparam As Long
        Lparam As Long
        time As Long
        pt As POINT_TYPE
      End Type
    
      Private Declare Function PeekMessage Lib "user32" Alias "PeekMessageA" _
        (lpMsg As Msg, ByVal hWnd As Long, ByVal wMsgFilterMin As Long, _
        ByVal wMsgFilterMax As Long, ByVal wRemoveMsg As Long) As Long
    
    Public Sub ClearMouseBuffer(ByVal oFrm As Form)
      
      Dim MOUSE_MSG As Msg
        
      PeekMessage MOUSE_MSG, oFrm.hWnd, WM_MOUSEFIRST, WM_MOUSELAST, PM_REMOVE
      
    End Sub
    If someone has an idea, this will help me a lot.

    Thanks for your comments and time for trying to help me out.
    David Richard

  7. #7
    Join Date
    Jan 2012
    Posts
    1

    Re: Flushing the mouse buffer

    Quote Originally Posted by avidichard View Post
    I would like to know how you can clear the mouse clicks. Here is my problem.

    I use an image as a button with mouse_move, mouse_up and mouse_down events. But what happens is that when I click once, if I click to fast a seconde time, the down effect of the button won't happen because the system taks the other click as a double click instead of a seperate new click.

    I would like to know if there is a way I can flush the last click so that the system does not count it as first click in a double click. In that case the button will reply to the mouse down event and not the mouse_dblclick event.

    Thanks in advance.
    I've your same problem , have you found a solution ? Many thanks

  8. #8
    Join Date
    Jul 2005
    Location
    Quebec, Canada
    Posts
    75

    Re: Flushing the mouse buffer

    No I did not find a solution in that direction. I did do a work arround but it does not relate to this. I had to find another solution much more complexe which does not not implicate mouse clicks.

    Sorry, I did not find anything.
    David Richard

  9. #9
    Join Date
    Jul 2006
    Location
    Germany
    Posts
    3,725

    Re: Flushing the mouse buffer

    Yes, I had the same problem. DataMiser's idea is right.

    What I did:
    Code:
    Private sub imgButton_DblClick()
      imgButton_MouseDown 0,0,0,0
    End Sub
    The double-click is then retransfered to the mouse_down() code.
    It worked very well for me. I could then click as fast as possible to achieve all mose-down code.
    Very easy solution...

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

    Re: Flushing the mouse buffer

    Quote Originally Posted by WoF View Post
    Yes, I had the same problem. DataMiser's idea is right.

    What I did:
    Code:
    Private sub imgButton_DblClick()
      imgButton_MouseDown 0,0,0,0
    End Sub
    The double-click is then retransfered to the mouse_down() code.
    It worked very well for me. I could then click as fast as possible to achieve all mose-down code.
    Very easy solution...
    Very nice indeed. Thanks for teaching me this as well

Tags for this Thread

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