System Tray Click and Double click

I would like to use both Click and Double click on my applications system tray icon.  I'm using the common Shell_NotifyIcon API to create the icon and Form_MouseMove to detect any mouse operations that accure.

The problem is that I'm unable to find a way to determan if a mouse event was a single click or a double click since there is no WM_LButtonClick constant.  If I check for LButtonDown or LButtonUp the events both accure with a double click aswell.

Is there anyway to know if the user clicked knowing it was not supposed to be a double click?
KnarfAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
webJoseConnect With a Mentor Commented:
A Click is a concept added in VB.  There is no WM_LBUTTONCLICK message.  Instead, the order of messages and the mouse coordinates are examined to determine if a Click is in order.  For example, a command button will only raise the Click event if the mouse goes down and then up while the mouse cursor is inside the client area of the button.  The window procedure logic for this is something like:

Select case uMsg
    Case WM_LBUTTONDOWN
        m_Pressed = true
        SetCapture hWnd
        Refresh
    CASE WM_MOUSEMOVE
        m_Pressed = MouseCoordsInsideClientArea(hwnd, lParam)
        Refresh
    Case WM_LBUTTONUP:
        if m_Pressed and MouseCoordsInsideClientArea(hwnd, lParam) then
            m_Pressed = false
            ReleaseCapture
            Refresh
            raiseevent Click
            raiseevent MouseUp
        end if
...

As you can see, Click is MouseUp under certain conditions.
0
 
Ryan ChongCommented:
No, both method are supported, here is the constant values you want:

Private Const WM_LBUTTONDBLCLK = &H203
Private Const WM_LBUTTONUP = &H202
Private Const WM_LBUTTONDOWN = &H201
Private Const WM_RBUTTONUP = &H205

as more if you need help.
0
 
kalihtoCommented:
0
 
KnarfAuthor Commented:
Not a bad approach.  I actually did it a different way. I took the systems double click speed and I waited that long before executing the click command.  

If I double click was producted during the systems double click duration then the click event would not activate.

Its not exactly pretty but it works.
0
All Courses

From novice to tech pro — start learning today.