• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 398
  • Last Modified:

Extra mouse messages on double-click...

I've got an MDI application in which I am processing left-mouse button messages.  When I get a LButtonDblClk message, for some reason I also get a MouseMove message.  Stranger yet, if I put a Sleep(100) call inside my LButtonDblClk handler I DON'T get the Mouse Move message. Could someone enlighten me here?  Thank you.
0
salamander
Asked:
salamander
  • 6
  • 3
  • 3
  • +2
1 Solution
 
galkinCommented:
I guess when you double click you move mouse pointer slightly so you get WM_MOUSEMOVE as well. If you call Sleep you suspend active thread associated with a window so it doesn't process WM_MOUSEMOVE
0
 
salamanderAuthor Commented:
Not so fast... that was the first thing I checked when I saw this problem.  I made sure the mouse was absolutely unable to move - it still occurs.
0
 
psdavisCommented:
What I do for all mouse messages is capture the initial location of the mouse down message.  Inside of my MouseMove, I can tell how far the mouse has actually moved by comparing against the MouseMove location.  If it is insignificant, I ignore the MouseMove message.  Then restore the initial location to CPoint( 0, 0 ) in the MouseUp message.

Phillip

0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
psdavisCommented:
Sorry about the answer, but I can't tell you why you won't get the message if you throw a sleep message in your double click handler.  

Phillip
0
 
salamanderAuthor Commented:
No need to apologize about the answer, it's just not the one I'm looking for.  I will just leave the Sleep()-hack in the code for now, but not knowing why the message is there is KILLING me.  If I step through the LButtonDblClick code in the debugger, I also get no problem.  I just have to find out why it's happening... for my own sake.
0
 
duneramCommented:
Windows just generates them.  When I used to install JournalRecordHooks and catch mouse messages I found I would get hundreds of WM_MOUSEMOVES even if I didn't move the mouse.  I wrote a filter that removed them and it had no effect on when I did the Journal playback hook.

I suspect the device driver is polling and posting this event on a regular basis.  


0
 
salamanderAuthor Commented:
Hmmmm... this seems very strange.  Why would the device driver poll the mouse?  Wouldn't that be a terribly inefficient use of processor time?
0
 
psdavisCommented:
Windows? Inefficient use of processor time?  Never heard of that! :)

0
 
salamanderAuthor Commented:
:)  Ah, yes...
0
 
duneramCommented:
there ya go
0
 
duneramCommented:
when you put the sleep there, someone else is getting the mouse move's.  they're always being generated.  doing the sleep lets another thread/process have some time.  If the RIT (RAw input Thread) switches during that sleep (by the other thread/process), that new one will be receiving the mouse messages.  Its possible the desktop is getting them when you do the sleep.  
0
 
AlFaCommented:
I think it's a programming shortcut from window!
to generate a WM_LBUTTONDBLCLK message it need to have generated a WM_LBUTTONDOWN and a WM_LBUTTONUP when the second click happend the system transforms WM_LBUTTONDOWN into WM_LBUTTONDBLCLK  and the WM_LBUTTONUP  into WM_MOVE just to get rid of it. On NT 4.1 you got WM_LBUTTONDOWN WM_LBUTTONUP WM_LBUTTONDBLCLK  (it was a bug)!....
0
 
salamanderAuthor Commented:
Is this a confirmed bug in Win95?  I would feel bad giving points to you for an answer which doesn't appear to be any more set in stone than the others.  I just don't want to give points to anyone before we know what the true culprit is...
0
 
AlFaCommented:
I do not thing i said it was a win 95 bug. It is easier to transform a message than remove it. I've refered to the dble click bug of NT 4.1 wicth didn't do such a tranformation.
receiving a mousemove msg with no move shoudn't stress a program.
0
 
salamanderAuthor Commented:
Ahhh... I'd forgotten about this problem entirely.  I ended up setting a boolean flag to true on LBUTTONDBLCLICK, setting it to false on LBUTTONUP.  This way I simply had and "if(!DblClkFlag)" statement in LBUTTONDOWN and everything ran great.  I would suggest the same to anyone reading this who has the same problem.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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.

  • 6
  • 3
  • 3
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now