MrCreatoR

GUICtrlSetOnHover UDF!

146 posts in this topic




#2 ·  Posted (edited)

Excellent Job, this is a lot like I had in mind... but using Picasso's Callback.au3 was a nice touch!

Edit:

I can see this:

$HOVER_CONTROLS_ARRAY[$Ubound][0] = GUICtrlGetHandle($CtrlID)

Maybe causing issues with Multiple GUI's?

Edit2:

And this will definately collide with anything I write:

Opt("OnExitFunc", "CallBack_Exit")

Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites

Thanks SmOke_N!

I can see this:

$HOVER_CONTROLS_ARRAY[$Ubound][0] = GUICtrlGetHandle($CtrlID)

Maybe causing issues with Multiple GUI's?

Yes it can, i thouth about it to, i think adding GUISwitch(WinGetHandle("")) and ControlGetHandel("", "", $CursorInfo[4]) can fix the problem... but then only forground window will handle the hovering...

I realy can't see perfect solution for this one... but if we use properly the child windows...

#include <GUICtrlSetOnHover_UDF.au3>

$Gui = GuiCreate("GUICtrlSetOnHover DEMO (With Child GUI)", 280, 200)

$Button = GUICtrlCreateButton("Show Child", 20, 160)
GUICtrlSetOnHover(-1, "Hover_Func", "Leave_Hover_Func")

GUISetState()

While 1
    $Msg = GUIGetMsg()
    Switch $Msg
        Case -3
            Exit
        Case $Button
            GUISetState(@SW_DISABLE, $Gui)
            $Child_Gui = GUICreate("Child", 150, 100, -1, -1, -1, -1, $Gui)
            $Child_Button = GUICtrlCreateButton("Child Button", 20, 20)
            GUICtrlSetOnHover(-1, "Hover_Func", "Leave_Hover_Func")
            
            GUISetState(@SW_SHOW, $Child_Gui)
            
            While GUIGetMsg() <> -3
            WEnd
            
            GUISetState(@SW_ENABLE, $Gui)
            GUIDelete($Child_Gui)
            GUISwitch($Gui)
    EndSwitch
WEnd

Func Hover_Func($CtrlID)
    Switch $CtrlID
        Case $Button, $Child_Button
            If GUICtrlRead($CtrlID) <> "New Button" Then GUICtrlSetData($CtrlID, "New Button")
    EndSwitch
EndFunc

Func Leave_Hover_Func($CtrlID)
    Switch $CtrlID
        Case $Button, $Child_Button
            If GUICtrlRead($CtrlID) <> "Button" Then GUICtrlSetData($CtrlID, "Button")
    EndSwitch
EndFunc

Everything will be OK ;) - But again, it's not perfect, sometimes we need to handle child window on the same "level" as the parent window...

And this will definately collide with anything I write

I do not know any way to do this without involve the host script :) - but maybe realy not needed to stop the timer after the script is exit, i think it will stop by itself, since (as far as i know) all the handles are closed before script exits.. maby here is the same? what you think?

 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Share this post


Link to post
Share on other sites

Awesome job!

Share this post


Link to post
Share on other sites

Nice. It should be included in the AutoIt installation in my opinion.

Share this post


Link to post
Share on other sites

I actually haven't test this, but if this is working its soo awesome.

I'll definitely use it!

After some bugfixing and errorchecking this UDF should be included into the AutoIt-Package!

greetings,

Pascal

Share this post


Link to post
Share on other sites

Hi...i think there is a problem if it`s over an image...the leave hover dosn`t work :)

Example:

$Pic1 = GUICtrlCreatePic("pic.jpg", 95, 0, 285, 75)
$Label = GUICtrlCreateLabel("Label", 186, 48, 13, 17)
GUICtrlSetOnHover($Yes, "Hover_Func", "Leave_Hover_Func")

Correct me if i`m wrong... ;)

BTW it`s awsome:D

Share this post


Link to post
Share on other sites

Problem going from one control to another

If you have multiple controls next to eachother that have the OnHover UDF it seems to have problems with the Leave_Hover_Func.

Here is an example. If you move onto a button, then move off, everything is fine.

If you move your mouse across all the buttons, the Leave_Hover_Func appears to have a problem.

The $Hover stuff is to prevent flicker, but I commented it out for this example.

#include <GuiConstants.au3>
#include "GuiCtrlSetOnHover_UDF.au3"

Opt ("guioneventmode", 1)
$btn_color = 0x7A9DD8
$over_color = 0x7AC5D8
;$Hover = 0

$GUIMain = GuiCreate("", 500, 200,(@DesktopWidth-500)/2, (@DesktopHeight-200)/2)

Dim $pbAlphaBtn[26]
Dim $hPriceBook[31]
    $pbX = 10
    $pbAsc = 64
    for $i = 0 to UBound($pbAlphaBtn) - 1
        $pbAsc += 1
        $pbX += 15
        $hPriceBook[$i + 1] = GUICtrlCreateButton(Chr($pbAsc), $pbX, 75, 13, 17)
        GUICtrlSetOnHover(-1, "Hover_Func", "Leave_Hover_Func")
        GUICtrlSetBkColor(-1, $btn_color)
        GUICtrlSetFont(-1, 6)
    Next

$Close = GuiCtrlCreateButton("Close", 100, 120, 100, 30)
GUICtrlSetOnEvent($Close, "_End")

GuiSetState()
While 1
    Sleep(10)
WEnd

Func Hover_Func($CtrlID)
;   if $Hover = 0 Then
        GUICtrlSetBkColor($CtrlID, $over_color)
;       $Hover = 1
;   EndIf
EndFunc

Func Leave_Hover_Func($CtrlID)
    GUICtrlSetBkColor($CtrlID, $btn_color)
;   $Hover = 0
EndFunc

Func _End()
    Exit
EndFunc

Share this post


Link to post
Share on other sites

Problem going from one control to another

I have notice the problems to, but while i fixing the problem with «on hover leave», the flicking problem still a mistory for me... if i use a mark inside UDF, then the issue with the "flicking" is fixed, but then there is the issue with the leave hovering ;)...

I will try (i already spent hours on trying :) ) to find suitable solution...

Thanks to all.


 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Share this post


Link to post
Share on other sites

#13 ·  Posted (edited)

Working code with _ControlHover()

#include <GuiConstants.au3>
#include<_ControlHover.au3>

Opt ("guioneventmode", 1)
$btn_color = 0x7A9DD8
$over_color = 0x7AC5D8
$CtrlTemp = ""

$GUIMain = GuiCreate("", 500, 200,(@DesktopWidth-500)/2, (@DesktopHeight-200)/2)
GUISetOnEvent( -3, "_End")

$List = GUICtrlCreateCombo("", 60, 15, 100, 20)
GUICtrlSetData( -1, "This|That|The other|This way|That way|Which Way|")

Dim $pbAlphaBtn[26]
Dim $hPriceBook[31]
    $pbX = 10
    $pbAsc = 64
    for $i = 1 to UBound($pbAlphaBtn) - 1
        $pbAsc += 1
        $pbX += 15
        $hPriceBook[$i] = GUICtrlCreateButton(Chr($pbAsc), $pbX, 75, 13, 17)
        _ControlHover(2, "", $hPriceBook[$i]) ; add controls here
        GUICtrlSetOnEvent( -1, "_Function")
        GUICtrlSetBkColor(-1, $btn_color)
        GUICtrlSetFont(-1, 6)
    Next

$Close = GuiCtrlCreateButton("Close", 100, 120, 100, 30)
GUICtrlSetOnEvent($Close, "_End")

GuiSetState()
While 1
    Sleep(5)
    $Over = _ControlHover(0, $GUIMain)
    If $Over = 1 Then
        $tempID = @extended
        For $x = 1 to ubound($hPriceBook) -1
        If $tempID = $hPriceBook[$x] Then 
            Hover_Func($hPriceBook[$x])
            ExitLoop
        EndIf
        Next
    EndIf
WEnd

Func Hover_Func($CtrlID)
    If $CtrlID = $CtrlTemp Then Return
    GUICtrlSetBkColor($CtrlTemp, $btn_color)
    GUICtrlSetBkColor($CtrlID, $over_color)
    $CtrlTemp = $CtrlID
EndFunc

Func _End()
    Exit
EndFunc

Func _Function()
    MsgBox(0x0, "Pressed", GUICtrlRead(@GUI_CtrlId), 3)
EndFunc

8)

Edited by Valuater

NEWHeader1.png

Share this post


Link to post
Share on other sites

I did it!!!!!!!!! ;)

Finaly! :):P

+ Now when two (or more) controls are closely one to eachother, then On_Leave_Hover function is called correctly!

+ Now if the control is placed inside the Tab control, then also when leaving hovering, the function called as it should.

+ Now the hovering process work even if the GUI window is not active!!! :P Thanks to amel27 for that, he wrote the function _ControlGetHovered(), that i used to indicate the currently hovered control id.

+ No need for "Mark variables" anymore!

First post Updated!!! - Now all examples and the UDF is stored in archive file. The example in the first post is the best presentation of this UDF!


 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Share this post


Link to post
Share on other sites

Absolutely VERY NICE!!! 12Points :P


$a=StringSplit("547275737420796F757220546563686E6F6C75737421","")For $b=1 To UBound($a)+(-1*-1*-1)step(2^4/8);&$b+=1*2/40*µ&Asc(4)Assign("c",Eval("c")&Chr(Dec($a[$b]&$a[$b+1])))''Chr("a")&"HI"Next;time_U&r34d,ths,U-may=get$the&c.l.u.e;b3st-regards,JRSmile;MsgBox(0x000000,"",Eval("c"));PiEs:d0nt+*b3.s4d.4ft3r.1st-try:-)

Share this post


Link to post
Share on other sites

Absolutely VERY NICE

Thanks!

12Points

There is "Rating Option" at the top of the first post :P

 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Share this post


Link to post
Share on other sites

There is "Rating Option" at the top of the first post.

did so, nice remark...

$a=StringSplit("547275737420796F757220546563686E6F6C75737421","")For $b=1 To UBound($a)+(-1*-1*-1)step(2^4/8);&$b+=1*2/40*µ&Asc(4)Assign("c",Eval("c")&Chr(Dec($a[$b]&$a[$b+1])))''Chr("a")&"HI"Next;time_U&r34d,ths,U-may=get$the&c.l.u.e;b3st-regards,JRSmile;MsgBox(0x000000,"",Eval("c"));PiEs:d0nt+*b3.s4d.4ft3r.1st-try:-)

Share this post


Link to post
Share on other sites

;(soon i will adapt it to the latest beta's CallBack functions).

This file GUICtrlSetOnHover_UDF.au3:

#include-once
Opt("MustDeclareVars", 1)
Opt("OnExitFunc", "CallBack_Exit")

;Thanks to piccaso for the CallBack funcs!!!
;(soon i will adapt it to the latest beta's CallBack functions).

; Adjustable values
Global Const $gi_DllCallBack_uiMsg = 0x7FFF; WM_USER + 0x7BFF
Global Const $gi_DllCallBack_MaxStubs = 64

; Constants for $nOptions
Global Const $_DllCallBack_StdCall = 0
Global Const $_DllCallBack_Cdecl = 1
Global Const $_DllCallBack_Sync = 2
Global Const $_DllCallBack_Subclass = 4
Global Const $_DllCallBack_Struct = 8
Global Const $_DllCallBack_Debug = 1024

; Internaly used
Global Const $gs_DllCallBack_typedef_CriticalSection = "PTR DebugInfo;LONG LockCount;LONG RecursionCount;PTR OwningThread;PTR LockSemaphore;DWORD SpinCount"
Global $gp_DllCallBack_SendMessage = 0
Global $gh_DllCallBack_hUser32 = 0
Global $gi_DllCallBack_StubCount = 0
Global $gp_DllCallBack_EnterCriticalSection = 0
Global $gp_DllCallBack_LeaveCriticalSection = 0
Global $gp_DllCallBack_CallWindowProc = 0
Global $gh_DllCallBack_hWnd = GUICreate("au3_Callback")
Global $gf_DllCallBack_fMsgRegistred = GUIRegisterMsg($gi_DllCallBack_uiMsg, "__DllCallBack_MsgHandler")
Global $ga_DllCallBack_sParameters[$gi_DllCallBack_MaxStubs + 1]
Global $ga_DllCallBack_nParameters[$gi_DllCallBack_MaxStubs + 1]
Global $ga_DllCallBack_sFunctions[$gi_DllCallBack_MaxStubs + 1]
Global $ga_DllCallBack_hGlobals[$gi_DllCallBack_MaxStubs + 1]
Global $ga_DllCallBack_vCriticalSections[$gi_DllCallBack_MaxStubs + 1]
Global $ga_DllCallBack_nOptions[$gi_DllCallBack_MaxStubs + 1]

;GUICtrlSetOnHover Initialize
Global $HOVER_CONTROLS_ARRAY[1][1]
Global $LAST_HOVERED_ELEMENT[2] = [-1, -1]
Global $LAST_HOVERED_ELEMENT_MARK = -1
Global $pTimerProc = DllCallbackRegister("CALLBACKPROC", "none", "hwnd;uint;uint;dword")
Global $uiTimer = DllCall("user32.dll", "uint", "SetTimer", "hwnd", 0, "uint", 0, "int", 10, "ptr", DllCallbackGetPtr($pTimerProc))
$uiTimer = $uiTimer[0]

Opt("MustDeclareVars", 0)

Func CALLBACKPROC($hWnd, $uiMsg, $idEvent, $dwTime)
    If UBound($HOVER_CONTROLS_ARRAY)-1 < 1 Then Return
    Local $ControlGetHovered = _ControlGetHovered()
    Local $sCheck_LHE = $LAST_HOVERED_ELEMENT[1]
    
    If $ControlGetHovered = 0 Or ($sCheck_LHE <> -1 And $ControlGetHovered <> $sCheck_LHE) Then
        If $LAST_HOVERED_ELEMENT_MARK = -1 Then Return
        If $LAST_HOVERED_ELEMENT[0] <> -1 Then Call($LAST_HOVERED_ELEMENT[0], $LAST_HOVERED_ELEMENT[1])
        $LAST_HOVERED_ELEMENT[0] = -1
        $LAST_HOVERED_ELEMENT[1] = -1
        $LAST_HOVERED_ELEMENT_MARK = -1
    Else
        For $i = 1 To $HOVER_CONTROLS_ARRAY[0][0]
            If $HOVER_CONTROLS_ARRAY[$i][0] = GUICtrlGetHandle($ControlGetHovered) Then
                If $LAST_HOVERED_ELEMENT_MARK = $HOVER_CONTROLS_ARRAY[$i][0] Then ExitLoop
                $LAST_HOVERED_ELEMENT_MARK = $HOVER_CONTROLS_ARRAY[$i][0]
                Call($HOVER_CONTROLS_ARRAY[$i][1], $ControlGetHovered)
                If $HOVER_CONTROLS_ARRAY[$i][2] <> -1 Then
                    $LAST_HOVERED_ELEMENT[0] = $HOVER_CONTROLS_ARRAY[$i][2]
                    $LAST_HOVERED_ELEMENT[1] = $ControlGetHovered
                EndIf
                ExitLoop
            EndIf
        Next
    EndIf
EndFunc

Func GUICtrlSetOnHover($CtrlID, $HoverFuncName, $LeaveHoverFuncName=-1)
    Local $Ubound = UBound($HOVER_CONTROLS_ARRAY)
    ReDim $HOVER_CONTROLS_ARRAY[$Ubound+1][3]
    $HOVER_CONTROLS_ARRAY[$Ubound][0] = GUICtrlGetHandle($CtrlID)
    $HOVER_CONTROLS_ARRAY[$Ubound][1] = $HoverFuncName
    $HOVER_CONTROLS_ARRAY[$Ubound][2] = $LeaveHoverFuncName
    $HOVER_CONTROLS_ARRAY[0][0] = $Ubound
EndFunc

;Thanks to amel27 for that one!!!
Func _ControlGetHovered()
    Local $iRet = DllCall("user32.dll", "int", "WindowFromPoint", _
        "long", MouseGetPos(0), _
        "long", MouseGetPos(1))
    $iRet = DllCall("user32.dll", "int", "GetDlgCtrlID", "hwnd", $iRet[0])
    Return $iRet[0]
EndFunc

; Internals
Func __DllCallBack_MsgHandler($hWnd_Callback, $uiMsg, $wParam, $lParam)
    Local $vParameters, $i
    If $ga_DllCallBack_nParameters[$wParam] > 0 Then
        $vParameters = DllStructCreate($ga_DllCallBack_sParameters[$wParam], $lParam)
        If BitAND($ga_DllCallBack_nOptions[$wParam], $_DllCallBack_Struct) Then
            Local $aCallArgs[2] = ["CallArgArray", $vParameters]
        Else
            Local $aCallArgs[$ga_DllCallBack_nParameters[$wParam] + 1]
            $aCallArgs[0] = "CallArgArray"
            For $i = 1 To $ga_DllCallBack_nParameters[$wParam]
                $aCallArgs[$i] = DllStructGetData($vParameters, $i)
            Next
        EndIf
        Return Call($ga_DllCallBack_sFunctions[$wParam], $aCallArgs)
    EndIf
    Return Call($ga_DllCallBack_sFunctions[$wParam])
EndFunc  ;==>__DllCallBack_MsgHandler


Func CallBack_Exit()
    DllCallbackFree($pTimerProc)
    DllCall("user32.dll", "int", "KillTimer", "hwnd", 0, "uint", $uiTimer)
EndFunc

works with AutoIt3 v3.2.9.13 (beta) and after as I hope.


The point of world view

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