Jump to content
Sign in to follow this  
billthecreator

Making a control have more properties

Recommended Posts

billthecreator

I'm really stuck here..

I have 6 pictures, that change like on/off.

Almost like a checkbox, basically.

Is there a way to make it so that if the picture is click, it would change conditionally, like if the picture had a $GUI_CHECKED property.

I've been using java for the last 3 months, and the only thing that comes to mind is classes and objects, that would be easy. Maybe there's a way, but after searching this forum, I'm not sure what to do.

Thank you all.

Basically this is what I am imagining...

if $button_1.Status()= 1 then

;change picture

$button_1.Status(0)

endif


[font=Microsoft Sans Serif]My Scripts: From Most recent to least.[/font]Countdown GUI | QLOCK TWO | FlipClock | Slot Machine My UDF:_GenerateRandomNoRepeat | _GuiSnap

Share this post


Link to post
Share on other sites
PsaltyDS

GUICtrlSetImage()

#include <GUIConstantsEx.au3>
#include <ButtonConstants.au3>

Global $idButton, $iImg = 1

GUICreate("My GUI", 300, 300) ; will create a dialog box that when displayed is centered
$idLabel = GUICtrlCreateLabel("Image = " & $iImg, 20, 20, 260, 20)
$idButton = GUICtrlCreateButton("my picture button", 20, 120, 40, 40, $BS_ICON)
GUICtrlSetImage(-1, "shell32.dll", $iImg)

GUISetState()

; Run the GUI until the dialog is closed
While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $idButton
            $iImg += 1
            If $iImg > 48 Then $iImg = 1
            GUICtrlSetData($idLabel, "Image = " & $iImg)
            GUICtrlSetImage($idButton, "shell32.dll", $iImg)
    EndSwitch
WEnd

:x


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites
billthecreator

thats not actually what i was looking for, but after thnking i think i found the best way

to create an array, subscript 1 would be the handle, 2 the status, and so forth.


[font=Microsoft Sans Serif]My Scripts: From Most recent to least.[/font]Countdown GUI | QLOCK TWO | FlipClock | Slot Machine My UDF:_GenerateRandomNoRepeat | _GuiSnap

Share this post


Link to post
Share on other sites
Malkey

An example.

#include <GUIConstantsEx.au3>
#include <ButtonConstants.au3>

local $hGUI, $idButton[6], $iImg = 274

$hGUI = GUICreate("My GUI", 300, 300,300,300)
For $i = 0 To 5
    GUICtrlCreateLabel("", 110, 30 + ($i * 42), 100, 20)
    $idButton[$i] = GUICtrlCreateButton("", 110, 20 + ($i * 42), 40, 40, $BS_ICON)
    GUICtrlSetImage(-1, "shell32.dll", $iImg)
    GUICtrlSetState(-1, $GUI_DISABLE)
    $iImg += 1
Next
GUICtrlSetState($idButton[0], $GUI_ENABLE)
GUISetState()

While 1
    $iMsg = GUIGetMsg()
    Switch $iMsg
        Case $GUI_EVENT_CLOSE
            Exit
        ; All buttons are disabled, except for the button which was last pressed via its invisible covering label.
        Case $idButton[0] - 1 To $idButton[UBound($idButton) - 1]
            For $i = 0 To 5
                GUICtrlSetState($idButton[$i], $GUI_DISABLE)
            Next
            GUICtrlSetState($idButton[($iMsg + 1 - $idButton[0]) / 2], $GUI_ENABLE)
            MsgBox(0, "", "Button " & 1 + ($iMsg + 1 - $idButton[0]) / 2 & " pushed.", 1, $hGUI)
    EndSwitch
WEnd

Share this post


Link to post
Share on other sites
ivan

Just for the sake of completeness, shouldn't you close the User32.dll, i.e, add a function:

Func _PropList_Destroy($phwnd)
    GUIDelete($phwnd)
    DllClose($User32)
EndFunc

So after you leave the main loop in the example

_PropList_Destroy($Gui)
Edited by ivan

Share this post


Link to post
Share on other sites
PsaltyDS

You can if it makes you feel better, but AutoIt closes all open handles on exit anyway. Not actually required.

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.