Jump to content

Change RollOver to MouseDown


Crash
 Share

Recommended Posts

Hello, how can I change the function of my menu so that they do not change when they are rolled over but when they are clicked?

For example, when the first button is clicked, it stays down until the other button is clicked. When the other is clicked, the first button goes back to its original state (up) while the second button becomes down and so on.

I have all the resources readied, but I don't know how to write the script (it's half done). Can you help me? :)

Sorry, the file name should be RollOver, not RoolOver.

RoolOver.zip

Edited by Crash

JPGRARMouse Lock | My website | Thanks so much for your help! ❤️

Link to comment
Share on other sites

Hello, how can I change the function of my menu so that they do not change when they are rolled over but when they are clicked?

For example, when the first button is clicked, it stays down until the other button is clicked. When the other is clicked, the first button goes back to its original state (up) while the second button becomes down and so on.

I have all the resources readied, but I don't know how to write the script (it's half done). Can you help me? :)

Sorry, the file name should be RollOver, not RoolOver.

Here is a possible way. I have only made a small change to your code so that if you click on 'OVERALL' it stays clicked.

#Include <GUICtrlSetOnHover.au3>
#Include <GUIConstantsEx.au3>
#Include <GDIPlus.au3>



_GDIPlus_Startup()

;Mine
GUICreate("Fungicide 2010", 790, 556)
GUISetBkColor(0xFFFFFF)
GUISetState()


;~ ;Find colour theme
;~ If $antiautorunning = "true" And $firewallrunning = "true" Then
;~  $colourtheme = "green"
;~ Else
;~  $colourtheme = "red"
;~          EndIf

;GUI bg
GUICtrlCreatePic(@ScriptDir&"\main_bg_top.jpg", 0, 0, 790, 78)
$Pic1=GUICtrlCreatePic(@ScriptDir&"\main_bg_left.jpg", 0, 78, 245, 443)
$hPic1 = GUICtrlGetHandle($Pic1)
GUICtrlSetState(-1, $GUI_DISABLE)
GUICtrlCreatePic(@ScriptDir&"\main_bg_bottom.jpg", 0, 521, 790, 35)

;End of Mine

;Create Overall Menu
$Pic2 = GUICtrlCreatePic('', 20, 90, 220, 80)
$hPic2 = GUICtrlGetHandle($Pic2)
_SetImageHover($Pic2, @ScriptDir & '\menu_overall_up.jpg')
GUICtrlSetOnHover($Pic2, 'HoverPic', 'LeaveHoverPic')


;Create Protection Menu
$Pic3 = GUICtrlCreatePic('', 20, 175, 220, 80)
$hPic3 = GUICtrlGetHandle($Pic3)
_SetImageHover($Pic3, @ScriptDir & '\menu_protection_up.jpg')
GUICtrlSetOnHover($Pic3, 'HoverPic', 'LeaveHoverPic')

;Create Protection Menu
$Pic4 = GUICtrlCreatePic('', 20, 260, 220, 80)
$hPic4 = GUICtrlGetHandle($Pic4)
_SetImageHover($Pic4, @ScriptDir & '\menu_recovery_up.jpg')
GUICtrlSetOnHover($Pic4, 'HoverPic', 'LeaveHoverPic')

;Create Configuration Menu
$Pic5 = GUICtrlCreatePic('', 20, 345, 220, 80)
$hPic5 = GUICtrlGetHandle($Pic5)
_SetImageHover($Pic5, @ScriptDir & '\menu_configuration_up.jpg')
GUICtrlSetOnHover($Pic5, 'HoverPic', 'LeaveHoverPic')

;Create About Menu
$Pic6 = GUICtrlCreatePic('', 20, 430, 220, 80)
$hPic6 = GUICtrlGetHandle($Pic6)
_SetImageHover($Pic6, @ScriptDir & '\menu_about_up.jpg')
GUICtrlSetOnHover($Pic6, 'HoverPic', 'LeaveHoverPic')
Global $Selected = 0
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
        Case $Pic2
            If $Selected <> $Pic2 then
                ;reset image for the current selection if there is one  
                 _SetImageHover($Pic2, @ScriptDir & '\menu_overall_down.jpg')
                 $Selected = $Pic2
                 ;Add the menu options or whatever for 'OVERALL' here
            EndIf    
    EndSwitch
WEnd

Func HoverPic($CtrlID)
    Select
    Case $CtrlID = $Pic2
    _WinAPI_InvalidateRect($hPic1, _ControlGetRect($hPic2))
    _SetImageHover($Pic2, @ScriptDir & '\menu_overall_down.jpg')
    _WinAPI_InvalidateRect($hPic2)
            _WinAPI_InvalidateRect($hPic3)

        Case $CtrlID = $Pic3
    _WinAPI_InvalidateRect($hPic1, _ControlGetRect($hPic3))
    _SetImageHover($Pic3, @ScriptDir & '\menu_protection_down.jpg')
    _WinAPI_InvalidateRect($hPic3)
            _WinAPI_InvalidateRect($hPic4)

        Case $CtrlID = $Pic4
    _WinAPI_InvalidateRect($hPic1, _ControlGetRect($hPic4))
    _SetImageHover($Pic4, @ScriptDir & '\menu_recovery_down.jpg')
    _WinAPI_InvalidateRect($hPic4)
            _WinAPI_InvalidateRect($hPic5)

        Case $CtrlID = $Pic5
    _WinAPI_InvalidateRect($hPic1, _ControlGetRect($hPic5))
    _SetImageHover($Pic5, @ScriptDir & '\menu_configuration_down.jpg')
    _WinAPI_InvalidateRect($hPic5)
            _WinAPI_InvalidateRect($hPic6)

        Case $CtrlID = $Pic6
    _WinAPI_InvalidateRect($hPic1, _ControlGetRect($hPic6))
    _SetImageHover($Pic6, @ScriptDir & '\menu_about_down.jpg')
    _WinAPI_InvalidateRect($hPic6)
    EndSelect
EndFunc ;==>HoverPic

Func LeaveHoverPic($CtrlID)
    Select
    Case $CtrlID = $Pic2 And $selected <> $Pic2
    _WinAPI_InvalidateRect($hPic1, _ControlGetRect($hPic2))
    _SetImageHover($Pic2, @ScriptDir & '\menu_overall_up.jpg')
    _WinAPI_InvalidateRect($hPic2)
            _WinAPI_InvalidateRect($hPic3)

        Case $CtrlID = $Pic3
    _WinAPI_InvalidateRect($hPic1, _ControlGetRect($hPic3))
    _SetImageHover($Pic3, @ScriptDir & '\menu_protection_up.jpg')
    _WinAPI_InvalidateRect($hPic3)
            _WinAPI_InvalidateRect($hPic4)


        Case $CtrlID = $Pic4
    _WinAPI_InvalidateRect($hPic1, _ControlGetRect($hPic4))
    _SetImageHover($Pic4, @ScriptDir & '\menu_recovery_up.jpg')
    _WinAPI_InvalidateRect($hPic4)
            _WinAPI_InvalidateRect($hPic5)

        Case $CtrlID = $Pic5
    _WinAPI_InvalidateRect($hPic1, _ControlGetRect($hPic5))
    _SetImageHover($Pic5, @ScriptDir & '\menu_configuration_up.jpg')
    _WinAPI_InvalidateRect($hPic5)
            _WinAPI_InvalidateRect($hPic6)

        Case $CtrlID = $Pic6
    _WinAPI_InvalidateRect($hPic1, _ControlGetRect($hPic6))
    _SetImageHover($Pic6, @ScriptDir & '\menu_about_up.jpg')
    _WinAPI_InvalidateRect($hPic6)
    EndSelect
EndFunc ;==>LeaveHoverPic

Func _ControlGetRect($hWnd)

    Local $Pos = ControlGetPos($hWnd, '', '')
    Local $tRect = DllStructCreate('int;int;int;int')

    DllStructSetData($tRect, 1, $Pos[0])
    DllStructSetData($tRect, 2, $Pos[1])
    DllStructSetData($tRect, 3, $Pos[0] + $Pos[2])
    DllStructSetData($tRect, 4, $Pos[1] + $Pos[3])
    Return $tRect
EndFunc ;==>_ControlGetRect

Func _SetImageHover($ControlID, $sImage)

    Local $hWnd = GUICtrlGetHandle($ControlID)
    Local $hImage, $hBitmap

;   _GDIPlus_Startup()
    $hImage = _GDIPlus_BitmapCreateFromFile($sImage)
    $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage)
    _GDIPlus_ImageDispose($hImage)
;   _GDIPlus_Shutdown()
    _WinAPI_DeleteObject(_SendMessage($hWnd, 0x0173))
    _SendMessage($hWnd, 0x0172, 0, $hBitmap)
    $hImage = _SendMessage($hWnd, 0x0173)
    If $hImage <> $hBitmap Then
    _WinAPI_DeleteObject($hBitmap)
    EndIf
EndFunc ;==>_SetImageHover

It will be much easier to deal with this if you use an array for the Pics used for the buttons, and for images filenames used for them. Then you can deal with any button that is pressed with one bit of code.

Your gui looks very good :)

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
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...