Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Mousedown fires, Mouseup does not

Status
Not open for further replies.

Glasgow

IS-IT--Management
Jul 30, 2001
1,669
GB
I have a datagrid with code for MouseUp event. I find that, under some circumstances, this event does not fire when I am right clicking the control. The Mousedown event, on the other hand, fires consistently.

Does anyone have any explanation for this?

Thanks in advance.
 
If you click on a control then the MouseDown fires immediately. However, if you move off the control before releasing the mouse then MouseUp does not fire.
 
Thanks Golom but that's not it. I am doing simple (and often multiple repeated) clicks and MouseUp fails to fire.
 
Multiple clicks? Perhaps you're clicking too quickly. I've noticed that when using the mouse up and down events, it's often necessary to click slower. I'd be interested to hear if anyone has a solution.

[fish] No Dolphins were harmed in the posting of this message... Dolphin Friendly Tuna!

Ever feel like you're banging your head against a tree? I did, so I cut down the tree.
 
No, sorry, the multiple clicks were just out of sheer frustration! The event also fails to fire on a single click.
 
Just as a simple test, I did this
[blue][tt]
Private Sub DBGrid1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If LastMove <> "UP" Then Debug.Print "MouseDown", X, Y, LastMove
LastMove = "DOWN"
End Sub

Private Sub DBGrid1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
If LastMove <> "DOWN" Then Debug.Print "MouseUp", X, Y, LastMove
LastMove = "UP"
End Sub
[/tt][/blue]
and discovered that by rapid clicks I can cause it to miss MouseDown events. MouseUp always seems to occur. At slower click rates or with single clicks I get both events. I'm wondering if there's a buffering problem where Windows is capturing the mouse click but can't pass it back to VB as fast as I can click the mouse.
 
Thanks for further input.

I really don't think my problem has anything to do with the speed of the click(s). The only way I can get the code to reliably behave as I want (i.e. fire the MouseUp event) is to force a setfocus on the grid in its MouseDown event. Without that, it only tends to work if I manually left click on the grid before the right click.
 
Oh wait... I overlooked that it was a right click... that makes me wonder.

I wish I had VB installed on this pc so I could do some things.

I'll get back to you tonight

[fish] No Dolphins were harmed in the posting of this message... Dolphin Friendly Tuna!

Ever feel like you're banging your head against a tree? I did, so I cut down the tree.
 
One thing that may help is if you could tell us what your doing on mouse down? You state that sometimes it works as expected and sometimes it does not. Is there any consistancy with which it works/does not work?
 
>Just as a simple test

Um...your code will fail to report MouseDown events apart from the very first one...
 
bmdb:

On right click I am displaying a menu of options associated with the grid. With regards to consistency - although I have now implemented my 'setfocus' fix/bodge, my recollection is that once the focus had moved from the grid, the MouseUp event stopped firing until focus was re-established via a left click.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top