Jump to content

Recommended Posts

Posted

New example - shows a nice custom tooltip on hover:

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

#include "GUICtrlOnHover.au3"

Global $sBtn_Image = @Systemdir & "\oobe\images\wpakey.jpg"
Global $sLbl_Image = @Systemdir & "\oobe\images\merlin.gif"

If Not FileExists($sBtn_Image) Or Not FileExists($sLbl_Image) Then
    $sBtn_Image = @TempDir & "\wpakey.jpg"
    $sLbl_Image = @TempDir & "\merlin.gif"
    
    InetGet("http://creator-lab.ucoz.ru/Images/wpakey.jpg", $sBtn_Image)
    InetGet("http://creator-lab.ucoz.ru/Images/merlin.gif", $sLbl_Image)
EndIf

$hGUI = GUICreate("Control ToolTip OnHover Example",500,400)

$nButton = GUICtrlCreateButton("Button", 100, 100, 50, 50)
_GUICtrl_OnHoverRegister(-1, "_ShowToolTip_Proc", "_ShowToolTip_Proc")

$nLabel = GUICtrlCreateLabel("Label", 300, 100, -1, 15)
_GUICtrl_OnHoverRegister(-1, "_ShowToolTip_Proc", "_ShowToolTip_Proc")

GUISetState(@SW_SHOW, $hGUI)

$hButton_ToolTip = _GUIToolTipCreate("My Button ToolTip", "Some Info", $sBtn_Image, 0x4E6FD6)
$hLabel_ToolTip = _GUIToolTipCreate("My Label ToolTip", "Some Info", $sLbl_Image, 0xFFFFFF)

While 1
    $nMsg = GUIGetMsg()
    
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            ExitLoop
    EndSwitch
WEnd

Func _GUIToolTipCreate($sTitle, $sText, $sImage = '', $nBkColor = 0xECEC00)
    Local $hToolTip = GUICreate($sTitle, 300, 200, -1, -1, BitOR($WS_POPUP, $WS_BORDER), $WS_EX_TOPMOST, $hGUI)
    GUISetBkColor($nBkColor, $hToolTip)
    GUICtrlCreatePic($sImage, 10, 10, 80, 80, $WS_BORDER)
    GUICtrlCreateLabel($sTitle, 100, 10, 180, 20)
    GUICtrlSetFont(-1, 10, 800)
    GUICtrlCreateLabel($sText, 100, 50, 180, 120)
    Return $hToolTip
EndFunc

Func _ShowToolTip_Proc($iCtrlID, $iHoverMode, $hWnd_Hovered)
    Local $hToolTip
    
    Switch $iCtrlID
        Case $nButton
            $hToolTip = $hButton_ToolTip
        Case $nLabel
            $hToolTip = $hLabel_ToolTip
    EndSwitch
    
    Switch $iHoverMode
        Case 1 ;Hover proc
            $aMousePos = MouseGetPos()
            WinMove($hToolTip, "", $aMousePos[0]+10, $aMousePos[1]+10)
            GUISetState(@SW_SHOWNOACTIVATE, $hToolTip)
        Case 2 ;Leave hover proc
            GUISetState(@SW_HIDE, $hToolTip)
    EndSwitch
EndFunc

 

  Reveal hidden contents

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

  • 4 weeks later...
Posted (edited)

Thanks a lot for the UDF but there's a little problem... The order to the controls hover and click priority is set as the 1st one created to the last one, so if I put 2 buttons/pictures on top of each others, the priority is to the one under...

Do you know how I can fix it?

Thanks again!

Edit: It seems that however I try to bring front, it always inverse the whole thing... The picture under alway has the hover reception priority.

I tried to do a GUICTRLSetState($CtrlID, $GUI_ONTOP) and it puts the given $CtrlID under as appearance but over for hover handle.

You can reproduce what a meant earlier by using the example "onclick Hovering Example (3-State)" by changing $Play button's left parameter to something like 90, just enough to get a little bit in front of the $Pause button.

Edited by Silverkorn
Posted

  On 11/18/2010 at 11:13 AM, 'Silverkorn said:

Thanks a lot for the UDF but there's a little problem... The order to the controls hover and click priority is set as the 1st one created to the last one, so if I put 2 buttons/pictures on top of each others, the priority is to the one under...

Do you know how I can fix it?

Thanks again!

Edit: It seems that however I try to bring front, it always inverse the whole thing... The picture under alway has the hover reception priority.

I tried to do a GUICTRLSetState($CtrlID, $GUI_ONTOP) and it puts the given $CtrlID under as appearance but over for hover handle.

You can reproduce what a meant earlier by using the example "onclick Hovering Example (3-State)" by changing $Play button's left parameter to something like 90, just enough to get a little bit in front of the $Pause button.

Well... I got it to work by using the GUICTRLSetState($CtrlID, $GUI_ONTOP) more properly... Sorry for disturbing and underestimating your UDF :graduated:

  • 1 month later...
  • Moderators
Posted (edited)

leomoon,

As I showed in the examples I posted in your thread here, this UDF works fine in OnEvent and MessageLoop modes. :x

What it cannot cope with is changes between OnEvent and MessageLoop modes during script execution, which is a very different thing.

M23

Edit: It now seems that the problem is not as described above - there is something happening when you exit your script that is causing your problem - although it does seem to involve this UDF in particular. Let us continue this in your General Support thread and I will update here as and when necessary.

Edited by Melba23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

  Reveal hidden contents

 

  • 6 months later...
Posted

Hi Mr. Creator!

I've found a small bug in your UDF:

If I register a couple of hover-functions and then unregister all of them, and then register a new hover-function, the last of the unregistered functions is active again. A smal example what i mean:

#include <GUICtrlOnHover.au3>

$hGUI = GUICreate("Example", 260, 160)
GUICtrlSetDefBkColor(0xffffff)
GUISetBkColor(0xffffff)
$hButton1 = GUICtrlCreateButton("Button1", 20, 20, 100, 30)
$hButton2 = GUICtrlCreateButton("Button2", 140, 20, 100, 30)
$hButton3 = GUICtrlCreateButton("Button3", 20, 70, 100, 30)
$hButton4 = GUICtrlCreateButton("Button4", 140, 70, 100, 30)
$hLabel = GUICtrlCreateLabel("A simple GUI :)", 20, 120, 220, 40)
GUISetState()

Sleep(1000)

_GUICtrl_OnHoverRegister($hButton1, "_Hover_Func", "_Leave_Hover_Func")
_GUICtrl_OnHoverRegister($hButton2, "_Hover_Func", "_Leave_Hover_Func")
GUICtrlSetData($hLabel, "Hover effect added to button 1 and button 2 => test it!")
Sleep(5000)

_GUICtrl_OnHoverRegister($hButton1, "")
_GUICtrl_OnHoverRegister($hButton2, "")
GUICtrlSetData($hLabel, "Hover effect removed from button 1 and button 2 => test it!")
Sleep(5000)

_GUICtrl_OnHoverRegister($hButton3, "_Hover_Func", "_Leave_Hover_Func")
_GUICtrl_OnHoverRegister($hButton4, "_Hover_Func", "_Leave_Hover_Func")
GUICtrlSetData($hLabel, "Hover effect added to button 3 and button 4 => test it!")
Sleep(2000)

GUICtrlSetData($hLabel, "Do you see? The hover effect on button 3 is working again!")
GUICtrlSetColor($hLabel, 0xff0000)

While 1
    If GUIGetMsg() = -3 Then Exit
WEnd

Func _Hover_Func($iCtrlID)
    GUICtrlSetBkColor($iCtrlID, 0xff0000)
EndFunc   ;==>_Hover_Func

Func _Leave_Hover_Func($iCtrlID)
    GUICtrlSetBkColor($iCtrlID, 0xffffff)
EndFunc   ;==>_Leave_Hover_Func

How to fix the bug:

Change this part of the _GUICtrl_OnHoverRegister

If $a__GUICtrl_SOH_Ctrls_Tmp[0][0] < 1 Then
    __GUICtrl_SOH_ReleaseResources() ;Release the callbacks
Else
    $i__GUICtrl_SOH_CtrlsModified = 1
    $a__GUICtrl_SOH_Ctrls = $a__GUICtrl_SOH_Ctrls_Tmp
EndIf

Return 1

to this:

If $a__GUICtrl_SOH_Ctrls_Tmp[0][0] < 1 Then
    $a__GUICtrl_SOH_Ctrls = $a__GUICtrl_SOH_Ctrls_Tmp
    __GUICtrl_SOH_ReleaseResources() ;Release the callbacks
Else
    $i__GUICtrl_SOH_CtrlsModified = 1
    $a__GUICtrl_SOH_Ctrls = $a__GUICtrl_SOH_Ctrls_Tmp
EndIf

Return 1

Simon

  • 6 months later...
Posted

Are you able to provide an example script of hovering over a picture (GuiCtrlCreatePic) made small in the GUI, which then displays a tooltip of that picture, but at original size? Like

I am also using Opt("GUIOnEventMode", 1), which I believe is incompatible with your UDF. If i use OnEventMode I believe I cannot close the window when finished ...

eg

$fileAdminPic = "C:\WINDOWS\Web\Wallpaper\Bliss.bmp"

$pcAdminPic= GuiCtrlCreatePic($fileAdminPic,x, y, 20,20)

When you hover over the small picture only 20 x 20, you will get the original size in the hover box.

Thank you

  • 4 months later...
Posted

  On 7/20/2011 at 12:01 AM, 'Simon1602 said:

I've found a small bug in your UDF:

Thanks, it's should be fixed inside __GUICtrl_SOH_ReleaseResources() function, by adding:

$a__GUICtrl_SOH_Ctrls = 0
Dim $a__GUICtrl_SOH_Ctrls[1][1]

 

  Reveal hidden contents

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Posted

Update...

  Quote

[v2.1] - [04.07.2012]

* Compatibility with ColorPicker.au3 UDF.

* Fixed issue with releasing resources (last unregistered control was still active for hovering).

+ Added function to release all resources: _GUICtrl_OnHoverReleaseResources

+ Added alternative UDF "GUICtrlOnHover_NoCallback.au3", it uses AdlibRegister instead of callback with timer. In some cases callback can cause a memory leak.

The disadvantage is obvious, any blocking function or loop will "freeze" the hovering events.

 

  Reveal hidden contents

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

  • 4 months later...
Posted (edited)

I'm trying to use this library in my own script but i'm facing an issue : the action is randomly repeated.

For example if i try to open a FileOpenDialog on Mouse Primary Up action, it opens the file dialog more than one time.

This example is bouncing (opening file dialog more than one time randomly) :

Func PrimaryUp_Proc($iCtrlID)
   Switch $iCtrlID
     Case $Button
      GUICtrlSetImage($iCtrlID, $sImages_Path & "\Button_Hover.jpg")
      FileOpenDialog("BIOU", "", "")
   EndSwitch
EndFunc

I found a way to make it work properly but it involves using GUIGetMsg() and I would like to avoid that since my script is using OnEvent.

Am I missing something here ?

I hope someone can help me,

thank you in advance.

Edited by Slym

--------------------- [font="Franklin Gothic Medium"]LinuxLive USB Creator[/font], [size="3"]The only Linux Live USB creator with easy integrated virtualization (made with AutoIT)[/size] ---------------------

  • 2 months later...
Posted (edited)

Firstly I'd just like to say how much I love this UDF, I have recently "upgraded" to Windows 8 and have started experiencing an issue with it.

OnHover on a particular set of items registers a "hover", "leave" and "click" function. Hover and Leave work perfectly every time, however on what appears to be random time/event, the Click function does not register. Sometimes it works perfectly, other times it just stops. I've tried debugging, putting basic items in the Click function, but the function is never called. The only way I've been able to have the click register again is to restart the app. Sometimes it happens after a few minutes, other times the app can work for half an hour without issue. I've never had a problem when the app is first launched.

Running under XP and Windows 7, I can run the app for days and not see the same issue. Have you any suggestions or experienced behaviour like this under Windows 8 before?

Thanks in advance

Edit: Solved it with _GUICtrl_OnHoverReleaseResources(). Not sure why it only occurred under Win8. Thanks again for a great function.

Edited by Steve0
  • 5 months later...
Posted (edited)

Hello, I have a problem with this UDF.

The Hover works well but the Click does not work.
Function are not even call.

This is due to the child window.

Here is an example of the bug :

#include <WindowsConstants.au3>
#Include <GUIConstants.au3>
#include "GUICtrlOnHover.au3"

;~ ***

$PARENT_GUI = GuiCreate('PARENT', 200, 100)
    $CHILD_GUI = GuiCreate('CHILD', 150, 50, 30, 30, $WS_CHILD, $WS_EX_CLIENTEDGE, $PARENT_GUI)
        $bt1 = GUICtrlCreateButton("normal", 0, 0, 100, 30)
        _GUICtrl_OnHoverRegister(-1, "_Hover_Func", "_Leave_Hover_Func", "_Click_Hover_Func", "_Click_Leave_Hover_Func")
GuiSetState(@SW_SHOW, $PARENT_GUI)
GuiSetState(@SW_SHOW, $CHILD_GUI)

;~ ***

While 1
    $nMsg = GuiGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
;~      Case $bt1
;~          Exit
    EndSwitch
Wend

;~ ***

Func _Hover_Func()
    GUICtrlSetData($bt1, "hover")
EndFunc
Func _Click_Hover_Func()
    GUICtrlSetData($bt1, "click+hover")
EndFunc
Func _Leave_Hover_Func()
    GUICtrlSetData($bt1, "unhover")
EndFunc
Func _Click_Leave_Hover_Func()
    GUICtrlSetData($bt1, "click+unhover")
EndFunc
Edited by Xinnony
  • 2 weeks later...
Posted

Yes, there is a bug on that issue.

I think it's somehow related to GUIRegisterMsg, soon i will check this issue and see how we can fix this.

Thanks.

 

  Reveal hidden contents

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

  • 3 months later...
  • 3 months later...
Posted (edited)

MrCreatoR

Am I allowed to post something based on this UDF?

I just checked it out, it's great but seems like you don't have enough time (or interest) to update and/or modify it based on the latest AutoIt version.

Yes, it works on latest versions but it could be updated to use the new AutoIt features, function references for example.

Let me know if it's OK, else I need your permission to use the modified version in my private projects (I won't share any source code).

Thanks for this great UDF.

Edited by D4RKON3
  • 2 weeks later...
Posted (edited)

I didn't get any response for 10 days so I have to take it as a (big) NO, which means I'm not allowed to release anything based on this UDF, however I believe that the idea remains free for all to follow.

Thank you, it just inspired me, badly!

Edited by D4RKON3
  • 1 month later...
  • 10 months later...

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
  • Recently Browsing   0 members

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