Jump to content

WM_MOUSEHOVER message


rasim
 Share

Recommended Posts

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?

Link to comment
Share on other sites

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"

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...