Jump to content

An alternative to the tab control, and a question about GUICtrlGetState


Zealot
 Share

Recommended Posts

So if you read my last post, you know that I am making a die roller for various role playing games. My next step was to try and hide the tab controls along the top, because there are many more games than I have space for tabs along the top of the control. And I hate the way it looks when the tabs overflow.

While I was researching the solution, it seems that there isn't one. Microsoft doesn't allow the tabs along the top to be hidden. By expanding on smashly's solution in the previous post I was able to come up with a work-around.

#include <GUIConstants.au3>
#include <Array.au3>

$GUIHandle= GUICreate("Demo2", 210,235, -1, -1)

    $TabSelector= GUICtrlCreateCombo("",5,5,83,20)                  ; Create a combo box to choose which "tab" to display
        GUICtrlSetData($TabSelector,"Tab1|Tab2|Tab3", "Tab1")
    
    $TabAreaDummyStart= GUICtrlCreateDummy()                        ; Create a dummy control to use as the start of the point to cycle through control IDs
        $Tab1DummyStart= GUICtrlCreateDummy()                       ; Create dummy controls bracketting the contols you want to display on the tabs
            $Tab1= GUICtrlCreateGroup("Tab1",5,30,200,200)
                GUICtrlCreateLabel("Tab the First",75,100,80,20)
        $Tab1DummyEnd= GUICtrlCreateDummy()                         ; End bracket for Tab1
        $Tab2DummyStart= GUICtrlCreateDummy()                       ; Start bracket for Tab2
            $Tab2= GUICtrlCreateGroup("Tab2",5,30,200,200)
                GUICtrlCreateLabel("Tab the Second",75,100,80,20)
        $Tab2DummyEnd= GUICtrlCreateDummy()                         ; End bracket for Tab2
        $Tab3DummyStart= GUICtrlCreateDummy()                       ; Start bracket for Tab3
            $Tab3= GUICtrlCreateGroup("Tab3",5,30,200,200)
                GUICtrlCreateLabel("Tab the Third",75,100,80,20)
        $Tab3DummyEnd= GUICtrlCreateDummy()                         ; End bracket for Tab3
    $TabAreaDummyEnd= GUICtrlCreateDummy()                          ; End bracket for the tab area
    SwitchTabs($Tab1DummyStart,$Tab1DummyEnd)                       ; Call the SwitchTab function to set the proper state for the GUI's start
GUISetState()

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $TabSelector                                    ; Pass the correct start and end dummy control ID's to the SwitchTab function
            Select
                Case GUICtrlRead($TabSelector) = "Tab1"
                    SwitchTabs($Tab1DummyStart,$Tab1DummyEnd)
                Case GUICtrlRead($TabSelector) = "Tab2"
                    SwitchTabs($Tab2DummyStart,$Tab2DummyEnd)
                Case GUICtrlRead($TabSelector) = "Tab3"
                    SwitchTabs($Tab3DummyStart,$Tab3DummyEnd)
            EndSelect
    EndSelect
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
    Wend
    
Func SwitchTabs($StartID,$EndID)                                    ; Disables and hides all the "Tabs", then shows/enables only those controls passed to it
    For $q = $TabAreaDummyStart To $TabAreaDummyEnd
        GUICtrlSetState($q, $GUI_DISABLE + $GUI_HIDE)
    Next
    For $q = $StartID To $EndID
        GUICtrlSetState($q, $GUI_ENABLE + $GUI_SHOW)
    Next    
EndFunc

The only problem with this is that "Tabs Controls" with a large number of controls produce a noticeable ripple as the for-next loop is processed. You can see this in my dice roller (the last code example). To get around this I tried to check the group control to see if it is enabled using GUICtrlGetState, which would allow me to hide disable only the currently enabled controls. I came up with some code, but I can't seem to make the GetState to check enablement correctly. Because it deosn't do this, the code results in an undeclared variable error. Can anyone give or point me to a short tutorial? Here is the code:

#include <GUIConstants.au3>
#include <Array.au3>

$GUIHandle= GUICreate("Demo2", 210,235, -1, -1)

    $TabSelector= GUICtrlCreateCombo("",5,5,83,20)
        GUICtrlSetData($TabSelector,"Tab1|Tab2|Tab3", "Tab1")
    $TabAreaDummyStart= GUICtrlCreateDummy()
        $Tab1DummyStart= GUICtrlCreateDummy()
            $Tab1= GUICtrlCreateGroup("Tab1",5,30,200,200)
                GUICtrlCreateLabel("Tab the First",75,100,80,20)
        $Tab1DummyEnd= GUICtrlCreateDummy()
        $Tab2DummyStart= GUICtrlCreateDummy()
            $Tab2= GUICtrlCreateGroup("Tab2",5,30,200,200)
                GUICtrlCreateLabel("Tab the Second",75,100,80,20)
        $Tab2DummyEnd= GUICtrlCreateDummy()
        $Tab3DummyStart= GUICtrlCreateDummy()
            $Tab3= GUICtrlCreateGroup("Tab3",5,30,200,200)
                GUICtrlCreateLabel("Tab the Third",75,100,80,20)
        $Tab3DummyEnd= GUICtrlCreateDummy()
    $TabAreaDummyEnd= GUICtrlCreateDummy()
    SwitchTabs($Tab1DummyStart,$Tab1DummyEnd)
GUISetState()

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $TabSelector
            Select
                Case GUICtrlRead($TabSelector) = "Tab1"
                    SwitchTabs($Tab1DummyStart,$Tab1DummyEnd)
                Case GUICtrlRead($TabSelector) = "Tab2"
                    SwitchTabs($Tab2DummyStart,$Tab2DummyEnd)
                Case GUICtrlRead($TabSelector) = "Tab3"
                    SwitchTabs($Tab3DummyStart,$Tab3DummyEnd)
            EndSelect
    EndSelect
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
WEnd
    
Func SwitchTabs($StartID,$EndID)
    Select                                          ; This should check to see which "Tab" is activated and set its bracketting dummy controls to be deactivated
        Case GUICtrlGetState($Tab1)= $GUI_ENABLE    ;       but the GetState statement doesn't return a matching value to $GUI_ENABLE.  This results in an
            $DisableCtrlIDStart= $Tab1DummyStart    ;       undeclared variable error in the for-next loops.
            $DisableCtrlIDEnd= $Tab1DummyEnd
        Case GUICtrlGetState($Tab2)= $GUI_ENABLE
            $DisableCtrlIDStart= $Tab2DummyStart
            $DisableCtrlIDEnd= $Tab2DummyEnd
        Case GUICtrlGetState($Tab3)= $GUI_ENABLE
            $DisableCtrlIDStart= $Tab3DummyStart
            $DisableCtrlIDEnd= $Tab3DummyEnd
    EndSelect
    For $q = $DisableCtrlIDStart To $DisableCtrlIDEnd
        GUICtrlSetState($q, $GUI_DISABLE + $GUI_HIDE)
    Next
    For $q = $StartID To $EndID
        GUICtrlSetState($q, $GUI_ENABLE + $GUI_SHOW)
    Next    
EndFunc

And here is the code for the die roller showing the ripple effect.

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_outfile=Odds and Evens v0.1.exe
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****

;~ Program:             Odds and Evens
;~ Script Compiler:     Autoit version: 3
;~ Author:              Simon Goodson
;~ Email:               zealott@hotmail.com
;~ Date:                7 Nov 2007
;~
;~ Based on:            Flanf's Die Roller v1.6
;~ Coded by:            Christoph Flandorfer
;~ Created on:          13 Sept 2006
;~
;~ Special Thanks To:   smashly from the forums for helping me to unclutter the rolled up window
;~
;~ Script Function:
;~ A dice roller, card picker, and point tracker for use in RPGs or whatever
;~
;~ Odds and Evens
;~ --------------
;~ Planned v0.2     Create a new way to select which games are displayed, combo or list box
;~                  Move the point tracker out into the general area somewhere
;~                  Move the DnD thing onto its own tab.
;~                  Get rid of the generic tab and move its functions into the Essentials area
;~                  
;~ v0.2     Swapped the positions of the "Roll Up Window" and KWoT checkbox button with the "Clear Results"
;~              button and made the window roll up to just show the "Roll Down Window" and KWoT buttons
;~ v0.1     Renamed app to "Odds and Evens"
;~          Began redisign of GUI
;~          Adding "Stay on Top" feature
;~          Adding "Roll-up Window" feature
;~          Adding Fate Dice function
;~          
;~ Flanf's Dice Roller
;~ -------------------
;- Version 1.6a:    Switched the output window around to get more space for the dice buttons
;-                  Added a tab to perform d1 through d20 wild dice.
;-                  Added the d20 dice to the S.Worlds tab, mostly for asthetics
;-                  Moved the card functions to its own section
;-                  Implemented 3 decks, 1 always containing all the cards, 1 to pick 1 card at a time out, and
;-                      one to issue multiple cards for combat also with a function to pick singles if needed
;-                  Moved the sort function so that all the dice results could be sorted or not depending on preference
;-                  Generated a random number and used it to seed the random table
;-                  Added a bunch of remarks to help me (Simon) understand the code
;~ Version 1.6: You can now draw Cards WITHOUT Shuffeling under Savage Worlds.
;~ Version 1.5: Marked the Wild Die Result in Savage Worlds.
;~ Version 1.4: The Fate-Table moved from the tabs to the right side and will be always easily available. Massive Changes to the GUI
;~ Version 1.3: Changes in the Output of the Savage Die Rolls (Wild Card & Sort Function). Savage Worlds is now default Tab
;~ Version 1.2: Includes now part of the Fate-Table from the Mythic RPG
;~ Version 1.1: Now with Pokercards (+2 Joker) (Savage Worlds)

#include <GUIConstants.au3>
#include <Array.au3>

;Global $cardsindeck
Global $FullDeck ;Declare 3 arrays to contain card decks
Global $CardDeck1
Global $CardDeck2
InitializeFullDeck() ;Calls the Initialize function to create the cards decks
InitializeCardDeck1()
InitializeCardDeck2()

; Generates a random number between 1 and 1 million and uses it to seed the random number generator
$RandomSeed=random(1,1000000,1)
SRandom($RandomSeed) 

; Define the GUI


$GUIHandle= GUICreate("Odds and Evens", 420, 405, -1, -1)
    
    $ControlAreaDummyStart = GUICtrlCreateDummy() ;<-- Added this here for start of controls
        $GameSelector= GUICtrlCreateCombo("",252,5,83,20)
            GUICtrlSetData($GameSelector,"Savage Worlds|Savage Worlds- Ravaged Rules|Fate|Generic", "Fate")
        $LSide= 5
        $Column1Mod= 6
        $Column2Mod= 76
        $Column3Mod= 116
        $x= 22
        $BeginningRow= 46
        GUICtrlCreateGroup("Essentials",$LSide,28,156,173)
        $FateButtonWeak= GUICtrlCreateButton("Weak", $LSide+$Column1Mod, $BeginningRow, 65, 15)
        $FateButtonLow= GUICtrlCreateButton("Low", $LSide+$Column1Mod, $BeginningRow+($x*1), 65, 15)
        $FateButtonBelowAvg= GUICtrlCreateButton("Below Av.", $LSide+$Column1Mod, $BeginningRow+($x*2), 65, 15)
        $FateButtonAvg= GUICtrlCreateButton("Average", $LSide+$Column1Mod, $BeginningRow+($x*3), 65, 15)
        $FateButtonAboveAvg= GUICtrlCreateButton("Above Av.", $LSide+$Column1Mod, $BeginningRow+($x*4), 65, 15)
        $FateButtonHigh= GUICtrlCreateButton("High", $LSide+$Column1Mod, $BeginningRow+($x*5), 65, 15)
        $FateButtonExcep= GUICtrlCreateButton("Exceptional", $LSide+$Column1Mod, $BeginningRow+($x*6), 65, 15)
        
        $x=30
        $BeginningRow2=50
        $QuickButtonD2= GUICtrlCreatebutton("d2", $LSide+$Column2Mod, $BeginningRow2, 35, 20)
        $QuickButtonD3= GUICtrlCreatebutton("d3", $LSide+$Column2Mod, $BeginningRow2+($x), 35, 20)
        $QuickButtonD4= GUICtrlCreatebutton("d4", $LSide+$Column2Mod, $BeginningRow2+($x*2), 35, 20)
        $QuickButtonD6= GUICtrlCreatebutton("d6", $LSide+$Column2Mod, $BeginningRow2+($x*3), 35, 20)
        $QuickButtonD8= GUICtrlCreatebutton("d8", $LSide+$Column2Mod, $BeginningRow2+($x*4), 35, 20)
       
        $QuickButtonD10= GUICtrlCreatebutton("d10", $LSide+$Column3Mod, $BeginningRow2, 35, 20)
        $QuickButtonD12= GUICtrlCreatebutton("d12", $LSide+$Column3Mod, $BeginningRow2+($x), 35, 20)
        $QuickButtonD20= GUICtrlCreatebutton("d20", $LSide+$Column3Mod, $BeginningRow2+($x*2), 35, 20)
        $QuickButtonD100= GUICtrlCreatebutton("d100", $LSide+$Column3Mod, $BeginningRow2+($x*3), 35, 20)
        $QuickButtonDX= GUICtrlCreatebutton("dX", $LSide+$Column3Mod, $BeginningRow2+($x*4), 35, 20)
       
        GUICtrlCreateGroup("An Always Full Deck",296,207,119,34)
        $DrawRandomCard= GUICtrlCreatebutton("Draw a Random Card", 299, 221, 113, 17)
       
        GUICtrlCreateGroup("Deck 1",296,244,119,53)
        $DrawFromDeck1= GUICtrlCreatebutton("Draw a Card", 299, 257, 113, 17)
        $ReshuffleDeck1= GUICtrlCreateButton("Reshuffle Deck", 299, 276, 113, 17)
       
        GUICtrlCreateGroup("Deck 2",296,298,119,72)
        $IssueCards= GUICtrlCreateButton("Issue X Cards", 299, 312, 113, 17)
        $DrawFromDeck2= GUICtrlCreatebutton("Draw a Single Card", 299, 331, 113, 17)
        $ReshuffleDeck2= GUICtrlCreateButton("Reshuffle Deck", 299, 350, 113, 17)
       
        $ShowADeck= GUICtrlCreatebutton("Show Deck", 296, 372, 73, 29)
        $DisplayHelp= GUICtrlCreatebutton("Help", 371, 372, 45, 29)
        
        $OutputWindow = GUICtrlCreateEdit("", 166, 35, 249, 165)
       
        GUICtrlCreateLabel("Select a" & @crlf & "Number",11,238)
        $NumberSelected = GUICtrlCreateList("1", 5,267,55,146,$WS_VSCROLL)
            For $i= 2 to 100
                GUICtrlSetData($NumberSelected,$i)
            Next
        $ClearButton= GUICtrlCreateButton("Clear Results",341,5,75,20)
       
        $RollUpWindow= GUICtrlCreateButton("Roll Up Window",5,5,105,20)
        $RollDownWindow= GUICtrlCreateButton("Roll Down Window",5,5,105,20)
;~ Hide and disable the Roll Down button
        GUICtrlSetState($RollDownWindow,$GUI_DISABLE + $GUI_HIDE)
       
        $KeepOnTop= GUICtrlCreateCheckbox("",125,7,15,15)
        GUICtrlCreateLabel("Keep Window on Top",141,8)
       
        $SortResults= GUICtrlCreateCheckbox("",5,209,15,15)
        GUICtrlCreateLabel("Sort" & @crlf & "Results",23,204)
        
        $GameAreaDummyStart= GUICtrlCreateDummy()
            $SavageWorldsDummyStart= GUICtrlCreateDummy()
                $SavageWorlds=GUICtrlCreateGroup ("Savage Worlds",67,205,225,197)
                    $MainButtonW=30
                    $BigButtonW=55
                    $SmallButtonW=17
                    $ButtonH=25
                    $1stCLSide=117
                    $2ndCLSide=218
                    $MidCLSide=155
                    $TopRow=243
                    $1stRTop=244
                    $2ndRTop=$TopRow+40
                    $3rdRTop=$TopRow+80
                    $4thRTop=$TopRow+120
                    ;First Row
                    $SWButtonUnsk= GUICtrlCreatebutton("Unskilled", $MidCLSide, $1stRTop, $BigButtonW, $ButtonH)
                    $SWButtonUnskx= GUICtrlCreatebutton("x", $MidCLSide-$SmallButtonW, $1stRTop, $SmallButtonW, $ButtonH)
                    $SWButtonUnskw= GUICtrlCreatebutton("w", $MidCLSide+$BigButtonW, $1stRTop, $SmallButtonW, $ButtonH)
                    ;Second Row
                    $SWButtonD4= GUICtrlCreatebutton("d4", $1stCLSide, $2ndRTop, $MainButtonW, $ButtonH)
                    $SWButtonD4x= GUICtrlCreatebutton("x", $1stCLSide-$SmallButtonW, $2ndRTop, $SmallButtonW, $ButtonH)
                    $SWButtonD4w= GUICtrlCreatebutton("w", $1stCLSide+$MainButtonW, $2ndRTop, $SmallButtonW, $ButtonH)
                    
                    $SWButtonD6= GUICtrlCreatebutton("d6", $2ndCLSide, $2ndRTop, $MainButtonW, $ButtonH)
                    $SWButtonD6x= GUICtrlCreatebutton("x", $2ndCLSide-$SmallButtonW, $2ndRTop, $SmallButtonW, $ButtonH)
                    $SWButtonD6w= GUICtrlCreatebutton("w", $2ndCLSide+$MainButtonW, $2ndRTop, $SmallButtonW, $ButtonH)
                    ;Third Row
                    $SWButtonD8= GUICtrlCreatebutton("d8", $1stCLSide, $3rdRTop, $MainButtonW, $ButtonH)
                    $SWButtonD8x= GUICtrlCreatebutton("x", $1stCLSide-$SmallButtonW, $3rdRTop, $SmallButtonW, $ButtonH)
                    $SWButtonD8w= GUICtrlCreatebutton("w", $1stCLSide+$MainButtonW, $3rdRTop, $SmallButtonW, $ButtonH)
                    
                    $SWButtonD10= GUICtrlCreatebutton("d10", $2ndCLSide, $3rdRTop, $MainButtonW, $ButtonH)
                    $SWButtonD10x= GUICtrlCreatebutton("x", $2ndCLSide-$SmallButtonW, $3rdRTop, $SmallButtonW, $ButtonH)
                    $SWButtonD10w= GUICtrlCreatebutton("w", $2ndCLSide+$MainButtonW, $3rdRTop, $SmallButtonW, $ButtonH)
                    ;Forth Row
                    $SWButtonD12= GUICtrlCreatebutton("d12", $1stCLSide, $4thRTop, $MainButtonW, $ButtonH)
                    $SWButtonD12x= GUICtrlCreatebutton("x", $1stCLSide-$SmallButtonW, $4thRTop, $SmallButtonW, $ButtonH)
                    $SWButtonD12w= GUICtrlCreatebutton("w", $1stCLSide+$MainButtonW, $4thRTop, $SmallButtonW, $ButtonH)
                     
                    $SWButtonD20= GUICtrlCreateButton("d20", $2ndCLSide, $4thRTop, $MainButtonW, $ButtonH)
                    $SWButtonD20x= GUICtrlCreateButton("x", $2ndCLSide-$SmallButtonW, $4thRTop, $SmallButtonW, $ButtonH)
                    $SWButtonD20w= GUICtrlCreateButton("w", $2ndCLSide+$MainButtonW, $4thRTop, $SmallButtonW, $ButtonH)
            $SavageWorldsDummyEnd= GUICtrlCreateDummy()
            
            $RavagedRulesDummyStart= GUICtrlCreateDummy()
                $RavagedRules=GUICtrlCreateGroup ("Savage Worlds- Ravaged Rules",67,205,225,197)
                    $MainButtonW=30
                    $SmallButtonW=17
                    $ButtonH=20
                    $1stCLSide=87
                    $2ndCLSide=163
                    $3rdCLSide=240
                    $LSideMod=37
                    $TopRow=230
                    $1stRTop=$TopRow
                    $2ndRTop=$TopRow+24
                    $3rdRTop=$TopRow+49
                    $4thRTop=$TopRow+73
                    $5thRTop=$TopRow+98
                    $6thRTop=$TopRow+122
                    $7thRTop=$TopRow+147
                    ;First Row
                    $SWModButtonD1= GUICtrlCreatebutton("d1", $1stCLSide, $1stRTop, $MainButtonW, $ButtonH)
                    $SWModButtonD1x= GUICtrlCreatebutton("x", $1stCLSide-$SmallButtonW, $1stRTop, $SmallButtonW, $ButtonH)
                    $SWModButtonD1W= GUICtrlCreatebutton("w", $1stCLSide+$MainButtonW, $1stRTop, $SmallButtonW, $ButtonH)
                    
                    $SWModButtonD2= GUICtrlCreatebutton("d2", $2ndCLSide, $1stRTop, $MainButtonW, $ButtonH)
                    $SWModButtonD2x= GUICtrlCreatebutton("x", $2ndCLSide-$SmallButtonW, $1stRTop, $SmallButtonW, $ButtonH)
                    $SWModButtonD2W= GUICtrlCreatebutton("w", $2ndCLSide+$MainButtonW, $1stRTop, $SmallButtonW, $ButtonH)
                    
                    $SWModButtonD3= GUICtrlCreatebutton("d3", $3rdCLSide, $1stRTop, $MainButtonW, $ButtonH)
                    $SWModButtonD3x= GUICtrlCreatebutton("x", $3rdCLSide-$SmallButtonW, $1stRTop, $SmallButtonW, $ButtonH)
                    $SWModButtonD3W= GUICtrlCreatebutton("w", $3rdCLSide+$MainButtonW, $1stRTop, $SmallButtonW, $ButtonH)
                    ;Second Row
                    $SWModButtonD4= GUICtrlCreatebutton("d4", $1stCLSide, $2ndRTop, $MainButtonW, $ButtonH)
                    $SWModButtonD4x= GUICtrlCreatebutton("x", $1stCLSide-$SmallButtonW, $2ndRTop, $SmallButtonW, $ButtonH)
                    $SWModButtonD4W= GUICtrlCreatebutton("w", $1stCLSide+$MainButtonW, $2ndRTop, $SmallButtonW, $ButtonH)
                    
                    $SWModButtonD5= GUICtrlCreatebutton("d5", $2ndCLSide, $2ndRTop, $MainButtonW, $ButtonH)
                    $SWModButtonD5x= GUICtrlCreatebutton("x", $2ndCLSide-$SmallButtonW, $2ndRTop, $SmallButtonW, $ButtonH)
                    $SWModButtonD5W= GUICtrlCreatebutton("w", $2ndCLSide+$MainButtonW, $2ndRTop, $SmallButtonW, $ButtonH)
                    
                    $SWModButtonD6= GUICtrlCreatebutton("d6", $3rdCLSide, $2ndRTop, $MainButtonW, $ButtonH)
                    $SWModButtonD6x= GUICtrlCreatebutton("x", $3rdCLSide-$SmallButtonW, $2ndRTop, $SmallButtonW, $ButtonH)
                    $SWModButtonD6W= GUICtrlCreatebutton("w", $3rdCLSide+$MainButtonW, $2ndRTop, $SmallButtonW, $ButtonH)
                    ;Third Row
                    $SWModButtonD7= GUICtrlCreatebutton("d7", $1stCLSide, $3rdRTop, $MainButtonW, $ButtonH)
                    $SWModButtonD7x= GUICtrlCreatebutton("x", $1stCLSide-$SmallButtonW, $3rdRTop, $SmallButtonW, $ButtonH)
                    $SWModButtonD7W= GUICtrlCreatebutton("w", $1stCLSide+$MainButtonW, $3rdRTop, $SmallButtonW, $ButtonH)
                    
                    $SWModButtonD8= GUICtrlCreatebutton("d8", $2ndCLSide, $3rdRTop, $MainButtonW, $ButtonH)
                    $SWModButtonD8x= GUICtrlCreatebutton("x", $2ndCLSide-$SmallButtonW, $3rdRTop, $SmallButtonW, $ButtonH)
                    $SWModButtonD8W= GUICtrlCreatebutton("w", $2ndCLSide+$MainButtonW, $3rdRTop, $SmallButtonW, $ButtonH)
                    
                    $SWModButtonD9= GUICtrlCreatebutton("d9", $3rdCLSide, $3rdRTop, $MainButtonW, $ButtonH)
                    $SWModButtonD9x= GUICtrlCreatebutton("x", $3rdCLSide-$SmallButtonW, $3rdRTop, $SmallButtonW, $ButtonH)
                    $SWModButtonD9W= GUICtrlCreatebutton("w", $3rdCLSide+$MainButtonW, $3rdRTop, $SmallButtonW, $ButtonH)
                    ;Fourth Row
                    $SWModButtonD10= GUICtrlCreatebutton("d10", $1stCLSide, $4thRTop, $MainButtonW, $ButtonH)
                    $SWModButtonD10x= GUICtrlCreatebutton("x", $1stCLSide-$SmallButtonW, $4thRTop, $SmallButtonW, $ButtonH)
                    $SWModButtonD10W= GUICtrlCreatebutton("w", $1stCLSide+$MainButtonW, $4thRTop, $SmallButtonW, $ButtonH)
                    
                    $SWModButtonD11= GUICtrlCreatebutton("d11", $2ndCLSide, $4thRTop, $MainButtonW, $ButtonH)
                    $SWModButtonD11x= GUICtrlCreatebutton("x", $2ndCLSide-$SmallButtonW, $4thRTop, $SmallButtonW, $ButtonH)
                    $SWModButtonD11W= GUICtrlCreatebutton("w", $2ndCLSide+$MainButtonW, $4thRTop, $SmallButtonW, $ButtonH)
                    
                    $SWModButtonD12= GUICtrlCreatebutton("d12", $3rdCLSide, $4thRTop, $MainButtonW, $ButtonH)
                    $SWModButtonD12x= GUICtrlCreatebutton("x", $3rdCLSide-$SmallButtonW, $4thRTop, $SmallButtonW, $ButtonH)
                    $SWModButtonD12W= GUICtrlCreatebutton("w", $3rdCLSide+$MainButtonW, $4thRTop, $SmallButtonW, $ButtonH)
                    ;Fifth Row
                    $SWModButtonD13= GUICtrlCreatebutton("d13", $1stCLSide, $5thRTop, $MainButtonW, $ButtonH)
                    $SWModButtonD13x= GUICtrlCreatebutton("x", $1stCLSide-$SmallButtonW, $5thRTop, $SmallButtonW, $ButtonH)
                    $SWModButtonD13W= GUICtrlCreatebutton("w", $1stCLSide+$MainButtonW, $5thRTop, $SmallButtonW, $ButtonH)
                    
                    $SWModButtonD14= GUICtrlCreatebutton("d14", $2ndCLSide, $5thRTop, $MainButtonW, $ButtonH)
                    $SWModButtonD14x= GUICtrlCreatebutton("x", $2ndCLSide-$SmallButtonW, $5thRTop, $SmallButtonW, $ButtonH)
                    $SWModButtonD14W= GUICtrlCreatebutton("w", $2ndCLSide+$MainButtonW, $5thRTop, $SmallButtonW, $ButtonH)
                    
                    $SWModButtonD15= GUICtrlCreatebutton("d15", $3rdCLSide, $5thRTop, $MainButtonW, $ButtonH)
                    $SWModButtonD15x= GUICtrlCreatebutton("x", $3rdCLSide-$SmallButtonW, $5thRTop, $SmallButtonW, $ButtonH)
                    $SWModButtonD15W= GUICtrlCreatebutton("w", $3rdCLSide+$MainButtonW, $5thRTop, $SmallButtonW, $ButtonH)
                    ;Sixth Row
                    $SWModButtonD16= GUICtrlCreatebutton("d16", $1stCLSide, $6thRTop, $MainButtonW, $ButtonH)
                    $SWModButtonD16x= GUICtrlCreatebutton("x", $1stCLSide-$SmallButtonW, $6thRTop, $SmallButtonW, $ButtonH)
                    $SWModButtonD16W= GUICtrlCreatebutton("w", $1stCLSide+$MainButtonW, $6thRTop, $SmallButtonW, $ButtonH)
                    
                    $SWModButtonD17= GUICtrlCreatebutton("d17", $2ndCLSide, $6thRTop, $MainButtonW, $ButtonH)
                    $SWModButtonD17x= GUICtrlCreatebutton("x", $2ndCLSide-$SmallButtonW, $6thRTop, $SmallButtonW, $ButtonH)
                    $SWModButtonD17W= GUICtrlCreatebutton("w", $2ndCLSide+$MainButtonW, $6thRTop, $SmallButtonW, $ButtonH)
                    
                    $SWModButtonD18= GUICtrlCreatebutton("d18", $3rdCLSide, $6thRTop, $MainButtonW, $ButtonH)
                    $SWModButtonD18x= GUICtrlCreatebutton("x", $3rdCLSide-$SmallButtonW, $6thRTop, $SmallButtonW, $ButtonH)
                    $SWModButtonD18W= GUICtrlCreatebutton("w", $3rdCLSide+$MainButtonW, $6thRTop, $SmallButtonW, $ButtonH)
                    ;Seventh Row
                    $SWModButtonD19= GUICtrlCreatebutton("d19", $1stCLSide+$LSideMod, $7thRTop, $MainButtonW, $ButtonH)
                    $SWModButtonD19x= GUICtrlCreatebutton("x", $1stCLSide+$LSideMod-$SmallButtonW, $7thRTop, $SmallButtonW, $ButtonH)
                    $SWModButtonD19W= GUICtrlCreatebutton("w", $1stCLSide+$LSideMod+$MainButtonW, $7thRTop, $SmallButtonW, $ButtonH)
                    
                    $SWModButtonD20= GUICtrlCreatebutton("d20", $2ndCLSide+$LSideMod, $7thRTop, $MainButtonW, $ButtonH)
                    $SWModButtonD20x= GUICtrlCreatebutton("x", $2ndCLSide+$LSideMod-$SmallButtonW, $7thRTop, $SmallButtonW, $ButtonH)
                    $SWModButtonD20W= GUICtrlCreatebutton("w", $2ndCLSide+$LSideMod+$MainButtonW, $7thRTop, $SmallButtonW, $ButtonH)
            $RavagedRulesDummyEnd= GUICtrlCreateDummy()
            
            $FateDummyStart= GUICtrlCreateDummy()
                $Fate= GUICtrlCreateGroup ("Fate",67,205,225,197)
                    GUICtrlCreateLabel("+8 Legendary" & @CRLF & "+7 Epic" & @CRLF & "+6 Fantastic" & @CRLF & "+5 Superb" & @CRLF & "+4 Great" & @CRLF & "+3 Good" & @CRLF & "+2 Good" & @CRLF & "+1 Average" & @CRLF & " 0 Mediocre" & @CRLF & "-1 Poor" & @CRLF & "-2 Terrible",83,241)
                    $LeftSide= 242
                    $TopOfButton= 242
                    $FatePts= GUICtrlCreateInput(1,$LeftSide,$TopOfButton+22,30,20)
                    GUICtrlSetState($FatePts,$GUI_DISABLE) ;Disable the control to prevent typed input
                    $MoreFatePts= GUICtrlCreateButton("More",$LeftSide,$TopOfButton,30,20)
                    $LessFatePts= GUICtrlCreateButton("Less",$LeftSide,$TopOfButton+43,30,20)
                    GUICtrlCreateLabel("Fate Points", $LeftSide-60,$TopOfButton+24)
                    
                    $LeftSide2= 183
                    $TopOfButton2= 343
                    $FtButton4dF= GUICtrlCreateButton("4dF",$LeftSide2,$TopOfButton2,40,40)
                    $FtButtonXdF= GUICtrlCreateButton("XdF",$LeftSide2+48,$TopOfButton2,40,40)
            $FateDummyEnd= GUICtrlCreateDummy()
            
            $GenericDummyStart= GUICtrlCreateDummy()
                $Generic= GUICtrlCreateGroup ("Fate",67,205,225,197)
                    $ButtonW=50
                    $HalfButtonW=25
                    $ButtonH=25
                    $1stCLSide=83
                    $2ndCLSide=153
                    $3rdCLSide=223
                    $TopRow=241
                    $1stRTop=$TopRow
                    $2ndRTop=$TopRow+40
                    $3rdRTop=$TopRow+80
                    $4thRTop=$TopRow+120
                    $SpecialButtonXD2= GUICtrlCreatebutton("x d2", $1stCLSide, $1stRTop, $ButtonW, $ButtonH)
                    $SpecialButtonXD3= GUICtrlCreatebutton("x d3", $2ndCLSide, $1stRTop, $ButtonW, $ButtonH)
                    $SpecialButtonXD4= GUICtrlCreatebutton("x d4", $3rdCLSide, $1stRTop, $ButtonW, $ButtonH)
                    $SpecialButtonXD6= GUICtrlCreatebutton("x d6", $1stCLSide, $2ndRTop, $ButtonW, $ButtonH)
                    $SpecialButtonXD8= GUICtrlCreatebutton("x d8", $2ndCLSide, $2ndRTop, $ButtonW, $ButtonH)
                    $SpecialButtonXD10= GUICtrlCreatebutton("x d10", $3rdCLSide, $2ndRTop, $ButtonW, $ButtonH)
                    $SpecialButtonXD12= GUICtrlCreatebutton("x d12", $1stCLSide, $3rdRTop, $ButtonW, $ButtonH)
                    $SpecialButtonXD20= GUICtrlCreatebutton("x d20", $2ndCLSide, $3rdRTop, $ButtonW, $ButtonH)
                    $SpecialButtonXD100= GUICtrlCreatebutton("x d100", $3rdCLSide, $3rdRTop, $ButtonW, $ButtonH)
                    $SpecialButtonXDY= GUICtrlCreatebutton("x d", $1stCLSide, $4thRTop, $HalfButtonW, $ButtonH)
                    $SpecialButtonDiePip= GUICtrlCreatebutton("Y", $1stCLSide+$HalfButtonW, $4thRTop, $ButtonW-$HalfButtonW, $ButtonH)
                    $DnDAttrib= GUICtrlCreatebutton("DnD Attribute Roll", $2ndCLSide, $4thRTop, $2ndCLSide-$1stCLSide+$ButtonW, $ButtonH)
            $GenericDummyEnd= GUICtrlCreateDummy()
        $GameAreaDummyEnd= GUICtrlCreateDummy()
    $ControlAreaDummyEnd = GUICtrlCreateDummy() ;<-- Added this here for end of controls
    SwitchGames($FateDummyStart,$FateDummyEnd)

GuiSetState ()

For $q = $ControlAreaDummyStart To $ControlAreaDummyEnd ;<-- Added this loop to set DockAll on all controls between start and end
    GUICtrlSetResizing($q, $GUI_DOCKALL)
Next ;<-- Added this ... that's it no more added

; Run the GUI until the dialog is closed
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GameSelector
            Select
                Case GUICtrlRead($GameSelector) = "Savage Worlds"
                    SwitchGames($SavageWorldsDummyStart,$SavageWorldsDummyEnd)
                Case GUICtrlRead($GameSelector) = "Savage Worlds- Ravaged Rules"
                    SwitchGames($RavagedRulesDummyStart,$RavagedRulesDummyEnd)
                Case GUICtrlRead($GameSelector) = "Fate"
                    SwitchGames($FateDummyStart,$FateDummyEnd)
                Case GUICtrlRead($GameSelector) = "Generic"
                    SwitchGames($GenericDummyStart,$GenericDummyEnd)
            EndSelect               
        Case $msg = $FtButton4dF
            FateDie()
        Case $msg = $FtButtonXdF
            FateMultiDie(GUICtrlRead($NumberSelected))
        Case $msg = $MoreFatePts
            AdjustPoints("U")
        Case $msg = $LessFatePts
            AdjustPoints("D")
        Case $msg = $KeepOnTop
            If GUICtrlRead($KeepOnTop) = 1 Then
                WinSetOnTop($GUIHandle,"",1)
            Else
                WinSetOnTop($GUIHandle,"",0)
            EndIf
        Case $msg = $DisplayHelp
            GUICtrlSetData($OutputWindow,"Help file not written yet, sorry." & @CRLF & GuiCtrlRead($OutputWindow))
        Case $msg = $ClearButton
            GUICtrlSetData($OutputWindow,"")
        Case $msg = $DnDAttrib
            DnDAttributes()
        Case $msg = $DrawRandomCard
            DrawRandomCard()
        Case $msg = $DrawFromDeck1
            DrawFromDeck1()
        Case $msg = $ReshuffleDeck1
            InitializeCardDeck1()
            GUICtrlSetData($OutputWindow,"Shuffled deck 1" & @CRLF & GuiCtrlRead($OutputWindow))
        Case $msg = $IssueCards
            IssueCards(GUICtrlRead($NumberSelected)) ;Read the number selection to get the number of players to issue cards to.
        Case $msg = $DrawFromDeck2
            DrawFromDeck2()
        Case $msg = $ReshuffleDeck2
            InitializeCardDeck2()
            GUICtrlSetData($OutputWindow,"Shuffled deck 2" & @CRLF & GuiCtrlRead($OutputWindow))
        Case $msg = $ShowADeck
            _ArrayDisplay($FullDeck,"Card Deck")
        Case $msg = $QuickButtonD2
            easydie(2)
        Case $msg = $QuickButtonD3
            easydie(3)
        Case $msg = $QuickButtonD4
            easydie(4)
        Case $msg = $QuickButtonD6
            easydie(6)
        Case $msg = $QuickButtonD8
            easydie(8)
        Case $msg = $QuickButtonD10
            easydie(10)
        Case $msg = $QuickButtonD12
            easydie(12)
        Case $msg = $QuickButtonD20
            easydie(20)
        Case $msg = $QuickButtonD100
            easydie(100)
        Case $msg = $QuickButtonDX
            easydie(GUICtrlRead($NumberSelected))
        Case $msg = $SpecialButtonXD2
            multidie(2)
        Case $msg = $SpecialButtonXD3
            multidie(3)
        Case $msg = $SpecialButtonXD4
            multidie(4)
        Case $msg = $SpecialButtonXD6
            multidie(6)
        Case $msg = $SpecialButtonXD8
            multidie(8)
        Case $msg = $SpecialButtonXD10
            multidie(10)
        Case $msg = $SpecialButtonXD12
            multidie(12)
        Case $msg = $SpecialButtonXD20
            multidie(20)
        Case $msg = $SpecialButtonXD100
            multidie(100)
        Case $msg = $SpecialButtonXDY
            if $x = "Y" then 
                GUICtrlSetData($OutputWindow, "You have to choose a die-type and press the right button" & @CRLF & GuiCtrlRead($OutputWindow))
            else
               multidie(GUICtrlRead($SpecialButtonDiePip))
            endif
        Case $msg = $SpecialButtonDiePip
            GUICtrlSetData ($SpecialButtonDiePip, GUICtrlRead($NumberSelected))

        Case $msg = $RollDownWindow
            GUICtrlSetState($RollUpWindow,$GUI_ENABLE + $GUI_SHOW)
            GUICtrlSetState($RollDownWindow,$GUI_DISABLE + $GUI_HIDE)
            $WinSizeArray= WinGetPos($GUIHandle)
            WinMove($GUIHandle,"",$WinSizeArray[0],$WinSizeArray[1],$WinSizeArray[2]+170,$WinSizeArray[3]+375)
        Case $msg = $RollUpWindow
            GUICtrlSetState($RollDownWindow,$GUI_ENABLE + $GUI_SHOW)
            GUICtrlSetState($RollUpWindow,$GUI_DISABLE + $GUI_HIDE)
            $WinSizeArray= WinGetPos($GUIHandle)
            WinMove($GUIHandle,"",$WinSizeArray[0],$WinSizeArray[1],$WinSizeArray[2]-170,$WinSizeArray[3]-375)
            
        Case $msg = $SWButtonUnsk
            savagedie("unskilled")
        Case $msg = $SWButtonUnskx ;x dices
            savagemultidie("unskilled")
        Case $msg = $SWButtonUnskw ;Wild Die
            savagewilddie("unskilled")
        Case $msg = $SWButtonD4
            savagedie(4)
        Case $msg = $SWButtonD4x ;x dices
            savagemultidie(4)
        Case $msg = $SWButtonD4w ;Wild Die
            savagewilddie(4)
        Case $msg = $SWButtonD6
            savagedie(6)
        Case $msg = $SWButtonD6x ;x dices
            savagemultidie(6)
        Case $msg = $SWButtonD6w ;Wild Die
            savagewilddie(6)
        Case $msg = $SWButtonD8
            savagedie(8)
        Case $msg = $SWButtonD8x ;x dices
            savagemultidie(8)
        Case $msg = $SWButtonD8w ;Wild Die
            savagewilddie(8)
        Case $msg = $SWButtonD10
            savagedie(10)
        Case $msg = $SWButtonD10x ;x dices
            savagemultidie(10)
        Case $msg = $SWButtonD10w ;Wild Die
            savagewilddie(10)
        Case $msg = $SWButtonD12
            savagedie(12)
        Case $msg = $SWButtonD12x ;x dices
            savagemultidie(12)
        Case $msg = $SWButtonD12w ;Wild Die
            savagewilddie(12)
        Case $msg = $SWButtonD20
            savagedie(20)
        Case $msg = $SWButtonD20x ;x dices
            savagemultidie(20)
        Case $msg = $SWButtonD20w ;Wild Die
            savagewilddie(20)
         
        Case $msg = $SWModButtonD1
            savagedie(1)
        Case $msg = $SWModButtonD1x ;x dices
            savagemultidie(1)
        Case $msg = $SWModButtonD1W ;Wild Die
            savagewilddie(1)
        Case $msg = $SWModButtonD2
            savagedie(2)
        Case $msg = $SWModButtonD2x ;x dices
            savagemultidie(2)
        Case $msg = $SWModButtonD2W ;Wild Die
            savagewilddie(2)
        Case $msg = $SWModButtonD3
            savagedie(3)
        Case $msg = $SWModButtonD3x ;x dices
            savagemultidie(3)
        Case $msg = $SWModButtonD3W ;Wild Die
            savagewilddie(3)
        Case $msg = $SWModButtonD4
            savagedie(4)
        Case $msg = $SWModButtonD4x ;x dices
            savagemultidie(4)
        Case $msg = $SWModButtonD4W ;Wild Die
            savagewilddie(4)
        Case $msg = $SWModButtonD5
            savagedie(5)
        Case $msg = $SWModButtonD5x ;x dices
            savagemultidie(5)
        Case $msg = $SWModButtonD5W ;Wild Die
            savagewilddie(5)
        Case $msg = $SWModButtonD6
            savagedie(6)
        Case $msg = $SWModButtonD6x ;x dices
            savagemultidie(6)
        Case $msg = $SWModButtonD6W ;Wild Die
            savagewilddie(6)
        Case $msg = $SWModButtonD7
            savagedie(7)
        Case $msg = $SWModButtonD7x ;x dices
            savagemultidie(7)
        Case $msg = $SWModButtonD7W ;Wild Die
            savagewilddie(7)
        Case $msg = $SWModButtonD8
            savagedie(8)
        Case $msg = $SWModButtonD8x ;x dices
            savagemultidie(8)
        Case $msg = $SWModButtonD8W ;Wild Die
            savagewilddie(8)
        Case $msg = $SWModButtonD9
            savagedie(9)
        Case $msg = $SWModButtonD9x ;x dices
            savagemultidie(9)
        Case $msg = $SWModButtonD9W ;Wild Die
            savagewilddie(9)
        Case $msg = $SWModButtonD10
            savagedie(10)
        Case $msg = $SWModButtonD10x ;x dices
            savagemultidie(10)
        Case $msg = $SWModButtonD10W ;Wild Die
            savagewilddie(10)
        Case $msg = $SWModButtonD11
            savagedie(11)
        Case $msg = $SWModButtonD11x ;x dices
            savagemultidie(11)
        Case $msg = $SWModButtonD11W ;Wild Die
            savagewilddie(11)
        Case $msg = $SWModButtonD12
            savagedie(12)
        Case $msg = $SWModButtonD12x ;x dices
            savagemultidie(12)
        Case $msg = $SWModButtonD12W ;Wild Die
            savagewilddie(12)
        Case $msg = $SWModButtonD13
            savagedie(13)
        Case $msg = $SWModButtonD13x ;x dices
            savagemultidie(13)
        Case $msg = $SWModButtonD13W ;Wild Die
            savagewilddie(13)
        Case $msg = $SWModButtonD14
            savagedie(14)
        Case $msg = $SWModButtonD14x ;x dices
            savagemultidie(14)
        Case $msg = $SWModButtonD14W ;Wild Die
            savagewilddie(14)
        Case $msg = $SWModButtonD15
            savagedie(15)
        Case $msg = $SWModButtonD15x ;x dices
            savagemultidie(15)
        Case $msg = $SWModButtonD15W ;Wild Die
            savagewilddie(15)
        Case $msg = $SWModButtonD16
            savagedie(16)
        Case $msg = $SWModButtonD16x ;x dices
            savagemultidie(16)
        Case $msg = $SWModButtonD16W ;Wild Die
            savagewilddie(16)
        Case $msg = $SWModButtonD17
            savagedie(17)
        Case $msg = $SWModButtonD17x ;x dices
            savagemultidie(17)
        Case $msg = $SWModButtonD17W ;Wild Die
            savagewilddie(17)
        Case $msg = $SWModButtonD18
            savagedie(18)
        Case $msg = $SWModButtonD18x ;x dices
            savagemultidie(18)
        Case $msg = $SWModButtonD18W ;Wild Die
            savagewilddie(18)
        Case $msg = $SWModButtonD19
            savagedie(19)
        Case $msg = $SWModButtonD19x ;x dices
            savagemultidie(19)
        Case $msg = $SWModButtonD19W ;Wild Die
            savagewilddie(19)
        Case $msg = $SWModButtonD20
            savagedie(20)
        Case $msg = $SWModButtonD20x ;x dices
            savagemultidie(20)
        Case $msg = $SWModButtonD20W ;Wild Die
            savagewilddie(20)
            
        Case $msg = $FateButtonWeak
            fatetable(3,15,84)
        Case $msg = $FateButtonLow
            fatetable(5,25,86)
        Case $msg = $FateButtonBelowAvg
            fatetable(7,35,88)
        Case $msg = $FateButtonAvg
            fatetable(10,50,91)
        Case $msg = $FateButtonAboveAvg
            fatetable(13,65,94)
        Case $msg = $FateButtonHigh
            fatetable(15,75,96)
        Case $msg = $FateButtonExcep
            fatetable(16,85,97)
    EndSelect
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
Wend
   
;~ ---------------------------------------------------------------------------------------------------------------
;~ --------------------------------------- End of Main Script ----------------------------------------------------
;~ ---------------------------------------------------------------------------------------------------------------

Func SwitchGames($StartID,$EndID)
    For $q = $GameAreaDummyStart To $GameAreaDummyEnd ;<-- Added this loop to set DockAll on all controls between start and end
        GUICtrlSetState($q, $GUI_DISABLE + $GUI_HIDE)
    Next ;<-- Added this ... that's it no more added
    For $q = $StartID To $EndID
        GUICtrlSetState($q, $GUI_ENABLE + $GUI_SHOW)
    Next    
EndFunc

Func FateDie()
    dim $avResults[4]   ;Stores the "+", "-", and "0" die results
    dim $total          ;Stores the final total
    Dim $Roll           ;Stores the individual die roll (either -1, 0, or 1)
    Dim $Mod            ;Stores either "+", "-", or "0" depending on the value of the total
    $total = 0
    For $i = 0 To 3
        $Roll= Random(-1,1,1)
        $total= $total + $Roll
        If $Roll < 0 Then
            $avResults[$i] = "-"
        ElseIf $Roll > 0 Then
            $avResults[$i] = "+"
        Else
            $avResults[$i] = "0"
        EndIf
    Next
    If $total < 0 Then
        $Mod = "-"
    ElseIf $total > 0 Then
        $Mod = "+"
    Else
        $Mod = ""
    EndIf
    If GUICtrlRead($SortResults)=1 then _ArraySort( $avResults,1) ;Sorts array, 1= descending
    GUICtrlSetData($OutputWindow, $avResults[0] & ", " & $avResults[1] & ", " & $avResults[2] & ", " & $avResults[3] & " (Result: " & Abs($total) & $Mod & " | 4dF)" & @CRLF & GuiCtrlRead($OutputWindow))
EndFunc

Func FateMultiDie($NumberOfDice)
    dim $avResults[$NumberOfDice]   ;Stores the "+", "-", and "0" die results
    dim $total                      ;Stores the final total
    Dim $Roll                       ;Stores the individual die roll (either -1, 0, or 1)
    Dim $Mod                        ;Stores either "+", "-", or "0" depending on the value of the total
    Dim $ResultString               ;Stores the results
    $total = 0
    For $i = 0 To $NumberOfDice - 1
        $Roll= Random(-1,1,1)
        $total= $total + $Roll
        If $Roll < 0 Then
            $avResults[$i] = "-"
        ElseIf $Roll > 0 Then
            $avResults[$i] = "+"
        Else
            $avResults[$i] = "0"
        EndIf
    Next
    If $total < 0 Then
        $Mod = "-"
    ElseIf $total > 0 Then
        $Mod = "+"
    Else
        $Mod = ""
    EndIf
    If GUICtrlRead($SortResults)=1 then _ArraySort( $avResults,1) ;Sorts array, 1= descending
    $ResultString = $avResults[0]   ;Create the result string
    For $i = 1 To $NumberOfDice - 1
        $ResultString = $ResultString & ", " & $avResults[$i]
    Next
    GUICtrlSetData($OutputWindow, $ResultString & " (Result: " & Abs($total) & $Mod & " | " & $NumberOfDice & "dF)" & @CRLF & GuiCtrlRead($OutputWindow))
EndFunc

Func AdjustPoints($Direction)
    $CurrentNumber = GUICtrlRead($FatePts)
    If $Direction = "U" Then
        $NewNumber = $CurrentNumber + 1
    Else
        $NewNumber = $CurrentNumber - 1
    EndIf
    GUICtrlSetData($FatePts, $NewNumber)
EndFunc

Func easydie($die) ; simple die with output
   $results = Random(1,$die, 1)
   GUICtrlSetData($OutputWindow,  $results & " (d" &$die &")" & @CRLF & GuiCtrlRead($OutputWindow))
EndFunc

Func multidie($die) ; multible dice rolls with output
   dim $avArray[GUICtrlRead($NumberSelected)+1] ;This seems like the array is being declared with an extra element, don't know why
   $string1=GUICtrlRead($NumberSelected)&"d"&$die ;the number of dice followed by the number of pips
   for $i = 1 to GUICtrlRead($NumberSelected)
      $avArray[$i-1]=Random(1,$die,1) ;$avArray[$i-1] is because the array element numbering starts at 0
   Next
   if GUICtrlRead($SortResults)=1 then _ArraySort( $avArray,1) ;Sorts array, 1= descending
   $string=$avArray[0] ;Load the first element of the array inro $string
   $total=int($avArray[0]) ;Load the first element of the array into $total
   for $i = 1 to (GUICtrlRead($NumberSelected)-1)
      $string=  $string & ", " & $avArray[$i] ;Read the array values into a variable seperated by a comma and a space
      $total=$total+int($avArray[$i]) ;Add the values in the array together
   Next
   GUICtrlSetData($OutputWindow, $string & " (" & "Total: " & $total & " | " &$string1 & ")" & @CRLF & GuiCtrlRead($OutputWindow))
EndFunc

Func DnDAttributes() ; D&D 3 Attribute roller (4d6 keep highest 3)
   dim $avArray[4]
   dim $total[6]
   for $j = 0 to 5 ;Generate 6 different numbers
      for $i = 0 to 3 ;Track array elements
         $avArray[$i]=Random(1,6,1) ;Generate random values to store in the array.
      next
      _ArraySort( $avArray,1) ;Sort the array, descneding
      $total[$j]=$avArray[0]+$avArray[1]+$avArray[2] ;add the first three (highest) values of the sorted array into the result array
   next
   _ArraySort($total,1) ;Sort the six results, descending
   GUICtrlSetData($OutputWindow, "D&D Attributes: " & $total[0] & ", " & $total[1] & ", " & $total[2] & ", " & $total[3] & ", " & $total[4] & ", " & $total[5] & @CRLF & GuiCtrlRead($OutputWindow))
endfunc

Func savagedie($diex) ; roll again on max, unskilled d4-2
   if $diex="unskilled" then ;If the  button (die) = unskilled, then set the die to 4 and subtract 2 from the results.
      $die=4
      $results=-2
      $string1="unskilled"
  elseif $diex=1 then ;If a 1 is passed, use the formula d2-1 provided in the SW Attribute+ Skill doc to resolve the roll
      $die=2
      $results=-1
      $string1="d"&$diex
   else ;if $diex is 2 or more, the die = the value of the button and the results are not modified.
      $die=$diex
      $results=0
      $string1="d"&$diex
   endif
   Do ;Generate die numbers until the number generated is less than the maximum number of pips on the die.  Add the numbers to get the final results
      $x=Random(1,$die,1)
      $results=$results+$x
   until $x<$die 
   GUICtrlSetData($OutputWindow, $results & " (" & $string1 & ")" & @CRLF & GuiCtrlRead($OutputWindow))
EndFunc

Func savagemultidie($diex) ;Same as savagedie but multiple dies
   dim $avArray[GUICtrlRead($NumberSelected)+1]
   if $diex="unskilled" then
      $die=4
      $string1="unskilled"
   elseif $diex=1 Then
      $die=2
      $string1=GUICtrlRead($NumberSelected)&"d"&$diex
   else
      $die=$diex
      $string1=GUICtrlRead($NumberSelected)&"d"&$diex
   endif
   for $i = 1 to GUICtrlRead($NumberSelected)
      if $diex="unskilled" then
         $avArray[$i-1]=-2
     elseif $diex=1 then
         $avArray[$i-1]=-1
     else
         $avArray[$i-1]=0
      endif
      Do
         $x=Random(1,$die,1)
         $avArray[$i-1]=$avArray[$i-1]+$x ;add the numbers to the $avArray variable at element $i-1
      until $x<$die         
   Next
   if GUICtrlRead($SortResults)=1 then _ArraySort( $avArray,1)
   $string=$avArray[0]
   $total=int($avArray[0])
   for $i = 1 to (GUICtrlRead($NumberSelected)-1)
      $string=  $string & ", " & $avArray[$i]
      $total=$total+int($avArray[$i])
   Next
   GUICtrlSetData($OutputWindow, $string & " (" & "Total: " & $total & " | " &$string1 & ")" & @CRLF & GuiCtrlRead($OutputWindow))
Endfunc

Func savagewilddie($diex) ; same as savagedie but roll also an additional d6 (wild die) -> higher roll counts
   if $diex="unskilled" then
      $die=4
      $results1=-2
      $results2=-2
      $string1="unskilled"
   elseif $diex=1 then
      $die=2
      $results1=-1
      $results2=-1
      $string1="d"&$diex
   else
      $die=$diex
      $results1=0
      $results2=0
      $string1="d"&$diex
   endif
   Do
      $x=Random(1,$die,1)
      $results1=$results1+$x
   until $x<$die 
   Do
      $x=Random(1,6,1)
      $results2=$results2+$x
   until $x<6
   if $results1 >= $results2 then
         $string = $results1 & ", " & $results2 & "w (" & $string1 & ")"
   else
         $string = $results2 & "w, " & $results1 & " (" & $string1 & ")"
   endif
   GUICtrlSetData($OutputWindow, $string & @CRLF & GuiCtrlRead($OutputWindow))
endfunc

Func InitializeFullDeck() ;Create an array containing a full deck of cards, the placeholder is just window dressing in this deck 
    $FullDeck = _ArrayCreate("Ace of Spades", "Ace of Diamonds", "Ace of Hearts", "Ace of Clubs")
    For $i=2 To 13
        Switch $i
            Case 2 To 10
                $CardValue= $i
            Case 11
                $CardValue= "Jack"
            Case 12
                $CardValue= "Queen"
            Case 13
                $CardValue= "King"
        EndSwitch
        _ArrayAdd( $FullDeck,$CardValue&" of Spades")
        _ArrayAdd( $FullDeck,$CardValue&" of Diamonds")
        _ArrayAdd( $FullDeck,$CardValue&" of Hearts")
        _ArrayAdd( $FullDeck,$CardValue&" of Clubs")
    Next
    _ArrayAdd($FullDeck,"Little Joker")
    _ArrayAdd($FullDeck,"Big Joker")
    _ArrayAdd($FullDeck,"Placeholder")
EndFunc

Func InitializeCardDeck1() ;create a deck of cards, the placeholder is so that there is still an element in the array when all the rest of the cards have been chosen.
    $CardDeck1 = _ArrayCreate("Ace of Spades", "Ace of Diamonds", "Ace of Hearts", "Ace of Clubs")
    For $i=2 To 13
        Switch $i
            Case 2 To 10
                $CardValue= $i
            Case 11
                $CardValue= "Jack"
            Case 12
                $CardValue= "Queen"
            Case 13
                $CardValue= "King"
        EndSwitch
        _ArrayAdd( $CardDeck1,$CardValue&" of Spades")
        _ArrayAdd( $CardDeck1,$CardValue&" of Diamonds")
        _ArrayAdd( $CardDeck1,$CardValue&" of Hearts")
        _ArrayAdd( $CardDeck1,$CardValue&" of Clubs")
    Next
    _ArrayAdd($CardDeck1,"Little Joker")
    _ArrayAdd($CardDeck1,"Big Joker")
    _ArrayAdd($CardDeck1,"Placeholder")
EndFunc

Func InitializeCardDeck2() ;Same as Deck 1
    $CardDeck2 = _ArrayCreate("Ace of Spades", "Ace of Diamonds", "Ace of Hearts", "Ace of Clubs")
    For $i=2 To 13
        Switch $i
            Case 2 To 10
                $CardValue= $i
            Case 11
                $CardValue= "Jack"
            Case 12
                $CardValue= "Queen"
            Case 13
                $CardValue= "King"
        EndSwitch
        _ArrayAdd( $CardDeck2,$CardValue&" of Spades")
        _ArrayAdd( $CardDeck2,$CardValue&" of Diamonds")
        _ArrayAdd( $CardDeck2,$CardValue&" of Hearts")
        _ArrayAdd( $CardDeck2,$CardValue&" of Clubs")
    Next
    _ArrayAdd($CardDeck2,"Little Joker")
    _ArrayAdd($CardDeck2,"Big Joker")
    _ArrayAdd($CardDeck2,"Placeholder")
EndFunc

Func DrawRandomCard()
    $i=Random(0,53)
    $CardDrawn=$FullDeck[$i]
    GUICtrlSetData($OutputWindow, $CardDrawn & @CRLF & GuiCtrlRead($OutputWindow))
EndFunc

Func DrawFromDeck1()
    $NumberOfCardsLeft=UBound($CardDeck1)-1 ;Subtract 1 for the placeholder
    $i=Random(0, $NumberOfCardsLeft)
    $CardDrawn=$CardDeck1[$i]
    _ArrayDelete($CardDeck1,$i)
    GUICtrlSetData($OutputWindow, $CardDrawn & @CRLF & GuiCtrlRead($OutputWindow))
    If UBound($CardDeck1)=1 Then
        InitializeCardDeck1()
        GUICtrlSetData($OutputWindow, "Out of Cards.  Deck 1 reshuffled." & @CRLF & GuiCtrlRead($OutputWindow))
    EndIf
EndFunc

Func IssueCards($NumberOfPlayers)
    Dim $CardsPicked[$NumberOfPlayers] ;Create an array to hold the cards picked
    $NumberOfCardsLeft=UBound($CardDeck2)-1 ;Subtract 1 for the placeholder
    If $NumberOfPlayers > 54 Then
        GUICtrlSetData($OutputWindow, $NumberOfPlayers & "?!  Thats more players then cards in the deck.  Please choose a smaller number." & @CRLF & GuiCtrlRead($OutputWindow))
        Return
    ElseIf $NumberOfPlayers > $NumberOfCardsLeft Then
        InitializeCardDeck2()
        GUICtrlSetData($OutputWindow, "- - - - - -" & @CRLF & GuiCtrlRead($OutputWindow))
        GUICtrlSetData($OutputWindow, "More players than cards remaining.  Deck 2 reshuffled." & @CRLF & GuiCtrlRead($OutputWindow))
    EndIf
    GUICtrlSetData($OutputWindow, "-----------" & @CRLF & GuiCtrlRead($OutputWindow))
    For $i = 0 To $NumberOfPlayers-1 ;Load the card array.
        $j=Random(0, $NumberOfCardsLeft)
        $CardDrawn=$CardDeck2[$j]
        _ArrayDelete($CardDeck2,$j)
        $CardsPicked[$i]=$CardDrawn
        $NumberOfCardsLeft=UBound($CardDeck2)-1 ;Reset the number of cards left in the deck. Subtract 1 for the placeholder
    Next
    For $i = $NumberOfPlayers-1 To 0 Step -1
        GUICtrlSetData($OutputWindow, "Player " & $i+1 & ": " & $CardsPicked[$i] & @CRLF & GuiCtrlRead($OutputWindow))
    Next
    If UBound($CardDeck2)=1 Then
        InitializeCardDeck2()
        GUICtrlSetData($OutputWindow, "Out of Cards.  Deck 2 reshuffled." & @CRLF & GuiCtrlRead($OutputWindow))
    EndIf
EndFunc

Func DrawFromDeck2()
    $NumberOfCardsLeft=UBound($CardDeck2)-1 ;Subtract 1 for the placeholder
    $i=Random(0, $NumberOfCardsLeft)
    $CardDrawn=$CardDeck2[$i]
    _ArrayDelete($CardDeck2,$i)
    GUICtrlSetData($OutputWindow, $CardDrawn & @CRLF & GuiCtrlRead($OutputWindow))
    If UBound($CardDeck2)=1 Then
        InitializeCardDeck2()
        GUICtrlSetData($OutputWindow, "Out of Cards.  Deck 2 reshuffled." & @CRLF & GuiCtrlRead($OutputWindow))
    EndIf
EndFunc

Func fatetable($1,$2,$3) ; choose how probale a question is and it will thell you Yes++/Yes/No/No-- -> more explaination in the Mythic RPG
    $results = Random(1,100, 1)
   Select
        Case $results <= $1
            GUICtrlSetData($OutputWindow, "Yes maximum" & @CRLF & GuiCtrlRead($OutputWindow))
        Case $results <= $2
            GUICtrlSetData($OutputWindow, "Yes" & @CRLF & GuiCtrlRead($OutputWindow))
        Case $results < $3
            GUICtrlSetData($OutputWindow, "No" & @CRLF & GuiCtrlRead($OutputWindow))
        Case Else
            GUICtrlSetData($OutputWindow, "No maximum" & @CRLF & GuiCtrlRead($OutputWindow))
   EndSelect
EndFunc

Thanks for any help.

Regards,

Z

Link to comment
Share on other sites

Ok,

I figured it out. Instead of setting GUICtrlGetState($Control) = $GUI_ENABLE, you should make sure that

GUICtrlGetState($Control) < $GUI_DISABLE. This works because any controls that are disabled must be greater than or equal to the value of $GUI_DISABLE (which is 128). Anyway, here is the code after the fix:

#include <GUIConstants.au3>
#include <Array.au3>

$GUIHandle= GUICreate("Demo2", 210,235, -1, -1)

    $TabSelector= GUICtrlCreateCombo("",5,5,83,20)
        GUICtrlSetData($TabSelector,"Tab1|Tab2|Tab3", "Tab1")
    $TabAreaDummyStart= GUICtrlCreateDummy()
        $Tab1DummyStart= GUICtrlCreateDummy()
            $Tab1= GUICtrlCreateGroup("Tab1",5,30,200,200)
                GUICtrlCreateLabel("Tab the First",75,100,80,20)
        $Tab1DummyEnd= GUICtrlCreateDummy()
        $Tab2DummyStart= GUICtrlCreateDummy()
            $Tab2= GUICtrlCreateGroup("Tab2",5,30,200,200)
                GUICtrlCreateLabel("Tab the Second",75,100,80,20)
        $Tab2DummyEnd= GUICtrlCreateDummy()
        $Tab3DummyStart= GUICtrlCreateDummy()
            $Tab3= GUICtrlCreateGroup("Tab3",5,30,200,200)
                GUICtrlCreateLabel("Tab the Third",75,100,80,20)
        $Tab3DummyEnd= GUICtrlCreateDummy()
    $TabAreaDummyEnd= GUICtrlCreateDummy()
    SwitchTabs($Tab1DummyStart,$Tab1DummyEnd)
GUISetState()

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $TabSelector
            Select
                Case GUICtrlRead($TabSelector) = "Tab1"
                    SwitchTabs($Tab1DummyStart,$Tab1DummyEnd)
                Case GUICtrlRead($TabSelector) = "Tab2"
                    SwitchTabs($Tab2DummyStart,$Tab2DummyEnd)
                Case GUICtrlRead($TabSelector) = "Tab3"
                    SwitchTabs($Tab3DummyStart,$Tab3DummyEnd)
            EndSelect
    EndSelect
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
WEnd
    
Func SwitchTabs($StartID,$EndID)
    Select
        Case GUICtrlGetState($Tab1)< $GUI_DISABLE
            $DisableCtrlIDStart= $Tab1DummyStart
            $DisableCtrlIDEnd= $Tab1DummyEnd
        Case GUICtrlGetState($Tab2)< $GUI_DISABLE
            $DisableCtrlIDStart= $Tab2DummyStart
            $DisableCtrlIDEnd= $Tab2DummyEnd
        Case GUICtrlGetState($Tab3)< $GUI_DISABLE
            $DisableCtrlIDStart= $Tab3DummyStart
            $DisableCtrlIDEnd= $Tab3DummyEnd
    EndSelect
    For $q = $DisableCtrlIDStart To $DisableCtrlIDEnd
        GUICtrlSetState($q, $GUI_DISABLE + $GUI_HIDE)
    Next
    For $q = $StartID To $EndID
        GUICtrlSetState($q, $GUI_ENABLE + $GUI_SHOW)
    Next    
EndFunc

And the code for the die roller:

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_outfile=Odds and Evens v0.1.exe
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****

;~ Program:             Odds and Evens
;~ Script Compiler:     Autoit version: 3
;~ Author:              Simon Goodson
;~ Email:               zealott@hotmail.com
;~ Date:                7 Nov 2007
;~
;~ Based on:            Flanf's Die Roller v1.6
;~ Coded by:            Christoph Flandorfer
;~ Created on:          13 Sept 2006
;~
;~ Special Thanks To:   smashly from the forums for helping me to unclutter the rolled up window
;~
;~ Script Function:
;~ A dice roller, card picker, and point tracker for use in RPGs or whatever
;~
;~ Odds and Evens
;~ --------------
;~ Planned v0.2     Create a new way to select which games are displayed, combo or list box
;~                  Move the point tracker out into the general area somewhere
;~                  Move the DnD thing onto its own tab.
;~                  Get rid of the generic tab and move its functions into the Essentials area
;~                  
;~ v0.2     Swapped the positions of the "Roll Up Window" and KWoT checkbox button with the "Clear Results"
;~              button and made the window roll up to just show the "Roll Down Window" and KWoT buttons
;~ v0.1     Renamed app to "Odds and Evens"
;~          Began redisign of GUI
;~          Adding "Stay on Top" feature
;~          Adding "Roll-up Window" feature
;~          Adding Fate Dice function
;~          
;~ Flanf's Dice Roller
;~ -------------------
;- Version 1.6a:    Switched the output window around to get more space for the dice buttons
;-                  Added a tab to perform d1 through d20 wild dice.
;-                  Added the d20 dice to the S.Worlds tab, mostly for asthetics
;-                  Moved the card functions to its own section
;-                  Implemented 3 decks, 1 always containing all the cards, 1 to pick 1 card at a time out, and
;-                      one to issue multiple cards for combat also with a function to pick singles if needed
;-                  Moved the sort function so that all the dice results could be sorted or not depending on preference
;-                  Generated a random number and used it to seed the random table
;-                  Added a bunch of remarks to help me (Simon) understand the code
;~ Version 1.6: You can now draw Cards WITHOUT Shuffeling under Savage Worlds.
;~ Version 1.5: Marked the Wild Die Result in Savage Worlds.
;~ Version 1.4: The Fate-Table moved from the tabs to the right side and will be always easily available. Massive Changes to the GUI
;~ Version 1.3: Changes in the Output of the Savage Die Rolls (Wild Card & Sort Function). Savage Worlds is now default Tab
;~ Version 1.2: Includes now part of the Fate-Table from the Mythic RPG
;~ Version 1.1: Now with Pokercards (+2 Joker) (Savage Worlds)

#include <GUIConstants.au3>
#include <Array.au3>

;Global $cardsindeck
Global $FullDeck ;Declare 3 arrays to contain card decks
Global $CardDeck1
Global $CardDeck2
InitializeFullDeck() ;Calls the Initialize function to create the cards decks
InitializeCardDeck1()
InitializeCardDeck2()

; Generates a random number between 1 and 1 million and uses it to seed the random number generator
$RandomSeed=random(1,1000000,1)
SRandom($RandomSeed) 

; Define the GUI


$GUIHandle= GUICreate("Odds and Evens", 420, 405, -1, -1)
    
    $ControlAreaDummyStart = GUICtrlCreateDummy() ;<-- Added this here for start of controls
        $GameSelector= GUICtrlCreateCombo("",252,5,83,20)
            GUICtrlSetData($GameSelector,"Savage Worlds|Savage Worlds- Ravaged Rules|Fate|Generic", "Fate")
        $LSide= 5
        $Column1Mod= 6
        $Column2Mod= 76
        $Column3Mod= 116
        $x= 22
        $BeginningRow= 46
        GUICtrlCreateGroup("Essentials",$LSide,28,156,173)
        $FateButtonWeak= GUICtrlCreateButton("Weak", $LSide+$Column1Mod, $BeginningRow, 65, 15)
        $FateButtonLow= GUICtrlCreateButton("Low", $LSide+$Column1Mod, $BeginningRow+($x*1), 65, 15)
        $FateButtonBelowAvg= GUICtrlCreateButton("Below Av.", $LSide+$Column1Mod, $BeginningRow+($x*2), 65, 15)
        $FateButtonAvg= GUICtrlCreateButton("Average", $LSide+$Column1Mod, $BeginningRow+($x*3), 65, 15)
        $FateButtonAboveAvg= GUICtrlCreateButton("Above Av.", $LSide+$Column1Mod, $BeginningRow+($x*4), 65, 15)
        $FateButtonHigh= GUICtrlCreateButton("High", $LSide+$Column1Mod, $BeginningRow+($x*5), 65, 15)
        $FateButtonExcep= GUICtrlCreateButton("Exceptional", $LSide+$Column1Mod, $BeginningRow+($x*6), 65, 15)
        
        $x=30
        $BeginningRow2=50
        $QuickButtonD2= GUICtrlCreatebutton("d2", $LSide+$Column2Mod, $BeginningRow2, 35, 20)
        $QuickButtonD3= GUICtrlCreatebutton("d3", $LSide+$Column2Mod, $BeginningRow2+($x), 35, 20)
        $QuickButtonD4= GUICtrlCreatebutton("d4", $LSide+$Column2Mod, $BeginningRow2+($x*2), 35, 20)
        $QuickButtonD6= GUICtrlCreatebutton("d6", $LSide+$Column2Mod, $BeginningRow2+($x*3), 35, 20)
        $QuickButtonD8= GUICtrlCreatebutton("d8", $LSide+$Column2Mod, $BeginningRow2+($x*4), 35, 20)
       
        $QuickButtonD10= GUICtrlCreatebutton("d10", $LSide+$Column3Mod, $BeginningRow2, 35, 20)
        $QuickButtonD12= GUICtrlCreatebutton("d12", $LSide+$Column3Mod, $BeginningRow2+($x), 35, 20)
        $QuickButtonD20= GUICtrlCreatebutton("d20", $LSide+$Column3Mod, $BeginningRow2+($x*2), 35, 20)
        $QuickButtonD100= GUICtrlCreatebutton("d100", $LSide+$Column3Mod, $BeginningRow2+($x*3), 35, 20)
        $QuickButtonDX= GUICtrlCreatebutton("dX", $LSide+$Column3Mod, $BeginningRow2+($x*4), 35, 20)
       
        GUICtrlCreateGroup("An Always Full Deck",296,207,119,34)
        $DrawRandomCard= GUICtrlCreatebutton("Draw a Random Card", 299, 221, 113, 17)
       
        GUICtrlCreateGroup("Deck 1",296,244,119,53)
        $DrawFromDeck1= GUICtrlCreatebutton("Draw a Card", 299, 257, 113, 17)
        $ReshuffleDeck1= GUICtrlCreateButton("Reshuffle Deck", 299, 276, 113, 17)
       
        GUICtrlCreateGroup("Deck 2",296,298,119,72)
        $IssueCards= GUICtrlCreateButton("Issue X Cards", 299, 312, 113, 17)
        $DrawFromDeck2= GUICtrlCreatebutton("Draw a Single Card", 299, 331, 113, 17)
        $ReshuffleDeck2= GUICtrlCreateButton("Reshuffle Deck", 299, 350, 113, 17)
       
        $ShowADeck= GUICtrlCreatebutton("Show Deck", 296, 372, 73, 29)
        $DisplayHelp= GUICtrlCreatebutton("Help", 371, 372, 45, 29)
        
        $OutputWindow = GUICtrlCreateEdit("", 166, 35, 249, 165)
       
        GUICtrlCreateLabel("Select a" & @crlf & "Number",11,238)
        $NumberSelected = GUICtrlCreateList("1", 5,267,55,146,$WS_VSCROLL)
            For $i= 2 to 100
                GUICtrlSetData($NumberSelected,$i)
            Next
        $ClearButton= GUICtrlCreateButton("Clear Results",341,5,75,20)
       
        $RollUpWindow= GUICtrlCreateButton("Roll Up Window",5,5,105,20)
        $RollDownWindow= GUICtrlCreateButton("Roll Down Window",5,5,105,20)
;~ Hide and disable the Roll Down button
        GUICtrlSetState($RollDownWindow,$GUI_DISABLE + $GUI_HIDE)
       
        $KeepOnTop= GUICtrlCreateCheckbox("",125,7,15,15)
        GUICtrlCreateLabel("Keep Window on Top",141,8)
       
        $SortResults= GUICtrlCreateCheckbox("",5,209,15,15)
        GUICtrlCreateLabel("Sort" & @crlf & "Results",23,204)
        
        $GameAreaDummyStart= GUICtrlCreateDummy()
            $SavageWorldsDummyStart= GUICtrlCreateDummy()
                $SavageWorlds=GUICtrlCreateGroup ("Savage Worlds",67,205,225,197)
                    $MainButtonW=30
                    $BigButtonW=55
                    $SmallButtonW=17
                    $ButtonH=25
                    $1stCLSide=117
                    $2ndCLSide=218
                    $MidCLSide=155
                    $TopRow=243
                    $1stRTop=244
                    $2ndRTop=$TopRow+40
                    $3rdRTop=$TopRow+80
                    $4thRTop=$TopRow+120
                    ;First Row
                    $SWButtonUnsk= GUICtrlCreatebutton("Unskilled", $MidCLSide, $1stRTop, $BigButtonW, $ButtonH)
                    $SWButtonUnskx= GUICtrlCreatebutton("x", $MidCLSide-$SmallButtonW, $1stRTop, $SmallButtonW, $ButtonH)
                    $SWButtonUnskw= GUICtrlCreatebutton("w", $MidCLSide+$BigButtonW, $1stRTop, $SmallButtonW, $ButtonH)
                    ;Second Row
                    $SWButtonD4= GUICtrlCreatebutton("d4", $1stCLSide, $2ndRTop, $MainButtonW, $ButtonH)
                    $SWButtonD4x= GUICtrlCreatebutton("x", $1stCLSide-$SmallButtonW, $2ndRTop, $SmallButtonW, $ButtonH)
                    $SWButtonD4w= GUICtrlCreatebutton("w", $1stCLSide+$MainButtonW, $2ndRTop, $SmallButtonW, $ButtonH)
                    
                    $SWButtonD6= GUICtrlCreatebutton("d6", $2ndCLSide, $2ndRTop, $MainButtonW, $ButtonH)
                    $SWButtonD6x= GUICtrlCreatebutton("x", $2ndCLSide-$SmallButtonW, $2ndRTop, $SmallButtonW, $ButtonH)
                    $SWButtonD6w= GUICtrlCreatebutton("w", $2ndCLSide+$MainButtonW, $2ndRTop, $SmallButtonW, $ButtonH)
                    ;Third Row
                    $SWButtonD8= GUICtrlCreatebutton("d8", $1stCLSide, $3rdRTop, $MainButtonW, $ButtonH)
                    $SWButtonD8x= GUICtrlCreatebutton("x", $1stCLSide-$SmallButtonW, $3rdRTop, $SmallButtonW, $ButtonH)
                    $SWButtonD8w= GUICtrlCreatebutton("w", $1stCLSide+$MainButtonW, $3rdRTop, $SmallButtonW, $ButtonH)
                    
                    $SWButtonD10= GUICtrlCreatebutton("d10", $2ndCLSide, $3rdRTop, $MainButtonW, $ButtonH)
                    $SWButtonD10x= GUICtrlCreatebutton("x", $2ndCLSide-$SmallButtonW, $3rdRTop, $SmallButtonW, $ButtonH)
                    $SWButtonD10w= GUICtrlCreatebutton("w", $2ndCLSide+$MainButtonW, $3rdRTop, $SmallButtonW, $ButtonH)
                    ;Forth Row
                    $SWButtonD12= GUICtrlCreatebutton("d12", $1stCLSide, $4thRTop, $MainButtonW, $ButtonH)
                    $SWButtonD12x= GUICtrlCreatebutton("x", $1stCLSide-$SmallButtonW, $4thRTop, $SmallButtonW, $ButtonH)
                    $SWButtonD12w= GUICtrlCreatebutton("w", $1stCLSide+$MainButtonW, $4thRTop, $SmallButtonW, $ButtonH)
                     
                    $SWButtonD20= GUICtrlCreateButton("d20", $2ndCLSide, $4thRTop, $MainButtonW, $ButtonH)
                    $SWButtonD20x= GUICtrlCreateButton("x", $2ndCLSide-$SmallButtonW, $4thRTop, $SmallButtonW, $ButtonH)
                    $SWButtonD20w= GUICtrlCreateButton("w", $2ndCLSide+$MainButtonW, $4thRTop, $SmallButtonW, $ButtonH)
            $SavageWorldsDummyEnd= GUICtrlCreateDummy()
            
            $RavagedRulesDummyStart= GUICtrlCreateDummy()
                $RavagedRules=GUICtrlCreateGroup ("Savage Worlds- Ravaged Rules",67,205,225,197)
                    $MainButtonW=30
                    $SmallButtonW=17
                    $ButtonH=20
                    $1stCLSide=87
                    $2ndCLSide=163
                    $3rdCLSide=240
                    $LSideMod=37
                    $TopRow=230
                    $1stRTop=$TopRow
                    $2ndRTop=$TopRow+24
                    $3rdRTop=$TopRow+49
                    $4thRTop=$TopRow+73
                    $5thRTop=$TopRow+98
                    $6thRTop=$TopRow+122
                    $7thRTop=$TopRow+147
                    ;First Row
                    $SWModButtonD1= GUICtrlCreatebutton("d1", $1stCLSide, $1stRTop, $MainButtonW, $ButtonH)
                    $SWModButtonD1x= GUICtrlCreatebutton("x", $1stCLSide-$SmallButtonW, $1stRTop, $SmallButtonW, $ButtonH)
                    $SWModButtonD1W= GUICtrlCreatebutton("w", $1stCLSide+$MainButtonW, $1stRTop, $SmallButtonW, $ButtonH)
                    
                    $SWModButtonD2= GUICtrlCreatebutton("d2", $2ndCLSide, $1stRTop, $MainButtonW, $ButtonH)
                    $SWModButtonD2x= GUICtrlCreatebutton("x", $2ndCLSide-$SmallButtonW, $1stRTop, $SmallButtonW, $ButtonH)
                    $SWModButtonD2W= GUICtrlCreatebutton("w", $2ndCLSide+$MainButtonW, $1stRTop, $SmallButtonW, $ButtonH)
                    
                    $SWModButtonD3= GUICtrlCreatebutton("d3", $3rdCLSide, $1stRTop, $MainButtonW, $ButtonH)
                    $SWModButtonD3x= GUICtrlCreatebutton("x", $3rdCLSide-$SmallButtonW, $1stRTop, $SmallButtonW, $ButtonH)
                    $SWModButtonD3W= GUICtrlCreatebutton("w", $3rdCLSide+$MainButtonW, $1stRTop, $SmallButtonW, $ButtonH)
                    ;Second Row
                    $SWModButtonD4= GUICtrlCreatebutton("d4", $1stCLSide, $2ndRTop, $MainButtonW, $ButtonH)
                    $SWModButtonD4x= GUICtrlCreatebutton("x", $1stCLSide-$SmallButtonW, $2ndRTop, $SmallButtonW, $ButtonH)
                    $SWModButtonD4W= GUICtrlCreatebutton("w", $1stCLSide+$MainButtonW, $2ndRTop, $SmallButtonW, $ButtonH)
                    
                    $SWModButtonD5= GUICtrlCreatebutton("d5", $2ndCLSide, $2ndRTop, $MainButtonW, $ButtonH)
                    $SWModButtonD5x= GUICtrlCreatebutton("x", $2ndCLSide-$SmallButtonW, $2ndRTop, $SmallButtonW, $ButtonH)
                    $SWModButtonD5W= GUICtrlCreatebutton("w", $2ndCLSide+$MainButtonW, $2ndRTop, $SmallButtonW, $ButtonH)
                    
                    $SWModButtonD6= GUICtrlCreatebutton("d6", $3rdCLSide, $2ndRTop, $MainButtonW, $ButtonH)
                    $SWModButtonD6x= GUICtrlCreatebutton("x", $3rdCLSide-$SmallButtonW, $2ndRTop, $SmallButtonW, $ButtonH)
                    $SWModButtonD6W= GUICtrlCreatebutton("w", $3rdCLSide+$MainButtonW, $2ndRTop, $SmallButtonW, $ButtonH)
                    ;Third Row
                    $SWModButtonD7= GUICtrlCreatebutton("d7", $1stCLSide, $3rdRTop, $MainButtonW, $ButtonH)
                    $SWModButtonD7x= GUICtrlCreatebutton("x", $1stCLSide-$SmallButtonW, $3rdRTop, $SmallButtonW, $ButtonH)
                    $SWModButtonD7W= GUICtrlCreatebutton("w", $1stCLSide+$MainButtonW, $3rdRTop, $SmallButtonW, $ButtonH)
                    
                    $SWModButtonD8= GUICtrlCreatebutton("d8", $2ndCLSide, $3rdRTop, $MainButtonW, $ButtonH)
                    $SWModButtonD8x= GUICtrlCreatebutton("x", $2ndCLSide-$SmallButtonW, $3rdRTop, $SmallButtonW, $ButtonH)
                    $SWModButtonD8W= GUICtrlCreatebutton("w", $2ndCLSide+$MainButtonW, $3rdRTop, $SmallButtonW, $ButtonH)
                    
                    $SWModButtonD9= GUICtrlCreatebutton("d9", $3rdCLSide, $3rdRTop, $MainButtonW, $ButtonH)
                    $SWModButtonD9x= GUICtrlCreatebutton("x", $3rdCLSide-$SmallButtonW, $3rdRTop, $SmallButtonW, $ButtonH)
                    $SWModButtonD9W= GUICtrlCreatebutton("w", $3rdCLSide+$MainButtonW, $3rdRTop, $SmallButtonW, $ButtonH)
                    ;Fourth Row
                    $SWModButtonD10= GUICtrlCreatebutton("d10", $1stCLSide, $4thRTop, $MainButtonW, $ButtonH)
                    $SWModButtonD10x= GUICtrlCreatebutton("x", $1stCLSide-$SmallButtonW, $4thRTop, $SmallButtonW, $ButtonH)
                    $SWModButtonD10W= GUICtrlCreatebutton("w", $1stCLSide+$MainButtonW, $4thRTop, $SmallButtonW, $ButtonH)
                    
                    $SWModButtonD11= GUICtrlCreatebutton("d11", $2ndCLSide, $4thRTop, $MainButtonW, $ButtonH)
                    $SWModButtonD11x= GUICtrlCreatebutton("x", $2ndCLSide-$SmallButtonW, $4thRTop, $SmallButtonW, $ButtonH)
                    $SWModButtonD11W= GUICtrlCreatebutton("w", $2ndCLSide+$MainButtonW, $4thRTop, $SmallButtonW, $ButtonH)
                    
                    $SWModButtonD12= GUICtrlCreatebutton("d12", $3rdCLSide, $4thRTop, $MainButtonW, $ButtonH)
                    $SWModButtonD12x= GUICtrlCreatebutton("x", $3rdCLSide-$SmallButtonW, $4thRTop, $SmallButtonW, $ButtonH)
                    $SWModButtonD12W= GUICtrlCreatebutton("w", $3rdCLSide+$MainButtonW, $4thRTop, $SmallButtonW, $ButtonH)
                    ;Fifth Row
                    $SWModButtonD13= GUICtrlCreatebutton("d13", $1stCLSide, $5thRTop, $MainButtonW, $ButtonH)
                    $SWModButtonD13x= GUICtrlCreatebutton("x", $1stCLSide-$SmallButtonW, $5thRTop, $SmallButtonW, $ButtonH)
                    $SWModButtonD13W= GUICtrlCreatebutton("w", $1stCLSide+$MainButtonW, $5thRTop, $SmallButtonW, $ButtonH)
                    
                    $SWModButtonD14= GUICtrlCreatebutton("d14", $2ndCLSide, $5thRTop, $MainButtonW, $ButtonH)
                    $SWModButtonD14x= GUICtrlCreatebutton("x", $2ndCLSide-$SmallButtonW, $5thRTop, $SmallButtonW, $ButtonH)
                    $SWModButtonD14W= GUICtrlCreatebutton("w", $2ndCLSide+$MainButtonW, $5thRTop, $SmallButtonW, $ButtonH)
                    
                    $SWModButtonD15= GUICtrlCreatebutton("d15", $3rdCLSide, $5thRTop, $MainButtonW, $ButtonH)
                    $SWModButtonD15x= GUICtrlCreatebutton("x", $3rdCLSide-$SmallButtonW, $5thRTop, $SmallButtonW, $ButtonH)
                    $SWModButtonD15W= GUICtrlCreatebutton("w", $3rdCLSide+$MainButtonW, $5thRTop, $SmallButtonW, $ButtonH)
                    ;Sixth Row
                    $SWModButtonD16= GUICtrlCreatebutton("d16", $1stCLSide, $6thRTop, $MainButtonW, $ButtonH)
                    $SWModButtonD16x= GUICtrlCreatebutton("x", $1stCLSide-$SmallButtonW, $6thRTop, $SmallButtonW, $ButtonH)
                    $SWModButtonD16W= GUICtrlCreatebutton("w", $1stCLSide+$MainButtonW, $6thRTop, $SmallButtonW, $ButtonH)
                    
                    $SWModButtonD17= GUICtrlCreatebutton("d17", $2ndCLSide, $6thRTop, $MainButtonW, $ButtonH)
                    $SWModButtonD17x= GUICtrlCreatebutton("x", $2ndCLSide-$SmallButtonW, $6thRTop, $SmallButtonW, $ButtonH)
                    $SWModButtonD17W= GUICtrlCreatebutton("w", $2ndCLSide+$MainButtonW, $6thRTop, $SmallButtonW, $ButtonH)
                    
                    $SWModButtonD18= GUICtrlCreatebutton("d18", $3rdCLSide, $6thRTop, $MainButtonW, $ButtonH)
                    $SWModButtonD18x= GUICtrlCreatebutton("x", $3rdCLSide-$SmallButtonW, $6thRTop, $SmallButtonW, $ButtonH)
                    $SWModButtonD18W= GUICtrlCreatebutton("w", $3rdCLSide+$MainButtonW, $6thRTop, $SmallButtonW, $ButtonH)
                    ;Seventh Row
                    $SWModButtonD19= GUICtrlCreatebutton("d19", $1stCLSide+$LSideMod, $7thRTop, $MainButtonW, $ButtonH)
                    $SWModButtonD19x= GUICtrlCreatebutton("x", $1stCLSide+$LSideMod-$SmallButtonW, $7thRTop, $SmallButtonW, $ButtonH)
                    $SWModButtonD19W= GUICtrlCreatebutton("w", $1stCLSide+$LSideMod+$MainButtonW, $7thRTop, $SmallButtonW, $ButtonH)
                    
                    $SWModButtonD20= GUICtrlCreatebutton("d20", $2ndCLSide+$LSideMod, $7thRTop, $MainButtonW, $ButtonH)
                    $SWModButtonD20x= GUICtrlCreatebutton("x", $2ndCLSide+$LSideMod-$SmallButtonW, $7thRTop, $SmallButtonW, $ButtonH)
                    $SWModButtonD20W= GUICtrlCreatebutton("w", $2ndCLSide+$LSideMod+$MainButtonW, $7thRTop, $SmallButtonW, $ButtonH)
            $RavagedRulesDummyEnd= GUICtrlCreateDummy()
            
            $FateDummyStart= GUICtrlCreateDummy()
                $Fate= GUICtrlCreateGroup ("Fate",67,205,225,197)
                    GUICtrlCreateLabel("+8 Legendary" & @CRLF & "+7 Epic" & @CRLF & "+6 Fantastic" & @CRLF & "+5 Superb" & @CRLF & "+4 Great" & @CRLF & "+3 Good" & @CRLF & "+2 Good" & @CRLF & "+1 Average" & @CRLF & " 0 Mediocre" & @CRLF & "-1 Poor" & @CRLF & "-2 Terrible",83,241)
                    $LeftSide= 242
                    $TopOfButton= 242
                    $FatePts= GUICtrlCreateInput(1,$LeftSide,$TopOfButton+22,30,20)
                    GUICtrlSetState($FatePts,$GUI_DISABLE) ;Disable the control to prevent typed input
                    $MoreFatePts= GUICtrlCreateButton("More",$LeftSide,$TopOfButton,30,20)
                    $LessFatePts= GUICtrlCreateButton("Less",$LeftSide,$TopOfButton+43,30,20)
                    GUICtrlCreateLabel("Fate Points", $LeftSide-60,$TopOfButton+24)
                    
                    $LeftSide2= 183
                    $TopOfButton2= 343
                    $FtButton4dF= GUICtrlCreateButton("4dF",$LeftSide2,$TopOfButton2,40,40)
                    $FtButtonXdF= GUICtrlCreateButton("XdF",$LeftSide2+48,$TopOfButton2,40,40)
            $FateDummyEnd= GUICtrlCreateDummy()
            
            $GenericDummyStart= GUICtrlCreateDummy()
                $Generic= GUICtrlCreateGroup ("Fate",67,205,225,197)
                    $ButtonW=50
                    $HalfButtonW=25
                    $ButtonH=25
                    $1stCLSide=83
                    $2ndCLSide=153
                    $3rdCLSide=223
                    $TopRow=241
                    $1stRTop=$TopRow
                    $2ndRTop=$TopRow+40
                    $3rdRTop=$TopRow+80
                    $4thRTop=$TopRow+120
                    $SpecialButtonXD2= GUICtrlCreatebutton("x d2", $1stCLSide, $1stRTop, $ButtonW, $ButtonH)
                    $SpecialButtonXD3= GUICtrlCreatebutton("x d3", $2ndCLSide, $1stRTop, $ButtonW, $ButtonH)
                    $SpecialButtonXD4= GUICtrlCreatebutton("x d4", $3rdCLSide, $1stRTop, $ButtonW, $ButtonH)
                    $SpecialButtonXD6= GUICtrlCreatebutton("x d6", $1stCLSide, $2ndRTop, $ButtonW, $ButtonH)
                    $SpecialButtonXD8= GUICtrlCreatebutton("x d8", $2ndCLSide, $2ndRTop, $ButtonW, $ButtonH)
                    $SpecialButtonXD10= GUICtrlCreatebutton("x d10", $3rdCLSide, $2ndRTop, $ButtonW, $ButtonH)
                    $SpecialButtonXD12= GUICtrlCreatebutton("x d12", $1stCLSide, $3rdRTop, $ButtonW, $ButtonH)
                    $SpecialButtonXD20= GUICtrlCreatebutton("x d20", $2ndCLSide, $3rdRTop, $ButtonW, $ButtonH)
                    $SpecialButtonXD100= GUICtrlCreatebutton("x d100", $3rdCLSide, $3rdRTop, $ButtonW, $ButtonH)
                    $SpecialButtonXDY= GUICtrlCreatebutton("x d", $1stCLSide, $4thRTop, $HalfButtonW, $ButtonH)
                    $SpecialButtonDiePip= GUICtrlCreatebutton("Y", $1stCLSide+$HalfButtonW, $4thRTop, $ButtonW-$HalfButtonW, $ButtonH)
                    $DnDAttrib= GUICtrlCreatebutton("DnD Attribute Roll", $2ndCLSide, $4thRTop, $2ndCLSide-$1stCLSide+$ButtonW, $ButtonH)
            $GenericDummyEnd= GUICtrlCreateDummy()
        $GameAreaDummyEnd= GUICtrlCreateDummy()
    $ControlAreaDummyEnd = GUICtrlCreateDummy() ;<-- Added this here for end of controls
    
    For $q = $GameAreaDummyStart To $GameAreaDummyEnd
        GUICtrlSetState($q, $GUI_DISABLE + $GUI_HIDE)
    Next
    For $q = $FateDummyStart To $FateDummyEnd
        GUICtrlSetState($q, $GUI_ENABLE + $GUI_SHOW)
    Next
    

GuiSetState ()

For $q = $ControlAreaDummyStart To $ControlAreaDummyEnd ;<-- Added this loop to set DockAll on all controls between start and end
    GUICtrlSetResizing($q, $GUI_DOCKALL)
Next ;<-- Added this ... that's it no more added

; Run the GUI until the dialog is closed
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GameSelector
            Select
                Case GUICtrlRead($GameSelector) = "Savage Worlds"
                    SwitchGames($SavageWorldsDummyStart,$SavageWorldsDummyEnd)
                Case GUICtrlRead($GameSelector) = "Savage Worlds- Ravaged Rules"
                    SwitchGames($RavagedRulesDummyStart,$RavagedRulesDummyEnd)
                Case GUICtrlRead($GameSelector) = "Fate"
                    SwitchGames($FateDummyStart,$FateDummyEnd)
                Case GUICtrlRead($GameSelector) = "Generic"
                    SwitchGames($GenericDummyStart,$GenericDummyEnd)
            EndSelect               
        Case $msg = $FtButton4dF
            FateDie()
        Case $msg = $FtButtonXdF
            FateMultiDie(GUICtrlRead($NumberSelected))
        Case $msg = $MoreFatePts
            AdjustPoints("U")
        Case $msg = $LessFatePts
            AdjustPoints("D")
        Case $msg = $KeepOnTop
            If GUICtrlRead($KeepOnTop) = 1 Then
                WinSetOnTop($GUIHandle,"",1)
            Else
                WinSetOnTop($GUIHandle,"",0)
            EndIf
        Case $msg = $DisplayHelp
            GUICtrlSetData($OutputWindow,"Help file not written yet, sorry." & @CRLF & GuiCtrlRead($OutputWindow))
        Case $msg = $ClearButton
            GUICtrlSetData($OutputWindow,"")
        Case $msg = $DnDAttrib
            DnDAttributes()
        Case $msg = $DrawRandomCard
            DrawRandomCard()
        Case $msg = $DrawFromDeck1
            DrawFromDeck1()
        Case $msg = $ReshuffleDeck1
            InitializeCardDeck1()
            GUICtrlSetData($OutputWindow,"Shuffled deck 1" & @CRLF & GuiCtrlRead($OutputWindow))
        Case $msg = $IssueCards
            IssueCards(GUICtrlRead($NumberSelected)) ;Read the number selection to get the number of players to issue cards to.
        Case $msg = $DrawFromDeck2
            DrawFromDeck2()
        Case $msg = $ReshuffleDeck2
            InitializeCardDeck2()
            GUICtrlSetData($OutputWindow,"Shuffled deck 2" & @CRLF & GuiCtrlRead($OutputWindow))
        Case $msg = $ShowADeck
            _ArrayDisplay($FullDeck,"Card Deck")
        Case $msg = $QuickButtonD2
            easydie(2)
        Case $msg = $QuickButtonD3
            easydie(3)
        Case $msg = $QuickButtonD4
            easydie(4)
        Case $msg = $QuickButtonD6
            easydie(6)
        Case $msg = $QuickButtonD8
            easydie(8)
        Case $msg = $QuickButtonD10
            easydie(10)
        Case $msg = $QuickButtonD12
            easydie(12)
        Case $msg = $QuickButtonD20
            easydie(20)
        Case $msg = $QuickButtonD100
            easydie(100)
        Case $msg = $QuickButtonDX
            easydie(GUICtrlRead($NumberSelected))
        Case $msg = $SpecialButtonXD2
            multidie(2)
        Case $msg = $SpecialButtonXD3
            multidie(3)
        Case $msg = $SpecialButtonXD4
            multidie(4)
        Case $msg = $SpecialButtonXD6
            multidie(6)
        Case $msg = $SpecialButtonXD8
            multidie(8)
        Case $msg = $SpecialButtonXD10
            multidie(10)
        Case $msg = $SpecialButtonXD12
            multidie(12)
        Case $msg = $SpecialButtonXD20
            multidie(20)
        Case $msg = $SpecialButtonXD100
            multidie(100)
        Case $msg = $SpecialButtonXDY
            if $x = "Y" then 
                GUICtrlSetData($OutputWindow, "You have to choose a die-type and press the right button" & @CRLF & GuiCtrlRead($OutputWindow))
            else
               multidie(GUICtrlRead($SpecialButtonDiePip))
            endif
        Case $msg = $SpecialButtonDiePip
            GUICtrlSetData ($SpecialButtonDiePip, GUICtrlRead($NumberSelected))

        Case $msg = $RollDownWindow
            GUICtrlSetState($RollUpWindow,$GUI_ENABLE + $GUI_SHOW)
            GUICtrlSetState($RollDownWindow,$GUI_DISABLE + $GUI_HIDE)
            $WinSizeArray= WinGetPos($GUIHandle)
            WinMove($GUIHandle,"",$WinSizeArray[0],$WinSizeArray[1],$WinSizeArray[2]+170,$WinSizeArray[3]+375)
        Case $msg = $RollUpWindow
            GUICtrlSetState($RollDownWindow,$GUI_ENABLE + $GUI_SHOW)
            GUICtrlSetState($RollUpWindow,$GUI_DISABLE + $GUI_HIDE)
            $WinSizeArray= WinGetPos($GUIHandle)
            WinMove($GUIHandle,"",$WinSizeArray[0],$WinSizeArray[1],$WinSizeArray[2]-170,$WinSizeArray[3]-375)
            
        Case $msg = $SWButtonUnsk
            savagedie("unskilled")
        Case $msg = $SWButtonUnskx ;x dices
            savagemultidie("unskilled")
        Case $msg = $SWButtonUnskw ;Wild Die
            savagewilddie("unskilled")
        Case $msg = $SWButtonD4
            savagedie(4)
        Case $msg = $SWButtonD4x ;x dices
            savagemultidie(4)
        Case $msg = $SWButtonD4w ;Wild Die
            savagewilddie(4)
        Case $msg = $SWButtonD6
            savagedie(6)
        Case $msg = $SWButtonD6x ;x dices
            savagemultidie(6)
        Case $msg = $SWButtonD6w ;Wild Die
            savagewilddie(6)
        Case $msg = $SWButtonD8
            savagedie(8)
        Case $msg = $SWButtonD8x ;x dices
            savagemultidie(8)
        Case $msg = $SWButtonD8w ;Wild Die
            savagewilddie(8)
        Case $msg = $SWButtonD10
            savagedie(10)
        Case $msg = $SWButtonD10x ;x dices
            savagemultidie(10)
        Case $msg = $SWButtonD10w ;Wild Die
            savagewilddie(10)
        Case $msg = $SWButtonD12
            savagedie(12)
        Case $msg = $SWButtonD12x ;x dices
            savagemultidie(12)
        Case $msg = $SWButtonD12w ;Wild Die
            savagewilddie(12)
        Case $msg = $SWButtonD20
            savagedie(20)
        Case $msg = $SWButtonD20x ;x dices
            savagemultidie(20)
        Case $msg = $SWButtonD20w ;Wild Die
            savagewilddie(20)
         
        Case $msg = $SWModButtonD1
            savagedie(1)
        Case $msg = $SWModButtonD1x ;x dices
            savagemultidie(1)
        Case $msg = $SWModButtonD1W ;Wild Die
            savagewilddie(1)
        Case $msg = $SWModButtonD2
            savagedie(2)
        Case $msg = $SWModButtonD2x ;x dices
            savagemultidie(2)
        Case $msg = $SWModButtonD2W ;Wild Die
            savagewilddie(2)
        Case $msg = $SWModButtonD3
            savagedie(3)
        Case $msg = $SWModButtonD3x ;x dices
            savagemultidie(3)
        Case $msg = $SWModButtonD3W ;Wild Die
            savagewilddie(3)
        Case $msg = $SWModButtonD4
            savagedie(4)
        Case $msg = $SWModButtonD4x ;x dices
            savagemultidie(4)
        Case $msg = $SWModButtonD4W ;Wild Die
            savagewilddie(4)
        Case $msg = $SWModButtonD5
            savagedie(5)
        Case $msg = $SWModButtonD5x ;x dices
            savagemultidie(5)
        Case $msg = $SWModButtonD5W ;Wild Die
            savagewilddie(5)
        Case $msg = $SWModButtonD6
            savagedie(6)
        Case $msg = $SWModButtonD6x ;x dices
            savagemultidie(6)
        Case $msg = $SWModButtonD6W ;Wild Die
            savagewilddie(6)
        Case $msg = $SWModButtonD7
            savagedie(7)
        Case $msg = $SWModButtonD7x ;x dices
            savagemultidie(7)
        Case $msg = $SWModButtonD7W ;Wild Die
            savagewilddie(7)
        Case $msg = $SWModButtonD8
            savagedie(8)
        Case $msg = $SWModButtonD8x ;x dices
            savagemultidie(8)
        Case $msg = $SWModButtonD8W ;Wild Die
            savagewilddie(8)
        Case $msg = $SWModButtonD9
            savagedie(9)
        Case $msg = $SWModButtonD9x ;x dices
            savagemultidie(9)
        Case $msg = $SWModButtonD9W ;Wild Die
            savagewilddie(9)
        Case $msg = $SWModButtonD10
            savagedie(10)
        Case $msg = $SWModButtonD10x ;x dices
            savagemultidie(10)
        Case $msg = $SWModButtonD10W ;Wild Die
            savagewilddie(10)
        Case $msg = $SWModButtonD11
            savagedie(11)
        Case $msg = $SWModButtonD11x ;x dices
            savagemultidie(11)
        Case $msg = $SWModButtonD11W ;Wild Die
            savagewilddie(11)
        Case $msg = $SWModButtonD12
            savagedie(12)
        Case $msg = $SWModButtonD12x ;x dices
            savagemultidie(12)
        Case $msg = $SWModButtonD12W ;Wild Die
            savagewilddie(12)
        Case $msg = $SWModButtonD13
            savagedie(13)
        Case $msg = $SWModButtonD13x ;x dices
            savagemultidie(13)
        Case $msg = $SWModButtonD13W ;Wild Die
            savagewilddie(13)
        Case $msg = $SWModButtonD14
            savagedie(14)
        Case $msg = $SWModButtonD14x ;x dices
            savagemultidie(14)
        Case $msg = $SWModButtonD14W ;Wild Die
            savagewilddie(14)
        Case $msg = $SWModButtonD15
            savagedie(15)
        Case $msg = $SWModButtonD15x ;x dices
            savagemultidie(15)
        Case $msg = $SWModButtonD15W ;Wild Die
            savagewilddie(15)
        Case $msg = $SWModButtonD16
            savagedie(16)
        Case $msg = $SWModButtonD16x ;x dices
            savagemultidie(16)
        Case $msg = $SWModButtonD16W ;Wild Die
            savagewilddie(16)
        Case $msg = $SWModButtonD17
            savagedie(17)
        Case $msg = $SWModButtonD17x ;x dices
            savagemultidie(17)
        Case $msg = $SWModButtonD17W ;Wild Die
            savagewilddie(17)
        Case $msg = $SWModButtonD18
            savagedie(18)
        Case $msg = $SWModButtonD18x ;x dices
            savagemultidie(18)
        Case $msg = $SWModButtonD18W ;Wild Die
            savagewilddie(18)
        Case $msg = $SWModButtonD19
            savagedie(19)
        Case $msg = $SWModButtonD19x ;x dices
            savagemultidie(19)
        Case $msg = $SWModButtonD19W ;Wild Die
            savagewilddie(19)
        Case $msg = $SWModButtonD20
            savagedie(20)
        Case $msg = $SWModButtonD20x ;x dices
            savagemultidie(20)
        Case $msg = $SWModButtonD20W ;Wild Die
            savagewilddie(20)
            
        Case $msg = $FateButtonWeak
            fatetable(3,15,84)
        Case $msg = $FateButtonLow
            fatetable(5,25,86)
        Case $msg = $FateButtonBelowAvg
            fatetable(7,35,88)
        Case $msg = $FateButtonAvg
            fatetable(10,50,91)
        Case $msg = $FateButtonAboveAvg
            fatetable(13,65,94)
        Case $msg = $FateButtonHigh
            fatetable(15,75,96)
        Case $msg = $FateButtonExcep
            fatetable(16,85,97)
    EndSelect
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
Wend
   
;~ ---------------------------------------------------------------------------------------------------------------
;~ --------------------------------------- End of Main Script ----------------------------------------------------
;~ ---------------------------------------------------------------------------------------------------------------

Func SwitchGames($StartID,$EndID)
    Select
        Case GUICtrlGetState($SavageWorlds) < $GUI_DISABLE
            $DisableAreaStart= $SavageWorldsDummyStart
            $DisableAreaEnd= $SavageWorldsDummyEnd
        Case GUICtrlGetState($RavagedRules) < $GUI_DISABLE
            $DisableAreaStart= $RavagedRulesDummyStart
            $DisableAreaEnd= $RavagedRulesDummyEnd
        Case GUICtrlGetState($Fate) < $GUI_DISABLE
            $DisableAreaStart= $FateDummyStart
            $DisableAreaEnd= $FateDummyEnd
        Case GUICtrlGetState($Generic) < $GUI_DISABLE
            $DisableAreaStart= $GenericDummyStart
            $DisableAreaEnd= $GenericDummyEnd
    EndSelect
    For $q = $DisableAreaStart To $DisableAreaEnd
        GUICtrlSetState($q, $GUI_DISABLE + $GUI_HIDE)
    Next
    For $q = $StartID To $EndID
        GUICtrlSetState($q, $GUI_ENABLE + $GUI_SHOW)
    Next    
EndFunc

Func FateDie()
    dim $avResults[4]   ;Stores the "+", "-", and "0" die results
    dim $total          ;Stores the final total
    Dim $Roll           ;Stores the individual die roll (either -1, 0, or 1)
    Dim $Mod            ;Stores either "+", "-", or "0" depending on the value of the total
    $total = 0
    For $i = 0 To 3
        $Roll= Random(-1,1,1)
        $total= $total + $Roll
        If $Roll < 0 Then
            $avResults[$i] = "-"
        ElseIf $Roll > 0 Then
            $avResults[$i] = "+"
        Else
            $avResults[$i] = "0"
        EndIf
    Next
    If $total < 0 Then
        $Mod = "-"
    ElseIf $total > 0 Then
        $Mod = "+"
    Else
        $Mod = ""
    EndIf
    If GUICtrlRead($SortResults)=1 then _ArraySort( $avResults,1) ;Sorts array, 1= descending
    GUICtrlSetData($OutputWindow, $avResults[0] & ", " & $avResults[1] & ", " & $avResults[2] & ", " & $avResults[3] & " (Result: " & Abs($total) & $Mod & " | 4dF)" & @CRLF & GuiCtrlRead($OutputWindow))
EndFunc

Func FateMultiDie($NumberOfDice)
    dim $avResults[$NumberOfDice]   ;Stores the "+", "-", and "0" die results
    dim $total                      ;Stores the final total
    Dim $Roll                       ;Stores the individual die roll (either -1, 0, or 1)
    Dim $Mod                        ;Stores either "+", "-", or "0" depending on the value of the total
    Dim $ResultString               ;Stores the results
    $total = 0
    For $i = 0 To $NumberOfDice - 1
        $Roll= Random(-1,1,1)
        $total= $total + $Roll
        If $Roll < 0 Then
            $avResults[$i] = "-"
        ElseIf $Roll > 0 Then
            $avResults[$i] = "+"
        Else
            $avResults[$i] = "0"
        EndIf
    Next
    If $total < 0 Then
        $Mod = "-"
    ElseIf $total > 0 Then
        $Mod = "+"
    Else
        $Mod = ""
    EndIf
    If GUICtrlRead($SortResults)=1 then _ArraySort( $avResults,1) ;Sorts array, 1= descending
    $ResultString = $avResults[0]   ;Create the result string
    For $i = 1 To $NumberOfDice - 1
        $ResultString = $ResultString & ", " & $avResults[$i]
    Next
    GUICtrlSetData($OutputWindow, $ResultString & " (Result: " & Abs($total) & $Mod & " | " & $NumberOfDice & "dF)" & @CRLF & GuiCtrlRead($OutputWindow))
EndFunc

Func AdjustPoints($Direction)
    $CurrentNumber = GUICtrlRead($FatePts)
    If $Direction = "U" Then
        $NewNumber = $CurrentNumber + 1
    Else
        $NewNumber = $CurrentNumber - 1
    EndIf
    GUICtrlSetData($FatePts, $NewNumber)
EndFunc

Func easydie($die) ; simple die with output
   $results = Random(1,$die, 1)
   GUICtrlSetData($OutputWindow,  $results & " (d" &$die &")" & @CRLF & GuiCtrlRead($OutputWindow))
EndFunc

Func multidie($die) ; multible dice rolls with output
   dim $avArray[GUICtrlRead($NumberSelected)+1] ;This seems like the array is being declared with an extra element, don't know why
   $string1=GUICtrlRead($NumberSelected)&"d"&$die ;the number of dice followed by the number of pips
   for $i = 1 to GUICtrlRead($NumberSelected)
      $avArray[$i-1]=Random(1,$die,1) ;$avArray[$i-1] is because the array element numbering starts at 0
   Next
   if GUICtrlRead($SortResults)=1 then _ArraySort( $avArray,1) ;Sorts array, 1= descending
   $string=$avArray[0] ;Load the first element of the array inro $string
   $total=int($avArray[0]) ;Load the first element of the array into $total
   for $i = 1 to (GUICtrlRead($NumberSelected)-1)
      $string=  $string & ", " & $avArray[$i] ;Read the array values into a variable seperated by a comma and a space
      $total=$total+int($avArray[$i]) ;Add the values in the array together
   Next
   GUICtrlSetData($OutputWindow, $string & " (" & "Total: " & $total & " | " &$string1 & ")" & @CRLF & GuiCtrlRead($OutputWindow))
EndFunc

Func DnDAttributes() ; D&D 3 Attribute roller (4d6 keep highest 3)
   dim $avArray[4]
   dim $total[6]
   for $j = 0 to 5 ;Generate 6 different numbers
      for $i = 0 to 3 ;Track array elements
         $avArray[$i]=Random(1,6,1) ;Generate random values to store in the array.
      next
      _ArraySort( $avArray,1) ;Sort the array, descneding
      $total[$j]=$avArray[0]+$avArray[1]+$avArray[2] ;add the first three (highest) values of the sorted array into the result array
   next
   _ArraySort($total,1) ;Sort the six results, descending
   GUICtrlSetData($OutputWindow, "D&D Attributes: " & $total[0] & ", " & $total[1] & ", " & $total[2] & ", " & $total[3] & ", " & $total[4] & ", " & $total[5] & @CRLF & GuiCtrlRead($OutputWindow))
endfunc

Func savagedie($diex) ; roll again on max, unskilled d4-2
   if $diex="unskilled" then ;If the  button (die) = unskilled, then set the die to 4 and subtract 2 from the results.
      $die=4
      $results=-2
      $string1="unskilled"
  elseif $diex=1 then ;If a 1 is passed, use the formula d2-1 provided in the SW Attribute+ Skill doc to resolve the roll
      $die=2
      $results=-1
      $string1="d"&$diex
   else ;if $diex is 2 or more, the die = the value of the button and the results are not modified.
      $die=$diex
      $results=0
      $string1="d"&$diex
   endif
   Do ;Generate die numbers until the number generated is less than the maximum number of pips on the die.  Add the numbers to get the final results
      $x=Random(1,$die,1)
      $results=$results+$x
   until $x<$die 
   GUICtrlSetData($OutputWindow, $results & " (" & $string1 & ")" & @CRLF & GuiCtrlRead($OutputWindow))
EndFunc

Func savagemultidie($diex) ;Same as savagedie but multiple dies
   dim $avArray[GUICtrlRead($NumberSelected)+1]
   if $diex="unskilled" then
      $die=4
      $string1="unskilled"
   elseif $diex=1 Then
      $die=2
      $string1=GUICtrlRead($NumberSelected)&"d"&$diex
   else
      $die=$diex
      $string1=GUICtrlRead($NumberSelected)&"d"&$diex
   endif
   for $i = 1 to GUICtrlRead($NumberSelected)
      if $diex="unskilled" then
         $avArray[$i-1]=-2
     elseif $diex=1 then
         $avArray[$i-1]=-1
     else
         $avArray[$i-1]=0
      endif
      Do
         $x=Random(1,$die,1)
         $avArray[$i-1]=$avArray[$i-1]+$x ;add the numbers to the $avArray variable at element $i-1
      until $x<$die         
   Next
   if GUICtrlRead($SortResults)=1 then _ArraySort( $avArray,1)
   $string=$avArray[0]
   $total=int($avArray[0])
   for $i = 1 to (GUICtrlRead($NumberSelected)-1)
      $string=  $string & ", " & $avArray[$i]
      $total=$total+int($avArray[$i])
   Next
   GUICtrlSetData($OutputWindow, $string & " (" & "Total: " & $total & " | " &$string1 & ")" & @CRLF & GuiCtrlRead($OutputWindow))
Endfunc

Func savagewilddie($diex) ; same as savagedie but roll also an additional d6 (wild die) -> higher roll counts
   if $diex="unskilled" then
      $die=4
      $results1=-2
      $results2=-2
      $string1="unskilled"
   elseif $diex=1 then
      $die=2
      $results1=-1
      $results2=-1
      $string1="d"&$diex
   else
      $die=$diex
      $results1=0
      $results2=0
      $string1="d"&$diex
   endif
   Do
      $x=Random(1,$die,1)
      $results1=$results1+$x
   until $x<$die 
   Do
      $x=Random(1,6,1)
      $results2=$results2+$x
   until $x<6
   if $results1 >= $results2 then
         $string = $results1 & ", " & $results2 & "w (" & $string1 & ")"
   else
         $string = $results2 & "w, " & $results1 & " (" & $string1 & ")"
   endif
   GUICtrlSetData($OutputWindow, $string & @CRLF & GuiCtrlRead($OutputWindow))
endfunc

Func InitializeFullDeck() ;Create an array containing a full deck of cards, the placeholder is just window dressing in this deck 
    $FullDeck = _ArrayCreate("Ace of Spades", "Ace of Diamonds", "Ace of Hearts", "Ace of Clubs")
    For $i=2 To 13
        Switch $i
            Case 2 To 10
                $CardValue= $i
            Case 11
                $CardValue= "Jack"
            Case 12
                $CardValue= "Queen"
            Case 13
                $CardValue= "King"
        EndSwitch
        _ArrayAdd( $FullDeck,$CardValue&" of Spades")
        _ArrayAdd( $FullDeck,$CardValue&" of Diamonds")
        _ArrayAdd( $FullDeck,$CardValue&" of Hearts")
        _ArrayAdd( $FullDeck,$CardValue&" of Clubs")
    Next
    _ArrayAdd($FullDeck,"Little Joker")
    _ArrayAdd($FullDeck,"Big Joker")
    _ArrayAdd($FullDeck,"Placeholder")
EndFunc

Func InitializeCardDeck1() ;create a deck of cards, the placeholder is so that there is still an element in the array when all the rest of the cards have been chosen.
    $CardDeck1 = _ArrayCreate("Ace of Spades", "Ace of Diamonds", "Ace of Hearts", "Ace of Clubs")
    For $i=2 To 13
        Switch $i
            Case 2 To 10
                $CardValue= $i
            Case 11
                $CardValue= "Jack"
            Case 12
                $CardValue= "Queen"
            Case 13
                $CardValue= "King"
        EndSwitch
        _ArrayAdd( $CardDeck1,$CardValue&" of Spades")
        _ArrayAdd( $CardDeck1,$CardValue&" of Diamonds")
        _ArrayAdd( $CardDeck1,$CardValue&" of Hearts")
        _ArrayAdd( $CardDeck1,$CardValue&" of Clubs")
    Next
    _ArrayAdd($CardDeck1,"Little Joker")
    _ArrayAdd($CardDeck1,"Big Joker")
    _ArrayAdd($CardDeck1,"Placeholder")
EndFunc

Func InitializeCardDeck2() ;Same as Deck 1
    $CardDeck2 = _ArrayCreate("Ace of Spades", "Ace of Diamonds", "Ace of Hearts", "Ace of Clubs")
    For $i=2 To 13
        Switch $i
            Case 2 To 10
                $CardValue= $i
            Case 11
                $CardValue= "Jack"
            Case 12
                $CardValue= "Queen"
            Case 13
                $CardValue= "King"
        EndSwitch
        _ArrayAdd( $CardDeck2,$CardValue&" of Spades")
        _ArrayAdd( $CardDeck2,$CardValue&" of Diamonds")
        _ArrayAdd( $CardDeck2,$CardValue&" of Hearts")
        _ArrayAdd( $CardDeck2,$CardValue&" of Clubs")
    Next
    _ArrayAdd($CardDeck2,"Little Joker")
    _ArrayAdd($CardDeck2,"Big Joker")
    _ArrayAdd($CardDeck2,"Placeholder")
EndFunc

Func DrawRandomCard()
    $i=Random(0,53)
    $CardDrawn=$FullDeck[$i]
    GUICtrlSetData($OutputWindow, $CardDrawn & @CRLF & GuiCtrlRead($OutputWindow))
EndFunc

Func DrawFromDeck1()
    $NumberOfCardsLeft=UBound($CardDeck1)-1 ;Subtract 1 for the placeholder
    $i=Random(0, $NumberOfCardsLeft)
    $CardDrawn=$CardDeck1[$i]
    _ArrayDelete($CardDeck1,$i)
    GUICtrlSetData($OutputWindow, $CardDrawn & @CRLF & GuiCtrlRead($OutputWindow))
    If UBound($CardDeck1)=1 Then
        InitializeCardDeck1()
        GUICtrlSetData($OutputWindow, "Out of Cards.  Deck 1 reshuffled." & @CRLF & GuiCtrlRead($OutputWindow))
    EndIf
EndFunc

Func IssueCards($NumberOfPlayers)
    Dim $CardsPicked[$NumberOfPlayers] ;Create an array to hold the cards picked
    $NumberOfCardsLeft=UBound($CardDeck2)-1 ;Subtract 1 for the placeholder
    If $NumberOfPlayers > 54 Then
        GUICtrlSetData($OutputWindow, $NumberOfPlayers & "?!  Thats more players then cards in the deck.  Please choose a smaller number." & @CRLF & GuiCtrlRead($OutputWindow))
        Return
    ElseIf $NumberOfPlayers > $NumberOfCardsLeft Then
        InitializeCardDeck2()
        GUICtrlSetData($OutputWindow, "- - - - - -" & @CRLF & GuiCtrlRead($OutputWindow))
        GUICtrlSetData($OutputWindow, "More players than cards remaining.  Deck 2 reshuffled." & @CRLF & GuiCtrlRead($OutputWindow))
    EndIf
    GUICtrlSetData($OutputWindow, "-----------" & @CRLF & GuiCtrlRead($OutputWindow))
    For $i = 0 To $NumberOfPlayers-1 ;Load the card array.
        $j=Random(0, $NumberOfCardsLeft)
        $CardDrawn=$CardDeck2[$j]
        _ArrayDelete($CardDeck2,$j)
        $CardsPicked[$i]=$CardDrawn
        $NumberOfCardsLeft=UBound($CardDeck2)-1 ;Reset the number of cards left in the deck. Subtract 1 for the placeholder
    Next
    For $i = $NumberOfPlayers-1 To 0 Step -1
        GUICtrlSetData($OutputWindow, "Player " & $i+1 & ": " & $CardsPicked[$i] & @CRLF & GuiCtrlRead($OutputWindow))
    Next
    If UBound($CardDeck2)=1 Then
        InitializeCardDeck2()
        GUICtrlSetData($OutputWindow, "Out of Cards.  Deck 2 reshuffled." & @CRLF & GuiCtrlRead($OutputWindow))
    EndIf
EndFunc

Func DrawFromDeck2()
    $NumberOfCardsLeft=UBound($CardDeck2)-1 ;Subtract 1 for the placeholder
    $i=Random(0, $NumberOfCardsLeft)
    $CardDrawn=$CardDeck2[$i]
    _ArrayDelete($CardDeck2,$i)
    GUICtrlSetData($OutputWindow, $CardDrawn & @CRLF & GuiCtrlRead($OutputWindow))
    If UBound($CardDeck2)=1 Then
        InitializeCardDeck2()
        GUICtrlSetData($OutputWindow, "Out of Cards.  Deck 2 reshuffled." & @CRLF & GuiCtrlRead($OutputWindow))
    EndIf
EndFunc

Func fatetable($1,$2,$3) ; choose how probale a question is and it will thell you Yes++/Yes/No/No-- -> more explaination in the Mythic RPG
    $results = Random(1,100, 1)
   Select
        Case $results <= $1
            GUICtrlSetData($OutputWindow, "Yes maximum" & @CRLF & GuiCtrlRead($OutputWindow))
        Case $results <= $2
            GUICtrlSetData($OutputWindow, "Yes" & @CRLF & GuiCtrlRead($OutputWindow))
        Case $results < $3
            GUICtrlSetData($OutputWindow, "No" & @CRLF & GuiCtrlRead($OutputWindow))
        Case Else
            GUICtrlSetData($OutputWindow, "No maximum" & @CRLF & GuiCtrlRead($OutputWindow))
   EndSelect
EndFunc

Regards,

Z

Link to comment
Share on other sites

Well, you figured it out wrong. <_<

The real reason is that window can have multiple state bits set, and not only can, but in most cases does. Window can be both enabled and visible for example.

To check only the value you want, you have to

BitAnd(GUICtrlGetState($Control), $GUI_ENABLE)

"be smart, drink your wine"

Link to comment
Share on other sites

Well, you figured it out wrong. ;)

The real reason is that window can have multiple state bits set, and not only can, but in most cases does. Window can be both enabled and visible for example.

To check only the value you want, you have to

BitAnd(GUICtrlGetState($Control), $GUI_ENABLE)

Um, yeah, thats what I meant, but I'm not a pro.

Thanks for the code to check it the right way though, I never would have figured that out.

:P

Z

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