Jump to content

Auto-Updating GUI


Tony567
 Share

Recommended Posts

Hello guys, so this is my first code. I'm making an application starter that starts different applications and has english and spanish languages as you can see in my code:

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
Opt("MustDeclareVars",1)
Global $Button1
Global $Button2
Global $Button3
Global $Button3t
Global $Button4
Global $Button4t
Global $Button5
Global $Button5t
Global $Button6
Global $Button6t
Global $Form1
Global $Label1
Global $Label1t
Global $Label2
Global $Label2t
Global $Label3
Global $Label3t
Global $nMsg
$Button3t = "Calculator"
$Button4t = "Notepad"
$Button5t = "Paint"
$Button6t = "Magnifier"
$Label1t = "Tony's Application Starter"
$Label2t = "More Features coming soon!"
$Label3t = "Current Language is English"
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 450, 303, 192, 124)
GUISetBkColor(0xFFFF00)
$Label1 = GUICtrlCreateLabel($Label1t, 16, 8, 411, 42)
GUICtrlSetFont(-1, 25, 800, 0, "Arial")
$Button1 = GUICtrlCreateButton("English", 96, 80, 105, 33)
$Button2 = GUICtrlCreateButton("Español", 256, 80, 105, 33)
$Button3 = GUICtrlCreateButton($Button3t, 80, 128, 121, 41)
$Button4 = GUICtrlCreateButton($Button4t, 256, 128, 121, 41)
$Button5 = GUICtrlCreateButton($Button5t, 80, 192, 121, 41)
$Button6 = GUICtrlCreateButton($Button6t, 256, 192, 121, 41)
$Label2 = GUICtrlCreateLabel($Label2t, 48, 248, 352, 36)
GUICtrlSetFont(-1, 20, 400, 0, "Arial")
$Label3 = GUICtrlCreateLabel($Label3t, 96, 48, 242, 28)
GUICtrlSetFont(-1, 16, 400, 0, "MS Sans Serif")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
  Case $GUI_EVENT_CLOSE
   Exit
EndSwitch
If $nMsg = $Button1 Then Button1()
If $nMsg = $Button2 Then Button2()
If $nMsg = $Button3 Then Button3()
If $nMsg = $Button4 Then Button4()
If $nMsg = $Button5 Then Button5()
If $nMsg = $Button6 Then Button6()
WEnd

Func Button1()
$Button3t = "Calculator"
$Button4t = "Notepad"
$Button5t = "Paint"
$Button6t = "Magnifier"
$Label1t = "Tony's Application Starter"
$Label2t = "More Features coming soon!"
$Label3t = "Current Language is English"
EndFunc
Func Button2()
$Button3t = "Calculadora"
$Button4t = "Bloc"
$Button5t = "Pintura"
$Button6t = "Lupa"
$Label1t = "Arranque de Tony Aplicación"
$Label2t = "Más Novedades Pronto!"
$Label3t = "El Idioma Es Actual Español"
EndFunc
Func Button3()
Run ( "cmd /c start %windir%\system32\calc.exe", "", @SW_HIDE )
EndFunc
Func Button4()
Run ( "cmd /c start %windir%\system32\notepad.exe", "", @SW_HIDE )
EndFunc
Func Button5()
Run ( "cmd /c start %windir%\system32\mspaint.exe", "", @SW_HIDE )
EndFunc
Func Button6()
Run ( "cmd /c start %windir%\system32\magnify.exe", "", @SW_HIDE )
EndFunc

Well my problem is that when i press the spanish button (button2), the variables change but the gui doesnt update any of the buttons/labels. any help please?

Link to comment
Share on other sites

You aren't changing the information on the controls, just the value of the variable used to initially create it. You need to, for example, use GUICtrlSetData($Button3, "Calculadora") instead of changing the value in the variable.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

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...