Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
29275 Discussions

How can trap the double click on the wheel of a wheel mouse?

davidgraham
Beginner
974 Views
I'm using a wheel mouse in my graphics application.

I can scroll the wheel mouse to zoom in and out and if I hold the wheel mouse down I can pan. This is the same funcionality as AutoCAD.

I now want to be able to double click the wheel mouse to do an zoom extents. How do I detect that the user has double clicked the wheel mouse?


Below is a sample of code I'm using:

case (WM_MOUSEWHEEL)
i2=HIWORD(wParam)
if (i2>0) then ! zoom in
! get new screen extents
else ! zoom out
! get new screen extents
end if
! display graphics

case (WM_MBUTTONDOWN) ! middle button down store postion
mButtonDown=.TRUE.
mButtonE=LOWORD(lParam) ! store cursor position in client view
mButtonN=HIWORD(lParam)

case (WM_MBUTTONUP) ! middle button up
mButtonDown=.FALSE.


Thanks
0 Kudos
7 Replies
IanH
Honored Contributor III
974 Views
Handle the WM_MBUTTONDBLCLK (msdn link) message.
0 Kudos
Steven_L_Intel1
Employee
974 Views
If you're using QuickWin, we had a bug in the library which prevented double-click from being recognized. That was fixed in Update 6.
0 Kudos
davidgraham
Beginner
974 Views
Thanks,
I've tried WM_MBUTTONDBLCLK and it's bot being recognised, I am recognising WM_MBUTTONDOWN - a sample of my code is shown below.

case (WM_MBUTTONDOWN) ! middle button down store postion
call MsgBox ('Middle mouse button down'c,"E")
MainWndProc = 0
end if
return

case (WM_MBUTTONDBLCLK)
call MsgBox ('Middle mouse button double click'c,"E")
MainWndProc = 0
return

It is a Windows application, not a QuickWin application but the double-click is not being recognised.
How can I tell which version I'm running - the 'help about' just gives the version of Visual Studio.
0 Kudos
Steven_L_Intel1
Employee
974 Views
It is shown in the build log, or you can look at the detailed list of "Additional Products" in Help. But if you're not using QuickWin, then the bug I referred to does not apply to you.
0 Kudos
davidgraham
Beginner
974 Views
Thanks,

The build log says:
Compiling with Intel Visual Fortran Compiler XE 12.0.4.196 [IA-32]...

Do you have any suggestions why double clicking on the middle button on the mouse is not being recognised?
WM_MBUTTONDOWN and WM_MBUTTONUP are being recognised.

I've checked what message I'm getting - 519 & 520 for WM_MBUTTONDOWN & WM_MBUTTONUP which is Hex 207 & 208.

If I double click I just get a WM_MBUTTONDOWN followed by a WM_MBUTTONUP.

Maybe I will have to check on a 'Down' followed by an 'Up' over a 'short' time.
0 Kudos
Steven_L_Intel1
Employee
974 Views
MSDN sez:

Only windows that have the CS_DBLCLKS style can receive WM_MBUTTONDBLCLK messages, which the system generates when the user presses, releases, and again presses the middle mouse button within the system's double-click time limit. Double-clicking the middle mouse button actually generates four messages: WM_MBUTTONDOWN, WM_MBUTTONUP, WM_MBUTTONDBLCLK, and WM_MBUTTONUP again.

Does your window have the CS_DBLCLKS style?
0 Kudos
davidgraham
Beginner
974 Views
Steve,
Thanks, I hadn't read right to the bottom of the documentation.
I'm now getting the double clicks.
0 Kudos
Reply