Jump to content
Sign in to follow this  
jtrout

GUI Tabs

Recommended Posts

jtrout

Ok I have several input boxes on a tab and I want to be able to either use a menu item or a button that the user would click to "reset" or return to beginning state the values that were passed into the input fileds.

I have used the same script to reset the field as I did to populate it.

GuiCtrlCreateInput($value, 200, 40, 130, 20)

But when I click the input field or tab into the field it goes back to the value I put in before "resetting" the fields.

This is something that has been requested but I can't figure out what I am doing wrong.

Thanks for your help!

Share this post


Link to post
Share on other sites
MHz

Show the relevant code olease so the issue can be pointed out to you in code solution. Seems like your message loop or on event is hooked on the input rather then the reset button.

:)

Edit:

Use [ autoit ] [ /autoit ] tags for code (no spaces in the tags themselves).

Edited by MHz

Share this post


Link to post
Share on other sites
jtrout

For the menu

$filemenuRefresh = GUICtrlCreateMenu("&Refresh Tab")

$fileitemRefreshIST1 = GUICtrlCreateMenuItem("Refresh IST1 Tab", $filemenuRefresh)

GUICtrlSetOnEvent(-1, "RefreshIST1Tab")

Func GUITabIST1()

GuiCtrlCreateTabItem("IST1")

GuiCtrlCreateLabel("ARGO - versionNumber", 10, 40)

GuiCtrlCreateLabel("TDEFN - versionNumber", 10, 80)

GuiCtrlCreateLabel("TDEFN - Date", 10, 120)

GuiCtrlCreateLabel("TDEFN - Time", 10, 160)

GuiCtrlCreateLabel("Alogent - versionNumber", 10, 200)

GuiCtrlCreateLabel("Sort Pattern - versionNumber", 10, 240)

GuiCtrlCreateLabel("Sort Pattern - Date", 10, 280)

GuiCtrlCreateLabel("Sort Pattern - Time", 10, 320)

GuiCtrlCreateLabel("Server Date - Date", 10, 360)

GuiCtrlCreateLabel("Code Delivery Folder - version", 10, 400)

$UpdateIST1button = GuiCtrlCreateButton("Update IST1", 145, 440, 100, 30)

GUICtrlSetOnEvent($UpdateIST1button, "UpdateIST1")

LoadIST1Fields()

EndFunc

Func LoadIST1Fields()

Dim $IST1ArgoInput

;$IST1ArgoField = GuiCtrlCreateInput($IST1Argo, 200, 40, 130, 20)

$IST1ArgoInput = GUICtrlCreateInput("",200,40,130,20)

$IST1ArgoField = GUICtrlSetData($IST1ArgoInput, $IST1Argo)

$IST1TDEFNversionNumberField = GuiCtrlCreateInput($IST1TDEFNversionNumber, 200, 80, 130, 20)

$IST1TDEFNDateField = GuiCtrlCreateInput($IST1TDEFNDate, 200, 120, 130, 20)

$IST1TDEFNTimeField = GuiCtrlCreateInput($IST1TDEFNTime, 200, 160, 130, 20)

$IST1AlogentversionNumberField = GuiCtrlCreateInput($IST1AlogentversionNumber, 200, 200, 130, 20)

$IST1SortPatternversionNumberField = GuiCtrlCreateInput($IST1SortPatternversionNumber, 200, 240, 130, 20)

$IST1SortPatternDateField = GuiCtrlCreateInput($IST1SortPatternDate, 200, 280, 130, 20)

$IST1SortPatternTimeField = GuiCtrlCreateInput($IST1SortPatternTime, 200, 320, 130, 20)

$IST1ServerDateDateField = GuiCtrlCreateInput($IST1ServerDateDate, 200, 360, 130, 20)

$IST1CodeversionField = GuiCtrlCreateInput($IST1Codeversion, 200, 400, 130, 20)

EndFunc

Func RefreshIST1Tab()

LoadIST1Fields()

EndFunc

Share this post


Link to post
Share on other sites
MHz

Here is a patched version of your code that runs.

Opt('GuiOnEventMode', 1)            ; 0 = disable, 1 = enable.
#include <GUIConstants.au3>
$IST1TDEFNversionNumber = 123
GUICreate('')
;For the menu
$filemenuRefresh = GUICtrlCreateMenu("&Refresh Tab")
$fileitemRefreshIST1 = GUICtrlCreateMenuItem("Refresh IST1 Tab", $filemenuRefresh)
GUICtrlSetOnEvent(-1, "RefreshIST1Tab")
GUITabIST1 ()
RefreshIST1Tab ()
GUISetState()

Func GUITabIST1 ()
    GUICtrlCreateTabItem("IST1")
    GUICtrlCreateLabel("ARGO - versionNumber", 10, 40)
    GUICtrlCreateLabel("TDEFN - versionNumber", 10, 80)
;~  GUICtrlCreateLabel("TDEFN - Date", 10, 120)
;~  GUICtrlCreateLabel("TDEFN - Time", 10, 160)
;~  GUICtrlCreateLabel("Alogent - versionNumber", 10, 200)
;~  GUICtrlCreateLabel("Sort Pattern - versionNumber", 10, 240)
;~  GUICtrlCreateLabel("Sort Pattern - Date", 10, 280)
;~  GUICtrlCreateLabel("Sort Pattern - Time", 10, 320)
;~  GUICtrlCreateLabel("Server Date - Date", 10, 360)
;~  GUICtrlCreateLabel("Code Delivery Folder - version", 10, 400)
    Global $UpdateIST1button = GUICtrlCreateButton("Update IST1", 145, 440, 100, 30)
;~  GUICtrlSetOnEvent($UpdateIST1button, "UpdateIST1")

    LoadIST1Fields ()
EndFunc   ;==>GUITabIST1

Func LoadIST1Fields ()
;~  Dim $IST1ArgoInput
    ;$IST1ArgoField = GuiCtrlCreateInput($IST1Argo, 200, 40, 130, 20)
    Global $IST1ArgoInput = GUICtrlCreateInput("", 200, 40, 130, 20)
;~  $IST1ArgoField = GUICtrlSetData($IST1ArgoInput, $IST1Argo)
    Global $IST1TDEFNversionNumberField = GUICtrlCreateInput("", 200, 80, 130, 20)
;~  $IST1TDEFNDateField = GUICtrlCreateInput($IST1TDEFNDate, 200, 120, 130, 20)
;~  $IST1TDEFNTimeField = GUICtrlCreateInput($IST1TDEFNTime, 200, 160, 130, 20)
;~  $IST1AlogentversionNumberField = GUICtrlCreateInput($IST1AlogentversionNumber, 200, 200, 130, 20)
;~  $IST1SortPatternversionNumberField = GUICtrlCreateInput($IST1SortPatternversionNumber, 200, 240, 130, 20)
;~  $IST1SortPatternDateField = GUICtrlCreateInput($IST1SortPatternDate, 200, 280, 130, 20)
;~  $IST1SortPatternTimeField = GUICtrlCreateInput($IST1SortPatternTime, 200, 320, 130, 20)
;~  $IST1ServerDateDateField = GUICtrlCreateInput($IST1ServerDateDate, 200, 360, 130, 20)
;~  $IST1CodeversionField = GUICtrlCreateInput($IST1Codeversion, 200, 400, 130, 20)
EndFunc   ;==>LoadIST1Fields


;~ Func ()
;~ EndFunc

Func RefreshIST1Tab ()
    Global $IST1TDEFNversionNumber = 'Default Data'
    GUICtrlSetData($IST1ArgoInput, 'Default Data')
    GUICtrlSetData($IST1TDEFNversionNumberField, $IST1TDEFNversionNumber)
EndFunc   ;==>RefreshIST1Tab

While 1
    Sleep(1000)
WEnd

You have issues with Local variables and once any function returns, then you will lose them. Not sure if you have them declared at the top of the script or not.

I have changed RefreshIST1Tab() to use GuiCtrlSetData()s to update the inputs to defaults. You can also reset your variables in the function to reset their values but you are going to read the inout later so it would defeat the purpose. I would create the input controls with empty strings and update with GuiCtrlSetData() functions in your RefreshIST1Tab(). If you have an ini file with saved settings, then load them rather then RefreshIST1Tab() at start of Gui to set saved values.

:)

Share this post


Link to post
Share on other sites
jtrout

Woohoo! Thanks for pointing out I am an idiot and forgetting to make the variables Global. Duh! I also like the fact that you mentioned to make the fields blank then fill them in. Makes it a little cleaner. Very good tips!

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  

×