Damein Posted June 8, 2016 Share Posted June 8, 2016 So I have a GUI that has 1-200 Group controls and I need a way to "scroll" through them cleanly but with only a fixed amount... I was originally going to do it like this For $i = 12 to 24 GuiCtrlSetState($ImageBox[$i], $GUI_SHOW) Next For $i = 1 To 12 GuiCtrlSetState($ImageBox[$i], $GUI_HIDE) Next For $i = 25 To 200 GuiCtrlSetState($ImageBox[$i], $GUI_HIDE) Next $CurrentSet = 2 And thus that would properly show 12-24 and hide all others. Now A: That's a lot of If statements (ugly) B: I want to set a max number too. IE: Let's say I don't want the user to be able to go over 50. That 50 is held in a var, lets call it $MaxCount. So I need to be able to do the same thing as above but also make a changeable cap. I'm kinda at a stump for this. If it doesn't make sense let me know and I'll phrase it differently. Thanks! Most recent sig. I made Quick Launcher W/ Profiles Topic Movie Database Topic & Website | LiveStreamer Pro Website | YouTube Stand-Alone Playlist Manager: Topic | Weather Desktop Widget: Topic | Flash Memory Game: Topic | Volume Control With Mouse / iTunes Hotkeys: Topic | Weather program: Topic | Paws & Tales radio drama podcast mini-player: Topic | Quick Math Calculations: Topic Link to comment Share on other sites More sharing options...
orbs Posted June 8, 2016 Share Posted June 8, 2016 option 1: when you generate the controls, put their control ID's in a 2D array: col#0 = control ID, col#1 = index number of the group they belong to. very easy to show/hide a specific group. option 2: if the controls are somewhat identical, store only the values in the said array (instead of control ID), then use GuiCtrlSetData() to update the existing controls, which you need to build only once. option 3: ListView? can you post a screenshot? Xandy 1 Signature - my forum contributions: Spoiler UDF: LFN - support for long file names (over 260 characters) InputImpose - impose valid characters in an input control TimeConvert - convert UTC to/from local time and/or reformat the string representation AMF - accept multiple files from Windows Explorer context menu DateDuration - literal description of the difference between given dates Apps: Touch - set the "modified" timestamp of a file to current time Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes SPDiff - Single-Pane Text Diff Link to comment Share on other sites More sharing options...
Damein Posted June 8, 2016 Author Share Posted June 8, 2016 Screen shot: Here is how I created the GUI / Groups. $TotalCreationCount = 0 $XCreationCount = 0 $YCreationCount = 0 $X = 60 $Y = 60 For $i = 1 To 200 If $XCreationCount = 4 Then $X = 60 $XCreationCount = 1 Else $XCreationCount += 1 EndIf If $YCreationCount = 4 Then $Y += 120 $YCreationCount = 1 Else $YCreationCount += 1 EndIf $ImageBox[$i] = GUICtrlCreateGroup("Charger " & $i, $X, $Y, 100, 100) $X += 160 $TotalCreationCount += 1 If $TotalCreationCount = 12 Then $X = 60 $Y = 60 $XCreationCount = 0 $YCreationCount = 0 $TotalCreationCount = 0 EndIf Next For $i = 13 To 200 GUICtrlSetState($ImageBox[$i], $GUI_HIDE) Next So as you can see in the SS there's a "Device Count" that is not always going to be the same per user. So I need a way to: A: Hide/Show controls based on the < and > arrows. B: Not allow the user to show more than "Device Count" although making it show a base of 12 is fine, I'll just rename the group text to "NA" or something to denote their not used. Thanks! Also, I already use a list view as a second way to view the devices found in "View Options" Most recent sig. I made Quick Launcher W/ Profiles Topic Movie Database Topic & Website | LiveStreamer Pro Website | YouTube Stand-Alone Playlist Manager: Topic | Weather Desktop Widget: Topic | Flash Memory Game: Topic | Volume Control With Mouse / iTunes Hotkeys: Topic | Weather program: Topic | Paws & Tales radio drama podcast mini-player: Topic | Quick Math Calculations: Topic Link to comment Share on other sites More sharing options...
Damein Posted June 8, 2016 Author Share Posted June 8, 2016 To better explain is the cut out of the GUI ect. for the problem. expandcollapse popup#include <GUIConstantsEx.au3> #include <GuiComboBox.au3> #include <GuiMenu.au3> #include <GuiListView.au3> #include <ListViewConstants.au3> #include <Array.au3> #include <GUIConstantsEx.au3> #include <EditConstants.au3> Opt("GUIOnEventMode", 1) Global $ChargerCount = 43, $CurrentSet = 1 Dim $ImageBox[201] _ImageGUI() Func _ImageGUI() $CurrentGui = "Image" $DeviceCount = 0 $FoundFault = 0 $CurrentFaultCount = 0 $NewFaultCount = 0 Dim $COMList[100], $ChargerIDS[1000], $Item[1000], $ItemCode[1000], $ImageBox[1000] $ChargerCount = 0 $Status = 1 $ImageGui = GUICreate("Facility Overview - Image", 700, 500) GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit") GUISetBkColor(0xFFFFFF) $StartButton = GUICtrlCreateButton("Start", 10, 420, 100, 50) ;~ GUICtrlSetOnEvent(-1, "_Start") GUICtrlSetFont(-1, 16) $StopButton = GUICtrlCreateButton("Stop", 590, 420, 100, 50) ;~ GUICtrlSetOnEvent(-1, "_Stop") GUICtrlSetFont(-1, 16) GUICtrlCreateLabel("Device Count", 203, 420, 200, 20) GUICtrlSetFont(-1, 12) $DisplayChargerCount = GUICtrlCreateInput("NA", 200, 450, 100, 30, BitOR($ES_CENTER, $ES_READONLY)) GUICtrlSetFont(-1, 14) GUICtrlCreateLabel("Faults", 430, 420, 100, 20) GUICtrlSetFont(-1, 12) $DisplayFaultCount = GUICtrlCreateInput("NA", 400, 450, 100, 30, BitOR($ES_CENTER, $ES_READONLY)) GUICtrlSetFont(-1, 14) Local $COMmenu = GUICtrlCreateMenu("COM List") $ViewMenu = GUICtrlCreateMenu("View Options") $ListViewOption = GUICtrlCreateMenuItem("List View", $ViewMenu) ;~ GUICtrlSetOnEvent(-1, "_ChangeGui") $ImageViewOption = GUICtrlCreateMenuItem("Image View", $ViewMenu) ;~ GUICtrlSetOnEvent(-1, "_ChangeGui") GUICtrlSetState(-1, $GUI_CHECKED) GUICtrlCreateLabel("COM Port:", 10, 10, 200, 40) GUICtrlSetFont(-1, 14) $DisplayCOM = GUICtrlCreateInput("NA", 100, 9, 140, 25, $ES_READONLY) GUICtrlSetFont(-1, 14) GUICtrlCreateLabel("Status:", 483, 10, 200, 40) GUICtrlSetFont(-1, 14) $DisplayStatus = GUICtrlCreateInput("Idle", 545, 9, 140, 25, $ES_READONLY) GUICtrlSetFont(-1, 14) GUICtrlSetBkColor($DisplayStatus, 0xFFFF00) $TotalCreationCount = 0 $XCreationCount = 0 $YCreationCount = 0 $X = 60 $Y = 60 For $i = 1 To 200 If $XCreationCount = 4 Then $X = 60 $XCreationCount = 1 Else $XCreationCount += 1 EndIf If $YCreationCount = 4 Then $Y += 120 $YCreationCount = 1 Else $YCreationCount += 1 EndIf $ImageBox[$i] = GUICtrlCreateGroup("Charger " & $i, $X, $Y, 100, 100) $X += 160 $TotalCreationCount += 1 If $TotalCreationCount = 12 Then $X = 60 $Y = 60 $XCreationCount = 0 $YCreationCount = 0 $TotalCreationCount = 0 EndIf Next For $i = 13 To 200 GUICtrlSetState($ImageBox[$i], $GUI_HIDE) Next $NextButton = GUICtrlCreateButton(">", 660, 182, 40, 100) GUICtrlSetOnEvent(-1, "_NextSet") GUICtrlSetFont(-1, 16) $PreviousButton = GUICtrlCreateButton("<", 0, 182, 40, 100) GUICtrlSetOnEvent(-1, "_PreviousSet") GUICtrlSetFont(-1, 16) GUISetState() EndFunc ;==>_ImageGUI Func _NextSet() If $CurrentSet = 1 Then For $i = 12 To 24 GUICtrlSetState($ImageBox[$i], $GUI_SHOW) Next For $i = 1 To 12 GUICtrlSetState($ImageBox[$i], $GUI_HIDE) Next For $i = 25 To 200 GUICtrlSetState($ImageBox[$i], $GUI_HIDE) Next $CurrentSet = 2 ElseIf $CurrentSet = 2 Then For $i = 25 To 37 GUICtrlSetState($ImageBox[$i], $GUI_SHOW) Next For $i = 1 To 24 GUICtrlSetState($ImageBox[$i], $GUI_HIDE) Next For $i = 37 To 200 GUICtrlSetState($ImageBox[$i], $GUI_HIDE) Next $CurrentSet = 3 ElseIf $CurrentSet = 3 Then For $i = 37 To 49 GUICtrlSetState($ImageBox[$i], $GUI_SHOW) Next For $i = 1 To 36 GUICtrlSetState($ImageBox[$i], $GUI_HIDE) Next For $i = 49 To 200 GUICtrlSetState($ImageBox[$i], $GUI_HIDE) Next $CurrentSet = 4 ElseIf $CurrentSet = 4 Then For $i = 49 To 61 GUICtrlSetState($ImageBox[$i], $GUI_SHOW) Next For $i = 1 To 48 GUICtrlSetState($ImageBox[$i], $GUI_HIDE) Next For $i = 61 To 200 GUICtrlSetState($ImageBox[$i], $GUI_HIDE) Next $CurrentSet = 5 ElseIf $CurrentSet = 5 Then For $i = 61 To 73 GUICtrlSetState($ImageBox[$i], $GUI_SHOW) Next For $i = 1 To 60 GUICtrlSetState($ImageBox[$i], $GUI_HIDE) Next For $i = 73 To 200 GUICtrlSetState($ImageBox[$i], $GUI_HIDE) Next $CurrentSet = 6 ElseIf $CurrentSet = 6 Then For $i = 73 To 85 GUICtrlSetState($ImageBox[$i], $GUI_SHOW) Next For $i = 1 To 72 GUICtrlSetState($ImageBox[$i], $GUI_HIDE) Next For $i = 85 To 200 GUICtrlSetState($ImageBox[$i], $GUI_HIDE) Next $CurrentSet = 7 ElseIf $CurrentSet = 7 Then For $i = 85 To 97 GUICtrlSetState($ImageBox[$i], $GUI_SHOW) Next For $i = 1 To 84 GUICtrlSetState($ImageBox[$i], $GUI_HIDE) Next For $i = 97 To 200 GUICtrlSetState($ImageBox[$i], $GUI_HIDE) Next $CurrentSet = 8 ElseIf $CurrentSet = 8 Then For $i = 97 To 109 GUICtrlSetState($ImageBox[$i], $GUI_SHOW) Next For $i = 1 To 96 GUICtrlSetState($ImageBox[$i], $GUI_HIDE) Next For $i = 109 To 200 GUICtrlSetState($ImageBox[$i], $GUI_HIDE) Next $CurrentSet = 9 ElseIf $CurrentSet = 9 Then For $i = 109 To 121 GUICtrlSetState($ImageBox[$i], $GUI_SHOW) Next For $i = 1 To 108 GUICtrlSetState($ImageBox[$i], $GUI_HIDE) Next For $i = 121 To 200 GUICtrlSetState($ImageBox[$i], $GUI_HIDE) Next $CurrentSet = 10 ElseIf $CurrentSet = 10 Then For $i = 121 To 133 GUICtrlSetState($ImageBox[$i], $GUI_SHOW) Next For $i = 1 To 120 GUICtrlSetState($ImageBox[$i], $GUI_HIDE) Next For $i = 133 To 200 GUICtrlSetState($ImageBox[$i], $GUI_HIDE) Next $CurrentSet = 11 ElseIf $CurrentSet = 11 Then For $i = 133 To 145 GUICtrlSetState($ImageBox[$i], $GUI_SHOW) Next For $i = 1 To 132 GUICtrlSetState($ImageBox[$i], $GUI_HIDE) Next For $i = 145 To 200 GUICtrlSetState($ImageBox[$i], $GUI_HIDE) Next $CurrentSet = 12 ElseIf $CurrentSet = 12 Then For $i = 145 To 157 GUICtrlSetState($ImageBox[$i], $GUI_SHOW) Next For $i = 1 To 144 GUICtrlSetState($ImageBox[$i], $GUI_HIDE) Next For $i = 157 To 200 GUICtrlSetState($ImageBox[$i], $GUI_HIDE) Next $CurrentSet = 13 ElseIf $CurrentSet = 13 Then For $i = 157 To 169 GUICtrlSetState($ImageBox[$i], $GUI_SHOW) Next For $i = 1 To 156 GUICtrlSetState($ImageBox[$i], $GUI_HIDE) Next For $i = 169 To 200 GUICtrlSetState($ImageBox[$i], $GUI_HIDE) Next $CurrentSet = 14 ElseIf $CurrentSet = 14 Then For $i = 169 To 181 GUICtrlSetState($ImageBox[$i], $GUI_SHOW) Next For $i = 1 To 168 GUICtrlSetState($ImageBox[$i], $GUI_HIDE) Next For $i = 181 To 200 GUICtrlSetState($ImageBox[$i], $GUI_HIDE) Next $CurrentSet = 15 ElseIf $CurrentSet = 15 Then For $i = 181 To 193 GUICtrlSetState($ImageBox[$i], $GUI_SHOW) Next For $i = 1 To 180 GUICtrlSetState($ImageBox[$i], $GUI_HIDE) Next For $i = 193 To 200 GUICtrlSetState($ImageBox[$i], $GUI_HIDE) Next $CurrentSet = 16 ElseIf $CurrentSet = 16 Then For $i = 193 To 200 GUICtrlSetState($ImageBox[$i], $GUI_SHOW) Next For $i = 1 To 192 GUICtrlSetState($ImageBox[$i], $GUI_HIDE) Next $CurrentSet = 17 ElseIf $CurrentSet = 17 Then For $i = 1 To 12 GUICtrlSetState($ImageBox[$i], $GUI_SHOW) Next For $i = 13 To 200 GUICtrlSetState($ImageBox[$i], $GUI_HIDE) Next $CurrentSet = 1 EndIf EndFunc ;==>_NextSet Func _PreviousSet() Sleep(10) EndFunc ;==>_PreviousSet Func _Exit() Exit EndFunc ;==>_Exit While 1 Sleep(10) WEnd I went ahead and wrote an If statement for all 200 controls. I would rather not have to use this because its rough. Also I don't know how to cap it with a ever changing variable ($ChargerCount) So once again to explain: Assume that the max amount of controls I want shown are 43. This is defined via the var $ChargerCount. I want the > arrow to cycle through controls by +12 each time but to not surpass 43. If all 43 are shown and they press > again it goes back to 1-12. Vice versa for the < arrow. I think I MAY be able to accomplish this with an If statement nested inside the other If's but I feel as if its dirty and unnecessary and there is a better way of doing it. Any suggestions would be helpful, thanks! Most recent sig. I made Quick Launcher W/ Profiles Topic Movie Database Topic & Website | LiveStreamer Pro Website | YouTube Stand-Alone Playlist Manager: Topic | Weather Desktop Widget: Topic | Flash Memory Game: Topic | Volume Control With Mouse / iTunes Hotkeys: Topic | Weather program: Topic | Paws & Tales radio drama podcast mini-player: Topic | Quick Math Calculations: Topic Link to comment Share on other sites More sharing options...
Damein Posted June 8, 2016 Author Share Posted June 8, 2016 Update! So I worked it out to clean up the Next/Previous sets, so now I just need to find a way to cap it. I think I can do it just wanted to post this in case anyone looks before I finish. Global $Set[15] = ["1-12", "12-24", "24-36", "36-48", "48-60", "60-72", "72-84", "84-96", "96-108", "108-120", "120-132", "132-144", "144-156", "156-168", "168-180"] Func _NextSet() If $CurrentSet >= 14 Then $CurrentSet = -1 EndIf $CurrentSet += 1 $SplitSet = StringSplit($Set[$CurrentSet], "-") $Min = $SplitSet[1] $Max = $SplitSet[2] For $i = 1 To 181 GUICtrlSetState($ImageBox[$i], $GUI_HIDE) Next For $i = $Min To $Max GUICtrlSetState($ImageBox[$i], $GUI_SHOW) Next EndFunc ;==>_NextSet Func _PreviousSet() If $CurrentSet <= 0 Then $CurrentSet = 15 EndIf $CurrentSet -= 1 $SplitSet = StringSplit($Set[$CurrentSet], "-") $Min = $SplitSet[1] $Max = $SplitSet[2] For $i = 1 To 181 GUICtrlSetState($ImageBox[$i], $GUI_HIDE) Next For $i = $Min To $Max GUICtrlSetState($ImageBox[$i], $GUI_SHOW) Next EndFunc ;==>_PreviousSet Most recent sig. I made Quick Launcher W/ Profiles Topic Movie Database Topic & Website | LiveStreamer Pro Website | YouTube Stand-Alone Playlist Manager: Topic | Weather Desktop Widget: Topic | Flash Memory Game: Topic | Volume Control With Mouse / iTunes Hotkeys: Topic | Weather program: Topic | Paws & Tales radio drama podcast mini-player: Topic | Quick Math Calculations: Topic Link to comment Share on other sites More sharing options...
Damein Posted June 8, 2016 Author Share Posted June 8, 2016 Sorry for all the posts ect. But I think I've got it. If anyone has a simpler way or a better way than let me know, but I think this will work out! expandcollapse popup#include <GUIConstantsEx.au3> #include <GuiComboBox.au3> #include <GuiMenu.au3> #include <GuiListView.au3> #include <ListViewConstants.au3> #include <Array.au3> #include <GUIConstantsEx.au3> #include <EditConstants.au3> Opt("GUIOnEventMode", 1) Global $ChargerCount = 43, $CurrentSet = 0, $TotalMax = 0 Dim $ImageBox[182] Global $Set[15] = ["1-12", "12-24", "24-36", "36-48", "48-60", "60-72", "72-84", "84-96", "96-108", "108-120", "120-132", "132-144", "144-156", "156-168", "168-180"] _ImageGUI() Func _ImageGUI() $CurrentGui = "Image" $DeviceCount = 0 $FoundFault = 0 $CurrentFaultCount = 0 $NewFaultCount = 0 Dim $COMList[100], $ChargerIDS[1000], $Item[1000], $ItemCode[1000], $ImageBox[1000] $ChargerCount = 0 $Status = 1 $ImageGui = GUICreate("Facility Overview - Image", 700, 500) GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit") GUISetBkColor(0xFFFFFF) $StartButton = GUICtrlCreateButton("Start", 10, 420, 100, 50) ;~ GUICtrlSetOnEvent(-1, "_Start") GUICtrlSetFont(-1, 16) $StopButton = GUICtrlCreateButton("Stop", 590, 420, 100, 50) ;~ GUICtrlSetOnEvent(-1, "_Stop") GUICtrlSetFont(-1, 16) GUICtrlCreateLabel("Device Count", 203, 420, 200, 20) GUICtrlSetFont(-1, 12) $DisplayChargerCount = GUICtrlCreateInput("NA", 200, 450, 100, 30, BitOR($ES_CENTER, $ES_READONLY)) GUICtrlSetFont(-1, 14) GUICtrlCreateLabel("Faults", 430, 420, 100, 20) GUICtrlSetFont(-1, 12) $DisplayFaultCount = GUICtrlCreateInput("NA", 400, 450, 100, 30, BitOR($ES_CENTER, $ES_READONLY)) GUICtrlSetFont(-1, 14) Local $COMmenu = GUICtrlCreateMenu("COM List") $ViewMenu = GUICtrlCreateMenu("View Options") $ListViewOption = GUICtrlCreateMenuItem("List View", $ViewMenu) ;~ GUICtrlSetOnEvent(-1, "_ChangeGui") $ImageViewOption = GUICtrlCreateMenuItem("Image View", $ViewMenu) ;~ GUICtrlSetOnEvent(-1, "_ChangeGui") GUICtrlSetState(-1, $GUI_CHECKED) GUICtrlCreateLabel("COM Port:", 10, 10, 200, 40) GUICtrlSetFont(-1, 14) $DisplayCOM = GUICtrlCreateInput("NA", 100, 9, 140, 25, $ES_READONLY) GUICtrlSetFont(-1, 14) GUICtrlCreateLabel("Status:", 483, 10, 200, 40) GUICtrlSetFont(-1, 14) $DisplayStatus = GUICtrlCreateInput("Idle", 545, 9, 140, 25, $ES_READONLY) GUICtrlSetFont(-1, 14) GUICtrlSetBkColor($DisplayStatus, 0xFFFF00) $TotalCreationCount = 0 $XCreationCount = 0 $YCreationCount = 0 $X = 60 $Y = 60 For $i = 1 To 181 If $XCreationCount = 4 Then $X = 60 $XCreationCount = 1 Else $XCreationCount += 1 EndIf If $YCreationCount = 4 Then $Y += 120 $YCreationCount = 1 Else $YCreationCount += 1 EndIf $ImageBox[$i] = GUICtrlCreateGroup("Charger " & $i, $X, $Y, 100, 100) $X += 160 $TotalCreationCount += 1 If $TotalCreationCount = 12 Then $X = 60 $Y = 60 $XCreationCount = 0 $YCreationCount = 0 $TotalCreationCount = 0 EndIf Next For $i = 13 To 181 GUICtrlSetState($ImageBox[$i], $GUI_HIDE) Next $NextButton = GUICtrlCreateButton(">", 660, 182, 40, 100) GUICtrlSetOnEvent(-1, "_NextSet") GUICtrlSetFont(-1, 16) $PreviousButton = GUICtrlCreateButton("<", 0, 182, 40, 100) GUICtrlSetOnEvent(-1, "_PreviousSet") GUICtrlSetFont(-1, 16) GUISetState() EndFunc ;==>_ImageGUI Func _NextSet() $CalculateMax = $ChargerCount For $i = 1 To 14 If $CalculateMax <= 12 Then ExitLoop EndIf If $CalculateMax >= 12 Then $CalculateMax -= 12 $TotalMax += 1 EndIf Next If $CurrentSet >= $TotalMax Then $CurrentSet = -1 EndIf $CurrentSet += 1 $SplitSet = StringSplit($Set[$CurrentSet], "-") $Min = $SplitSet[1] $Max = $SplitSet[2] For $i = 1 To 181 GUICtrlSetState($ImageBox[$i], $GUI_HIDE) Next For $i = $Min To $Max GUICtrlSetState($ImageBox[$i], $GUI_SHOW) Next EndFunc ;==>_NextSet Func _PreviousSet() $CalculateMax = $ChargerCount For $i = 1 To 14 If $CalculateMax <= 12 Then ExitLoop EndIf If $CalculateMax >= 12 Then $CalculateMax -= 12 $TotalMax += 1 EndIf Next If $CurrentSet <= 0 Then $CurrentSet = $TotalMax + 1 EndIf $CurrentSet -= 1 $SplitSet = StringSplit($Set[$CurrentSet], "-") $Min = $SplitSet[1] $Max = $SplitSet[2] For $i = 1 To 181 GUICtrlSetState($ImageBox[$i], $GUI_HIDE) Next For $i = $Min To $Max GUICtrlSetState($ImageBox[$i], $GUI_SHOW) Next EndFunc ;==>_PreviousSet Func _Exit() Exit EndFunc ;==>_Exit While 1 Sleep(10) WEnd Most recent sig. I made Quick Launcher W/ Profiles Topic Movie Database Topic & Website | LiveStreamer Pro Website | YouTube Stand-Alone Playlist Manager: Topic | Weather Desktop Widget: Topic | Flash Memory Game: Topic | Volume Control With Mouse / iTunes Hotkeys: Topic | Weather program: Topic | Paws & Tales radio drama podcast mini-player: Topic | Quick Math Calculations: Topic Link to comment Share on other sites More sharing options...
dmob Posted June 8, 2016 Share Posted June 8, 2016 I use dummy controls before creating controls to easily show/hide or enable disable controls between the dummy controls : Local $dumGrpStart1 = GUICtrlCreateDummy() ; 1st group of controls Local $dumGrpEnd1 = GUICtrlCreateDummy() Local $dumGrpStart2 = GUICtrlCreateDummy() ; 2nd group of controls Local $dumGrpEnd2 = GUICtrlCreateDummy() For $i = $dumGrpStart1 To $dumGrpEnd1 GUICtrlSetState($i, $GUI_HIDE) Next For $i = $dumGrpStart2 To $dumGrpEnd2 GUICtrlSetState($i, $GUI_SHOW) Next This makes it trivial to add/remove controls later without touching the logic to hide/show them. (Idea courtsesy of Melba... or was it AZJIO?) Link to comment Share on other sites More sharing options...
spudw2k Posted June 8, 2016 Share Posted June 8, 2016 49 minutes ago, dmob said: I use dummy controls before creating controls to easily show/hide or enable disable controls between the dummy controls : Interesting approach. Simple and effective for static GUIs; by static I mean the controls are built in order they are coded versus dynamic where the controls can be created/destroyed dynamically. You certainly could also employ dummy controls in a dynamic fashion; my point (I guess) is any controls created later will have control IDs outside the "range" of the dummy group controls. Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX Builder Misc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retrieve SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose Array Projects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalc Cool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF Link to comment Share on other sites More sharing options...
dmob Posted June 8, 2016 Share Posted June 8, 2016 4 minutes ago, spudw2k said: You certainly could also employ dummy controls in a dynamic fashion; ... and using arrays makes it possible. Although I've never had to, I would play around with storing the dummies in first and last elements of array, expanding array as needed and overwriting previous "range". Link to comment Share on other sites More sharing options...
Jeemo Posted July 24, 2016 Share Posted July 24, 2016 (edited) I know I'm a little late here, but thought it couldn't hurt to post. I was able to accomplish something similar to what you were asking via Tab controls. I have a pretty complex GUI that I'm building for which I have a handful of static controls (a couple graphic controls and a logo form a "banner" across the top, along with a Main Menu button in the top left corner - all of which are always visible at top of the application). All other controls are created dynamically, and the vast majority of those are programmatically swapped out in groups via switching tabs. The application employs a flyover Main Menu that slides in and out of view from the left side of the master window, as well as a Module Menu that lives permanently on the left side of the master window. The contents of the Module Menu will change depending on which module is selected from the Main Menu flyover. Additionally, the contents of the "main" window changes depending on what's selected in the Module Menu. I've been able to simply show/hide different groups of controls by utilizing a couple instances of the Tab control. You can only have one Tab control per GUI, but my application consists of a master GUI and several child GUIs, which enables me to pull off this approach. The GUI stack I have is structured like this: $guiMaster (Master GUI) $guiMainMenu (flyover menu GUI) $guiModuleMenu (static GUI on the left side of $guiMaster) $tabModuleMenu (Tab control for switching between the groups of controls in the Module Menu - one group per module) $tabMM_Module1 (Tab item containing all navigation controls for "Module 1") $ctrlModule1MenuItem1 $ctrlModule1MenuItem2 etc. $tabMM_Module2 (Tab item containing all navigation controls for "Module 2") $ctrlModule2MenuItem1 $ctrlModule2MenuItem2 etc. $guiMain (everything below the top "banner" section described earlier, and to the right of the Module Menu) $tabMain $tabMain_Module1 (Tab item containing all controls in the Main section for Module 1) $Module1MainControl1 $Module1MainControl2 etc. $tabMain_Module2 (Tab item containing all controls in the Main section for Module 2) $Module2MainControl1 $Module2MainControl2 etc. Again, selecting a Module from the Main Menu programmatically changes the tab to the appropriate module in the Module Menu. You can also simply hide the master Tab control - its tabs and border will then be invisible, but all controls belonging to it will remain visible, effectively masking the fact that a tab control is being used. With all this combined, it makes for a really nice way of swapping out groups of controls with just a single command instead of having to iterate through individual controls and change their state. Hope this helps the OP or someone else. - Jeemo Edited July 24, 2016 by Jeemo Better wording, better naming of example controls An emoticon is worth a dozen words. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now