Sign in to follow this  
Followers 0
rasim

WM_MOUSEHOVER message

5 posts in this topic

Hi! Anyone help me withs this code. I try to use WM_MOUSEHOVER message, but unsuccessful :)

#include <GUIConstants.au3>

Global Const $WM_MOUSEHOVER = 0x02A1

Global Const $TME_HOVER = 0x1
Global Const $TME_LEAVE = 0x2
Global Const $TME_NONCLIENT = 0x10
Global Const $TME_QUERY = 0x40000000
Global Const $TME_CANCEL = 0x80000000

$hGui = GUICreate("Test GUI", 160, 50)

$button1 = GUICtrlCreateButton("Button1", 10, 10, 50, 25)

$button2 = GUICtrlCreateButton("Button2", 100, 10, 50, 25)

$TRACKMOUSEEVENT = DllStructCreate("dword Size;dword EventFlags;hwnd hwndTrack;dword HoverTime")

DllStructSetData($TRACKMOUSEEVENT, 1, 255)
DllStructSetData($TRACKMOUSEEVENT, 2, $TME_HOVER)
DllStructSetData($TRACKMOUSEEVENT, 3, $hGui)
DllStructSetData($TRACKMOUSEEVENT, 4, 30)
    
$MouseEvent = DllCall("user32.dll", "int", "TrackMouseEvent", "ptr", DllStructGetPtr($TRACKMOUSEEVENT))
ConsoleWrite($MouseEvent[0] & @LF) ;Always returned nul :(

GUIRegisterMsg($WM_MOUSEHOVER, "WM_MOUSEHOVER")

GUISetState()

While 1
    $msg = GUIGetMsg()
    Switch $msg
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

Func WM_MOUSEHOVER($hWnd, $Msg, $wParam, $lParam)
    
    ConsoleWrite($wParam & @LF)
    
    Return $GUI_RUNDEFMSG
EndFunc

What`s wrong?

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

1) TrackMouseEvent call fails, because you set incorrect Size value in TRACKMOUSEEVENT structure. If you can't add up the elements manually, use DllStructGetSize($TRACKMOUSEEVENT).

2) For it to actually work (to generate WM_MOUSEHOVER message), the mouse has to be inside GUI at the time you call TrackMouseEvent. Which also assumes the GUI is visible at the time.

Edited by Siao

"be smart, drink your wine"

Share this post


Link to post
Share on other sites

Yes! :) Now this works! Thank you! Siao the best! ;)

Share this post


Link to post
Share on other sites

Oh! Thanks Gary! :)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0