Is it not possible to change the visual of the Image button inside a class?

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
sasee_sw
Posts: 5
Joined: 31 Mar 2023, 05:41

Is it not possible to change the visual of the Image button inside a class?

Post by sasee_sw » 31 May 2023, 13:02

I created a class. When I put the variable that changes the visual of an image (As button) it says that it is not a global variable. I globalized it in the same way. But none of them work. If anyone can help me.😥 :cry:

This is my class 👇

Code: Select all


class SuperGUI {
    __New(GuiIndex, Scale, Inifile) {
        ; Constructor code
        Scale := Floor(Scale/10)
        this.Scale         := Scale
        this.GUIIndex      := GuiIndex
        this.Inifile       := Inifile
    }

	ToggleSwitch(x, y, w, h, Buton1Image, Buton2Image, Visual, Action, InifileTag, IniSection) {
        ; global Visual
	    Inifile  := this.Inifile
        Scale    := this.Scale
        GuiIndex := this.GUIIndex
        ; Visual   := Visual2

        LocationX := Floor(x / scale)
	    LocationY := Floor(y / scale)
	    SizeX     := Floor(w / scale)
	    SizeY     := Floor(h / scale)

	    IniRead, InifileTag, %IniFile% , %IniSection%, %InifileTag%
	    if (InifileTag = 1)
		{
	        Live := Buton1Image
	    }
		Else if (InifileTag = 2)
		{
	        Live := Buton2Image
	    }
	    Gui, %GuiIndex%: Add, Picture, x%LocationX% y%LocationY% w%SizeX% h%SizeY% +BackgroundTrans g%Action% v%Visual%, %Live%

	}

 	TogleButtonAction(InifileTag, IniSection, Buton1Image, Buton2Image, Visual){
	    Inifile  := this.Inifile
	    IniRead, IniFileTagR, %Inifile%, %IniSection%, %IniFileTag%
        
	    if (IniFileTagR = 1) {
	        GuiControl, , %Visual%, %Buton1Image%
	        IniWrite, 2 , %Inifile%, %IniSection%, %IniFileTag%
	    } 
        Else if (IniFileTagR = 2) {
	        GuiControl, , %Visual%, %Buton2Image%
	        IniWrite, 1 , %Inifile%, %IniSection%, %IniFileTag%
	    }
    }  


}

And this is my use case part 👇

Code: Select all

CommonGUI := new SuperGUI(1, 10, "SettingsSave.ini")
CommonGUI.ToggleSwitch(90,90,60,30, on, off, "TogTog", "Toggle", "YUIO", "Main")


;== This is Action
Toggle:
    CommonGUI.TogleButtonAction("YUIO", "Main", On, Off, "TogTog")
Return
This is my error massage ⚠
Error Message.png
Error Message.png (22.63 KiB) Viewed 141 times
If there is one experienced person who has similar experience about this, please help me. I appreciate it more


[Mod action: Topic moved from "Ask for Help (v2)" since this is v1 code.]

sasee_sw
Posts: 5
Joined: 31 Mar 2023, 05:41

Re: Is it not possible to change the visual of the Image button inside a class?

Post by sasee_sw » 31 May 2023, 15:16

I find way get this :dance:
Hear it's

Code: Select all

Toggle:
    global TogTog
    CommonGUI.TogleButtonAction("YUIO", "Main", On, Off, "TogTog")
Return
I add The Visual tag before the visual changing function

Post Reply

Return to “Ask for Help (v1)”