Jump to content
Sign in to follow this  
BinaryBrother

Image Hover effects

Recommended Posts

BinaryBrother

I've managed to get the mouse over effects working, but when I click one of the images, the function isn't getting fired... :)

How can I register a click event on the images? ;)

If anyone actually needs the images, I'll zip and upload...

Oh and P.S.... The functions WERE firing before I added, $GUI_WS_EX_PARENTDRAG to the main BG image...

;#NoTrayIcon
#RequireAdmin
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Compression=4
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <Misc.au3>
Opt("GUIOnEventMode", 1)
$dll = DllOpen("user32.dll")


If Not FileExists(@TempDir & "\imgs\") Then
    Do
    DirCreate(@TempDir & "\imgs\")
    Until FileExists(@TempDir & "\imgs\")
EndIf

$Form1 = GUICreate("", 600, 450, 199, 153,$WS_POPUP)
Global $CurserID = GUIGetCursorInfo($Form1)
GUISetOnEvent($GUI_EVENT_CLOSE, "Form1Close")
GUISetOnEvent($GUI_EVENT_MINIMIZE, "Form1Minimize")
GUISetOnEvent($GUI_EVENT_MAXIMIZE, "Form1Maximize")
GUISetOnEvent($GUI_EVENT_RESTORE, "Form1Restore")
$BackGround = GUICtrlCreatePic(@TempDir & "\imgs\main-screen.jpg", 0, 0, 600, 450, BitOR($SS_NOTIFY,$WS_GROUP), $GUI_WS_EX_PARENTDRAG)
GUICtrlSetCursor ($BackGround, 2)
GUICtrlSetOnEvent($BackGround, "BackGroundClick")
$ApplyButton = GUICtrlCreatePic(@TempDir & "\imgs\apply-button1.jpg", 242, 188, 116, 35, BitOR($SS_NOTIFY,$WS_GROUP))
GUICtrlSetOnEvent($ApplyButton, "ApplyButtonclick")
$ExitButton2 = GUICtrlCreatePic(@TempDir & "\imgs\X_button_pre-hover.jpg", 575, 0, 24, 23, BitOR($SS_NOTIFY,$WS_GROUP))
GUICtrlSetOnEvent($ExitButton2, "ExitButtonclick")
$Pic4 = GUICtrlCreatePic(@TempDir & "\imgs\genuine-chew.jpg", 504, 372, 90, 47, BitOR($SS_NOTIFY,$WS_GROUP))
GUICtrlSetOnEvent($Pic4, "Pic4Click")
$ExitButton1 = GUICtrlCreatePic(@TempDir & "\imgs\exit_button_NOT_mouseover.jpg", 242, 228, 116, 35, BitOR($SS_NOTIFY,$WS_GROUP))
GUICtrlSetOnEvent($ExitButton1, "ExitButtonclick")
$CreditsButton = GUICtrlCreatePic(@TempDir & "\imgs\credits_button_NOT_mouseover.jpg", 501, 422, 93, 26, BitOR($SS_NOTIFY,$WS_GROUP))
GUICtrlSetOnEvent($CreditsButton, "CreditsButtonclick")

GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
GUICtrlSetImage($CreditsButton, @TempDir & "\imgs\credits_button_NOT_mouseover.jpg")
AdlibEnable("HoverEffects",50)
While 1
    Sleep(50)
WEnd

Func HoverEffects()
    $CurserID = GUIGetCursorInfo($Form1)
    ToolTip($CurserID[2])
    If Not $CurserID[4] <> 0 Then Return
    If $CurserID[4] = $ApplyButton Then     ; Apply Start
        GUICtrlSetImage($ApplyButton, @TempDir & "\imgs\apply-button2.jpg")
        While $CurserID[4] = $ApplyButton
            $CurserID = GUIGetCursorInfo($Form1)
            Sleep(50)
            ConsoleWrite("in loop")
            If $CurserID[2] = 1 Or _IsPressed("01") Then
                MsgBox(0,"","")
                ApplyButtonclick()
            EndIf
        WEnd
        GUICtrlSetImage($ApplyButton, @TempDir & "\imgs\apply-button1.jpg")
    EndIf   ; Apply End

    If $CurserID[4] = $ExitButton1 Then     ; Exit1 Start
        GUICtrlSetImage($ExitButton1, @TempDir & "\imgs\exit_button_IS_mouseover.jpg")
        While $CurserID[4] = $ExitButton1
            $CurserID = GUIGetCursorInfo($Form1)
            Sleep(50)
            If _IsPressed("01", $dll) Then
                Exit
            EndIf
        WEnd
        GUICtrlSetImage($ExitButton1, @TempDir & "\imgs\exit_button_NOT_mouseover.jpg")
    EndIf   ; Exit1 End

    If $CurserID[4] = $ExitButton2 Then     ; Exit2 Start
        GUICtrlSetImage($ExitButton2, @TempDir & "\imgs\X_button_onmouseover.jpg")
        While $CurserID[4] = $ExitButton2
            $CurserID = GUIGetCursorInfo($Form1)
            Sleep(50)
            If _IsPressed("01", $dll) Then
                Exit
            EndIf
        WEnd
        GUICtrlSetImage($ExitButton2, @TempDir & "\imgs\X_button_pre-hover.jpg")
    EndIf   ; Exit2 End

    If $CurserID[4] = $CreditsButton Then   ; Credits Start
        GUICtrlSetImage($CreditsButton, @TempDir & "\imgs\credits_button_IS_mouseover.jpg")
        While $CurserID[4] = $CreditsButton
            $CurserID = GUIGetCursorInfo($Form1)
            Sleep(50)
            If _IsPressed("01", $dll) Then
                Exit
            EndIf
        WEnd
        GUICtrlSetImage($CreditsButton, @TempDir & "\imgs\credits_button_NOT_mouseover.jpg")
    EndIf   ; Credits End


EndFunc

Func ApplyButtonclick()
    MsgBox(0,"","")
EndFunc
Func BackGroundClick()

EndFunc
Func CreditsButtonclick()

EndFunc
Func ExitButtonclick()
    Exit
EndFunc
Func Form1Close()
    Exit
EndFunc
Func Form1Maximize()

EndFunc
Func Form1Minimize()

EndFunc
Func Form1Restore()

EndFunc
Func Pic4Click()

EndFunc
Edited by BinaryBrother

Share this post


Link to post
Share on other sites
Dolemite50

I haven't used OnEvent mode but it seems odd that you assign an event using GUICtrlSetOnEvent and also manually detect/assign an event using the mouse functions. Possible conflict?

Share this post


Link to post
Share on other sites
BinaryBrother

That was simply a test because the event isn't being triggered due to the loop... :) I'll try removing some on the on event registers, but I don't think that's it... :/

Share this post


Link to post
Share on other sites
BinaryBrother

I got it fixed, I removed the sleeps in the internal function loop for the mouse over wait for click, and it seems to be working. :)

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
Sign in to follow this  

×