I am playing with some win32 api gui code. Now, i would like to create a mouse click & double click event for my gui library. I've read that one would need to deal with four type of mouse messages to implement this feature.
For a single click -
WM_LBUTTONDOWN
WM_LBUTTONUP
And for a double click --
WM_LBUTTONDOWN
WM_LBUTTONUP
WM_LBUTTONDOWN
WM_LBUTTONUP
And if you set the CS_DBLCLK style in your window class--
WM_LBUTTONDOWN
WM_LBUTTONUP
WM_LBUTTONDBLCLK
WM_LBUTTONUP
I've also read that one would need to enable a timer and get the mouse pointer location to handle these messages. So these are my questions--
1. Is there a better way to do this ?
2. Assume that if i started a timer and collect the mouse position in WM_LBUTTONDOWN, then, Can i call my leftBtnDown event at that space ? I mean, i can elaborate the idea with this code
This is a part of my window type
Code: Select all
' these are events
leftBtnDown As UINT
leftBtnUp As UINT
leftClick As UINT
leftDblClick As UINT
' these are event handling function pointers
' this is just pseudo code, and only for expressing my idea
onLeftDown As function Ptr
onLeftUp As function Ptr
onLeftClick As function Ptr
onLeftDblClick As function Ptr
Code: Select all
case WM_LBUTTONDOWN
'start a timer
'collect the mouse position and stores it in a variable
'set a boolean variable
'So, after these three steps, can i call my event function here or just finish processing this message
' like
onLeftDown(e As EventArgs)
case WM_LBUTTONUP
' Here, i need to check the timer's time. But i dont know which is the maximum allowed interval time between mouse down and up
' If i call my mouse click event function here, then, can i call my left button up event function here ?
if conditions are true then
onLeftClick(e As EventArgs)
end if
onLeftUp(e As EventArgs)