Jump to content

Change image back after hover


Recommended Posts

This script is pretty long at this point (a lot of directory reading and web reading) so I'm only going to include the part that I need help on

While 1
    $Msg = GUIGetMsg()
    $Hover = _ControlHover(0)
    If $Hover = 1 Then
        Prewview(@Extended)
    EndIf
    If $Hover = 0 Then GuiCtrlSetImage($GuiBackground, $GuiWallpaper)
    Select
        Case $Msg = $Exit
            Exit
    EndSelect
WEnd

Func Prewview($xControl)
    $Text = GuiCtrlRead($xControl)
    For $i = 1 to $GuiMenuItems[0][0]
        If $Text = $GuiMenuItems[$i][0] Then
            $Element = $i
            ExitLoop
        EndIf
    Next
    $PreviewPic = @ScriptDir & '\' & IniRead($GuiMenuDir & $GuiMenuItems[$Element][1], 'Data', 'ImagePreview', 'bin\menuitems\images\movies.jpg')
    GuiCtrlSetImage($GuiBackground, $PreviewPic)
EndFunc EndFunc

my problem is I can get the iamge to change when the button is hovered over but when I try to add

If $Hover <> 1 Then GuiCtrlSetImage($GuiBackground, $GuiWallpaper)

it flickers the image I want to have when its hovered and then just flickers the background image a lot

Thanks in advance

Link to comment
Share on other sites

Maybe you should try to set the image once instead of 100 times a second? ;)

$globalflag = 0
While 1
    $Msg = GUIGetMsg()
    $Hover = _ControlHover(0)
    If $globalflag = 0 And $Hover = 1 Then
        $globalflag = 1
        Prewview(@Extended)
    EndIf
    If $globalflag = 1 And $Hover = 0 Then
        $globalflag = 0
        GuiCtrlSetImage($GuiBackground, $GuiWallpaper)
    EndIf
    Select
        Case $Msg = $Exit
            Exit
    EndSelect
WEnd

Edit:Wait... That's not right. Better now?

Edited by AdmiralAlkex
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...