Jump to content

GUI Input Mystery


ken82m
 Share

Recommended Posts

I have two radiobuttons and an input associated with each one.

Each radiobutton enables its input and disables the other input.

Problem

1) Check "Archive Files"

2) Check "Limit Archive To:"

3) Check the first button for "Megabytes"

4) Enter a number into the input

5) Check the second button for "Days"

6) Notice the Megabytes entry changes back to "0"

7) Now click the button for "Megabytes" again

Problem

8) Click on the input, it changes back to teh value you entered in step 4

If you reverse that process I don't have that problem with the second input retains it's value of 0 when I click on it.

I managed to clean up my code enough to show you what's happening.

Thanks,

Kenny

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <Constants.au3>
#include <GUIConstantsEx.au3>
Opt("GUICloseOnESC", 0)
Opt("TrayIconHide", 1)
Global $INIFile = @ScriptDir & "\MyMovies.ini"

Global $ArchiveGUI = GUICreate("My Movies Backup Scheduler Utility - Cleanup Settings", 634, 557)
Global $ArchiveLimitInput = GUICtrlCreateInput("0", 56, 418, 49, 21, BitOR($ES_AUTOHSCROLL,$ES_NUMBER))
GUICtrlSetState(-1, $GUI_DISABLE)
Global $KeepDaysInput = GUICtrlCreateInput("0", 98, 170, 49, 21, BitOR($ES_AUTOHSCROLL,$ES_NUMBER))
Global $Label1a = GUICtrlCreateLabel(" days", 154, 173, 29, 17)
Global $Label1 = GUICtrlCreateLabel("Keep files for:", 26, 173, 68, 17)
Global $DeleteFiles = GUICtrlCreateRadio("Delete Files", 36, 248, 81, 17)
Global $ArchiveFiles = GUICtrlCreateRadio("Archive Files", 36, 272, 81, 17)
Global $Label2 = GUICtrlCreateLabel("When files expire:", 26, 228, 88, 17)
GUICtrlCreateGroup("", -99, -99, 1, 1)
Global $ArchiveLimitCheckbox = GUICtrlCreateCheckbox("Limit archive to:", 25, 391, 97, 17)
GUICtrlSetState(-1, $GUI_DISABLE)
Global $MBLimitCB = GUICtrlCreateRadio("", 36, 421, 17, 17)
GUICtrlSetState(-1, $GUI_DISABLE)
Global $DayLimitCB = GUICtrlCreateRadio("", 36, 449, 17, 17)
GUICtrlSetState(-1, $GUI_DISABLE)
Global $Label3a = GUICtrlCreateLabel(" megabytes", 108, 421, 58, 17)
Global $MBLimitInput = GUICtrlCreateInput("0", 56, 418, 49, 21, $ES_NUMBER)
GUICtrlSetState(-1, $GUI_DISABLE)
Global $Label3 = GUICtrlCreateLabel(" days", 108, 449, 29, 17)
Global $DayLimitInput = GUICtrlCreateInput("0", 56, 446, 49, 21, $ES_NUMBER)
GUICtrlSetState(-1, $GUI_DISABLE)

GUISetState(@SW_SHOW, $ArchiveGUI)

While 1
$nMsg = GUIGetMsg(1)
    Switch $nMsg[0]
        Case $GUI_EVENT_CLOSE
            Exit
        Case $ArchiveFiles
            ToggleArchive(1)
        Case $DeleteFiles
                ToggleArchive(0)
        Case $ArchiveLimitCheckbox
            If GUICtrlRead($ArchiveLimitCheckbox) = $GUI_UNCHECKED Then
            ;GUICtrlSetState($ArchiveLimitInput, $GUI_DISABLE)
                GUICtrlSetState($MBLimitCB, $GUI_DISABLE)
                GUICtrlSetState($DayLimitCB, $GUI_DISABLE)
                GUICtrlSetState($MBLimitInput, $GUI_DISABLE)
                GUICtrlSetState($MBLimitInput, $GUI_DISABLE)
            Else
                GUICtrlSetState($ArchiveLimitInput, $GUI_ENABLE)
                GUICtrlSetState($MBLimitCB, $GUI_ENABLE)
                GUICtrlSetState($DayLimitCB, $GUI_ENABLE)
            EndIf
        Case $MBLimitCB
            GUICtrlSetState($DayLimitInput, $GUI_DISABLE)
            GUICtrlSetState($MBLimitInput, $GUI_ENABLE)
            GUICtrlSetData($DayLimitInput, "0")
        Case $DayLimitCB
            GUICtrlSetState($MBLimitInput, $GUI_DISABLE)
            GUICtrlSetState($DayLimitInput, $GUI_ENABLE)
            GUICtrlSetData($MBLimitInput, "0")
    EndSwitch
WEnd


Func ToggleArchive($sStatus)
    If $sStatus = 0 Then
        $sStatus = $GUI_DISABLE
        GUICtrlSetState($DayLimitCB, $GUI_DISABLE)
        GUICtrlSetState($MBLimitCB, $GUI_DISABLE)
        GUICtrlSetState($DayLimitCB, $GUI_UNCHECKED)
        GUICtrlSetState($MBLimitCB, $GUI_UNCHECKED)
        GUICtrlSetData($MBLimitInput, "0")
        GUICtrlSetData($DayLimitInput, "0")
        GUICtrlSetState($DayLimitInput, $GUI_DISABLE)
        GUICtrlSetState($MBLimitInput, $GUI_DISABLE)
        GUICtrlSetState($ArchiveLimitCheckbox, $GUI_UNCHECKED)
        GUICtrlSetState($ArchiveLimitCheckbox, $GUI_DISABLE)
    Else
        GUICtrlSetState($ArchiveLimitCheckbox, $GUI_ENABLE)
    EndIf
EndFunc
Edited by ken82m

 "I believe that when we leave a place, part of it goes with us and part of us remains... Go anywhere, when it is quiet, and just listen.. After a while, you will hear the echoes of all our conversations, every thought and word we've exchanged.... Long after we are gone our voices will linger in these walls for as long as this place remains."

Link to comment
Share on other sites

I have two checkboxes and an input associated with each one.

Each checkbox enables its input and disables the other input.

Problem

1) Enter a number into $I1

2) I check $R2, $I2 is enabled, I1 is disabled and set to "0"

3) I click "R1", $I1 is enabled, I2 is disabled and set to "0"

4) When I actually click on the now activated I1 the value changes from "0" back to the value I previously entered.

If you reverse that process I2 retains it's value of 0 when I click on it.

Here's a sample I made of the GUI, which unfortunately works fine, I can't reproduce it in another script

But the script is extrememly large and contains multiple GUI's which is why I didn't post the whole thing.

In my script I have the exact same cases shown below, and I have reviewed every single GUICtrlCreateInput command in the script.

What other command or action could cause this?

Thanks,

Kenny

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

;Create GUI
Global $ArchiveGUI = GUICreate("My Movies Backup Scheduler Utility - Cleanup Settings", 634, 557)
;Create Controls
Global $MBLimitInput = GUICtrlCreateInput("0", 56, 418, 49, 21, $ES_NUMBER)
Global $DayLimitInput = GUICtrlCreateInput("0", 56, 446, 49, 21, $ES_NUMBER)

Global $ArchiveGUI = GUICreate("My Movies Backup Scheduler Utility - Cleanup Settings", 634, 557)
Global $R1 = GUICtrlCreateRadio("R1", 56, 48, 33, 33)
Global $R2 = GUICtrlCreateRadio("R2", 56, 96, 41, 41)
Global $I1 = GUICtrlCreateInput("I1", 176, 56, 65, 21)
Global $I2 = GUICtrlCreateInput("I2", 184, 104, 65, 21)
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()

    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $R1
            GUICtrlSetState($I2, $GUI_DISABLE)
            GUICtrlSetState($I1, $GUI_ENABLE)
            GUICtrlSetData($I2, "0")
        Case $R2
            GUICtrlSetState($I1, $GUI_DISABLE)
            GUICtrlSetState($I2, $GUI_ENABLE)
            GUICtrlSetData($I1, "0")
    EndSwitch
WEnd
Hi,try this, $r1 is for radio 1

While 1
If GuiCtrlGetState($r1)=$GUI_CHECKED then
GuiCtrlSetState($i1,$GUI_ENABLED)
GuiCtrlSetState($i2,$GUI_DISABLED)
Else
GuiCtrlSetState($i2,$GUI_ENABLED)
GuiCtrlSetState($i1,$GUI_DISABLED)
Endif
Wend
Edited by FireFox
Link to comment
Share on other sites

Added code to reproduce problem.

It's probably something simple and stupid and just needs a fresh pair of eyes.

Thanks,

Kenny

Edited by ken82m

 "I believe that when we leave a place, part of it goes with us and part of us remains... Go anywhere, when it is quiet, and just listen.. After a while, you will hear the echoes of all our conversations, every thought and word we've exchanged.... Long after we are gone our voices will linger in these walls for as long as this place remains."

Link to comment
Share on other sites

sorry, got it down to bare essentials now :)

 "I believe that when we leave a place, part of it goes with us and part of us remains... Go anywhere, when it is quiet, and just listen.. After a while, you will hear the echoes of all our conversations, every thought and word we've exchanged.... Long after we are gone our voices will linger in these walls for as long as this place remains."

Link to comment
Share on other sites

Well I got it I just redid Case $ArchiveLimitCheckbox from scratch

Though there was nothing in it that would change the value of the input boxes, and why would that case effect anything when I'm working with different controls....

Oh well

Kenny

 "I believe that when we leave a place, part of it goes with us and part of us remains... Go anywhere, when it is quiet, and just listen.. After a while, you will hear the echoes of all our conversations, every thought and word we've exchanged.... Long after we are gone our voices will linger in these walls for as long as this place remains."

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