Jump to content

_ButtonHover() UDF


Valuater
 Share

Recommended Posts

Champack, you could note above the discussion of $SS_CenterImage and how it is applied, I dont see how i can change the effect of the button without the current code and allow multilines of text... sorry.

However, since you notice the "$Xbtn[1] = GUICtrlCreateLabel" then you can set the text without re-creating the button

like this...

$Button = _HoverButton ("Some text", 180, 80, 70, 15, $color)
GUICtrlSetData($Button + 1, "Changed Text")

8)

NEWHeader1.png

Link to comment
Share on other sites

  • 1 month later...
  • Replies 68
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Posted Images

Hi,

i try to make your code work for more then one theme. I discovered the following problem. When you hit one of the buttons with a quick short mouse click, the button won't turn into 'pressed' state. This is because the au3 script just check's the $msg message if the button ist clicked right before the _CheckHoverAndPressed() function will be called ?!

I think there is no workaround for this ?

PS: The problem stays with the modified version and also with your original code Valuater. Some hints for me?

Link to comment
Share on other sites

So,

i moved the _CheckHoverAndPressed() call in the Button-Demo.au3 just behind the GUIGetMsg() and now it behaves much better...

Now i have to finish the modification..

See you

PS: I discovered the following bug. In the demo: when you push a button and only wait for the MessageBox to close instead of closing in manually the pushed button stays in 'pressed' mode...

Edited by Sundance
Link to comment
Share on other sites

  • 4 weeks later...
  • 3 months later...

its not working for me. it has 2 errors when I use your demo.

1. when I load it and it asks for a folder and I highlight one and click ok I get the error.

C:\Documents and Settings\Ours\Desktop\_ButtonHover.au3 (160) : ==> Variable used without being declared.:

$Xbtn[1] = GUICtrlCreateLabel($XBtext, $XBleft, $XBtop, $XBwidth, $XBheight, $SS_NOTIFY & $SS_CENTER)

$Xbtn[1] = GUICtrlCreateLabel($XBtext, $XBleft, $XBtop, $XBwidth, $XBheight, ^ ERROR

2. and when it does work it keeps popping up a msgbox that will just keep showing till the script is exited.

Link to comment
Share on other sites

  • 1 month later...

Hello,

to Valuater:

I used your _ButtonHover() UDF for two of my projects and I must say

it's very, very good. I like it (with XSkin and all - by the way also one of great scripts)

Yesterday I got this new __ButtonHoverTag UDF and everything is OK.

I have only one note for (some) people that can't get two different button "styles"

to work.

Why?

This was my case, but only till I realized that the images for some buttons and these for other buttons

had different extensions (gif - jpg). So I passed these $XBType to an Array (like the tags) and solved.

Thank you for it!

...

Link to comment
Share on other sites

  • 5 months later...

Valuater,

Let me start by saying I love ButtonHover and XSkin! Also thanks for Ez Track as well!

If you wouldn't mind takeing a look at the attached jpg. I am having a weird issue with one of my child forms. I am not sure why it is creating a partial Button in my ListView it is the one circled in Blue

Edit: If I don't run _CheckHoverAndPressed for that form It doesn't do it.

post-44460-1245268974_thumb.jpg

Edited by KenNichols
[topic="21048"]New to AutoIt? Check out AutoIt 1-2-3![/topic] Need to make a GUI? You NEED KODA FormDesigner!
Link to comment
Share on other sites

  • 2 weeks later...

ButtonHover() was based on a "theme" for the Buttons, ButtonHoverTag() was designed for mutiple buttons.

There are a couple of "Resource" UDF's around, however, I do not know how each use applies, you will need to do the DD on that

8)

Ok. I modified it to use custom array resource file rather than use from directory. I have followings code

;Menu buttons

$RegisterButtonNormal = @TempDir & "\sonnb_RegisterButtonNormal.jpg"
FileInstall("MenuButtons\RegisterButtonNormal.jpg",$RegisterButtonNormal)
$RegisterButtonOver = @TempDir & "\sonnb_RegisterButtonOver.jpg"
FileInstall("MenuButtons\RegisterButtonOver.jpg",$RegisterButtonOver)
$RegisterButtonPress = @TempDir & "\sonnb_RegisterButtonPress.jpg"
FileInstall("MenuButtons\RegisterButtonPress.jpg",$RegisterButtonPress)

$ViewAlbumButtonNormal = @TempDir & "\sonnb_ViewAlbumButtonNormal.jpg"
FileInstall("MenuButtons\ViewAlbumButtonNormal.jpg",$ViewAlbumButtonNormal)
$ViewAlbumButtonOver = @TempDir & "\sonnb_ViewAlbumButtonOver.jpg"
FileInstall("MenuButtons\ViewAlbumButtonOver.jpg",$ViewAlbumButtonOver)
$ViewAlbumButtonPress = @TempDir & "\sonnb_ViewAlbumButtonPress.jpg"
FileInstall("MenuButtons\ViewAlbumButtonPress.jpg",$ViewAlbumButtonPress)

$ViewBlogButtonNormal = @TempDir & "\sonnb_ViewBlogButtonNormal.jpg"
FileInstall("MenuButtons\ViewBlogButtonNormal.jpg",$ViewBlogButtonNormal)
$ViewBlogButtonOver = @TempDir & "\sonnb_ViewBlogButtonOver.jpg"
FileInstall("MenuButtons\ViewBlogButtonOver.jpg",$ViewBlogButtonOver)
$ViewBlogButtonPress = @TempDir & "\sonnb_ViewBlogButtonPress.jpg"
FileInstall("MenuButtons\ViewBlogButtonPress.jpg",$ViewBlogButtonPress)

$Form1_1 = GUICreate("LiveVN Space new blog maker", 726, 696, -1, -1, BitOR($WS_POPUP,$DS_MODALFRAME), BitOR($WS_EX_TRANSPARENT,$WS_EX_WINDOWEDGE))

GUISetState(@SW_SHOW)

Dim $XButton_Location[3]
$XButton_Location[0] = $HomeButtonNormal
$XButton_Location[1] = $HomeButtonOver
$XButton_Location[2] = $HomeButtonPress
$Button_1 = __HoverButton ("", 188, 0, 88, 36)
;$Pic4 = GUICtrlCreatePic($RegisterButtonNormal, 332, 0, 88, 36, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
$XButton_Location[0] = $RegisterButtonNormal
$XButton_Location[1] = $RegisterButtonOver
$XButton_Location[2] = $RegisterButtonPress
$Button_2 = __HoverButton ("", 332, 0, 88, 36)
;$Pic5 = GUICtrlCreatePic($ViewAlbumButtonNormal, 476, 0, 88, 36, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
$XButton_Location[0] = $ViewAlbumButtonNormal
$XButton_Location[1] = $ViewAlbumButtonOver
$XButton_Location[2] = $ViewAlbumButtonPress
$Button_3 = __HoverButton ("", 476, 0, 88, 36)
;$Pic6 = GUICtrlCreatePic($ViewBlogButtonNormal, 612, 0, 88, 36, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
$XButton_Location[0] = $ViewBlogButtonNormal
$XButton_Location[1] = $ViewBlogButtonOver
$XButton_Location[2] = $ViewBlogButtonPress
$Button_4 = __HoverButton ("", 612, 0, 88, 36)

While 1
    __CheckHoverAndPressed ($Form1_1)
    Sleep(100)
WEndoÝ÷ Ù«­¢+ÙÕ¹}}
¡­!½ÙɹAÉÍÍ ÀÌØí}U$ôÅÕ½ÐìÅÕ½Ðì¤(1½°ÀÌØíѵÁ%°ÀÌØíѵÁ%È(ÀÌØí
Ñɱ%Èô}}
½¹Ñɽ±!½ÙÈ Ä°ÀÌØí}U$¤(ÀÌØíѵÁ%¹àÈôáѹ(ÀÌØíѵÁ%ÈôÀÌØí!½ÙÉ%lÀÌØíѵÁ%¹àÉt(ÀÌØíѵÁQÈôÀÌØí!½ÙÉQlÀÌØíѵÁ%¹àÉt(%ÀÌØí
Ñɱ%ÈôôÄQ¡¸(U%
ÑɱMÑ%µ ÀÌØíѵÁ%È´Ä°ÀÌØía   ÕÑѽ¹}1½Ñ¥½¹lÉt¤(±Í%ÀÌØí
Ñɱ%ÈôôÀQ¡¸(U%
ÑɱMÑ%µ ÀÌØíѵÁ%È´Ä°ÀÌØía   ÕÑѽ¹}1½Ñ¥½¹lÅt¤(¹%(ÀÌØí
Ñɱ%ô}}
½¹Ñɽ±!½ÙÈ À°ÀÌØí}U$¤(ÀÌØíѵÁ%¹àôáѹ(ÀÌØíѵÁ%ôÀÌØí!½ÙÉ%lÀÌØíѵÁ%¹át(ÀÌØíѵÁQôÀÌØí!½ÙÉQlÀÌØíѵÁ%¹át(%ÀÌØí
Ñɱ%ôôÄQ¡¸(U%
ÑɱMÑ%µ ÀÌØíѵÁ%´Ä°ÀÌØía ÕÑѽ¹}1½Ñ¥½¹lÅt¤(±Í%ÀÌØí
Ñɱ%ôôÀQ¡¸(U%
ÑɱMÑ%µ ÀÌØíѵÁ%´Ä°ÀÌØía ÕÑѽ¹}1½Ñ¥½¹lÁt¤(¹%)¹Õ¹ìôôÐí}}
¡­!½ÙɹAÉÍÍoÝ÷ Ù«­¢+ÙÕ¹}}!½ÙÉ]¥Ñ ÕÑѽ¹UÀ ¤(%ÀÌØí!½ÙÉ%lÀÌØí±½±}!%tÐìôÈQ¡¸ì±ÍЭ¹½Ý¸½¹Ñɽ°%¥¹à°¥ÉÍн¹¥ÌÈ(ÀÌØíÉÐôU%Ñ
ÕÉͽÉ%¹¼ ¤(%%ÍÉÉä ÀÌØíÉФ¹ÀÌØíÉÑlÑtôôÀÌØí!½ÙÉ%lÀÌØí!½ÙÉ%lÀÌØí±½±}!%utQ¡¸ì¥¹¼¥ÌÙ±¥°¹±¥­Ñ¡­¹½Ý¸½¹Ñɽ°(ÀÌØíѵÁQôÀÌØí!½ÙÉQlÀÌØí!½ÙÉ%lÀÌØí±½±}!%utìÐÑɽ´¥¹à(U%
ÑɱMÑ%µ ÀÌØí!½ÙÉ%lÀÌØí!½ÙÉ%lÀÌØí±½±}!%ut´Ä°ÀÌØía   ÕÑѽ¹}1½Ñ¥½¹lÉt¤(]¡¥±ÀÌØíÉÑlÑtôôÀÌØí!½ÙÉ%lÀÌØí!½ÙÉ%lÀÌØí±½±}!%ut¹ÀÌØíÉÑlÉtôôÄ(M±À Ô¤(ÀÌØíÉÐôU%Ñ
ÕÉͽÉ%¹¼ ¤(]¹(%ÀÌØíÉÑlÉtôôÄQ¡¸IÑÕɸÄ(¹%(¹%)¹Õ¹ìôôÐí}}!½ÙÉ]¥Ñ   ÕÑѽ¹UÀ

When i run the code, it shows up ok but when i move mouse over buttons it only uses last XButton_Location setted images for all buttons. How can i use each XButton_Location or each button?

Thanks,

Edited by nguyenbason
UnderWorldVN- Just play the way you like it
Link to comment
Share on other sites

Your BuutonHover Function is TOTAlly Different than this

Func __HoverButton($XBtext, $XBleft, $XBtop, $XBwidth, $XBheight, $XBtag = "", $XBcolor = "")
    If Not FileExists($XButton_Location & "\") Then
        MsgBox(64, "Error", " $XButton_Location - was not found    ", 3)
        Return
    EndIf
    If FileExists($XButton_Location & "\" & $XBtag & "Normal.gif") Then
        $XBType = ".gif"
    ElseIf FileExists($XButton_Location & "\" & $XBtag & "Normal.jpg") Then
        $XBType = ".jpg"
    ElseIf FileExists($XButton_Location & "\" & $XBtag & "Normal.bmp") Then
        $XBType = ".bmp"
    Else
        MsgBox(64, "Error", " Unknown Button file type ( not - gif, jpg, or bmp )    ", 3)
        Return
    EndIf
    Local $Xbtn[2]
    $Xbtn[0] = GUICtrlCreatePic($XButton_Location & "\" & $XBtag & "Normal" & $XBType, $XBleft, $XBtop, $XBwidth, $XBheight)
    GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
    $Xbtn[1] = GUICtrlCreateLabel($XBtext, $XBleft, $XBtop, $XBwidth, $XBheight, BitOR($SS_CENTERIMAGE, $SS_CENTER))
    If $XBcolor <> "" Then GUICtrlSetColor(-1, $XBcolor)
    GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
    __ControlHover(2, "", $Xbtn[1], $XBtag)
    Return $Xbtn ; [0] = pic, [1] = label
EndFunc   ;==>__HoverButton

What you have change has also lost the process created in that functions correctly...

SORRY, I cannot go through your changing of my UDF to find your errors

8)

NEWHeader1.png

Link to comment
Share on other sites

Sorry for bump up again but the new __HoverButtonTag don't work on click (of course this time i don't modified anything, just use your example and rename functions to same with functions in __HoverButtonTag). Please check, thanks.

Edit: I checked the new and old UDF. In the new UDF __HoverButton return $Xbtn while the old on return $Xbtn[0]. I tried $Xbtn[0] and it's working now.

Edited by nguyenbason
UnderWorldVN- Just play the way you like it
Link to comment
Share on other sites

Thanks,

As you can see, in windows or in website, if you click on a button and hold the mouse (still in clicking) the function will not be called until you release the mouse. And the same if you click hold and move mouse out the button.

In your UDF, the function will be called immediately after user click on button. If you can improve this, i think it so greats.

UnderWorldVN- Just play the way you like it
Link to comment
Share on other sites

Thanks,

As you can see, in windows or in website, if you click on a button and hold the mouse (still in clicking) the function will not be called until you release the mouse. And the same if you click hold and move mouse out the button.

In your UDF, the function will be called immediately after user click on button. If you can improve this, i think it so greats.

Thats what this is...

Func __HoverWaitButtonUp()

8)

NEWHeader1.png

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...