Jump to content
Sign in to follow this  
telmob

Hide an entire group possible?

Recommended Posts

telmob

I've searched the forums, and the closest i found remoted to 2008, so... i'm asking if there's a younger alternative.

How can i hide a group and everything inside it?

Could i use something like this?

$groupgroup1=$Grup1, $Combo1, $Label1, $Combo2, $Label2, $Date1, $Label3, $Combo3
GuiCtrlSetState($groupgroup1,$GUI_HIDE)

I know this specific code doesn't work, but is there an alternative?

Share this post


Link to post
Share on other sites
Melba23

telmob,

First, you need to understand how the ControlIDs are allocated. AutoIt has an internal array which holds the data for all the controls created by the native (GUICtrlCreate*) functions. The ControlID returned by these functions is actually the index of this array in which the details of the control are stored. AutoIt always looks for the first empty element of this array to use for the next created control. :)

Now to your question. If you create the controls $Grup1, $Combo1, $Label1, $Combo2, $Label2, $Date1, $Label3, $Combo3 in IMMEDIATE SUCCESSION, and no controls created earlier have been deleted, the ControlIDs of these controls should be in a single block. So you can use something like this to hide them:

For $i = $Grup1 To $Combo3
    GUICtrlSetState($i, $GUI_HIDE)
Next

Be aware that this is a trick - there is no guarantee that it will always be true in future releases - although I believe it will be because a lot of us depend on it! And it will only be true if no controls created earlier have been deleted (unless you recreate the same number of controls immediately). ;)

I hope that is clear - please ask if not. ;)

M23

Edit: Typnig! :D

Edited by Melba23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
telmob

WOW! This is actually much better than i expected.

This way i can put other controls on top of these, and hide them to show these again and so on.

Amazing trick!

Thank you Melba23! You're the GUI master! :)

Share this post


Link to post
Share on other sites
Melba23

telmob,

This way i can put other controls on top of these, and hide them to show these again and so on

Always a good idea to create all the controls initially if you want to use this trick - that way there are no holes in the array! :)

M23


Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
telmob

I just connected 3 different GUIs and hid the 2nd and 3rd part of the gui, until i press a button to show the 2nd gui and another button to show the 3rd gui, works just perfect.

I'm loving AutoIt. :)

Share this post


Link to post
Share on other sites
Melba23

taietel,

My pleasure - as always! :)

And I have some ground to make up after the tab thread the other day! ;)

M23


Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
MrBeatnik

I thought I would just chime in on this... To avoid the issue noted above where you may delete controls before these ones, you can create your controls in an array instead. This can also solve the issue where your controls may be created on the fly (or not in order).

Dim $userArray[5]

$userArray[0] = GUICtrlCreateGroup("User Info", 264, 8, 233, 281)
$userArray[1] = GUICtrlCreateLabel("User Name", 280, 40, 63, 17)
$userArray[2] = GUICtrlCreateInput("John", 360, 40, 121, 21)
$userArray[3] = GUICtrlCreateLabel("User Age", 280, 104, 66, 17)
$userArray[4] = GUICtrlCreateInput("42", 360, 104, 121, 21)
GUICtrlCreateGroup("", -99, -99, 1, 1)

For $i = 0 To UBound($roomGroupArray)-1
  GUICtrlSetState ( $roomGroupArray[$i], $GUI_HIDE )
Next

I don't know if there are any issues with this method (I haven't noted them) - I'd appreciate a reply if anyone knows of any such problems.

The only thing is you lose logical naming of the controls - i.e. instead of a control called "$lblUserName", it's called "$userArray[1]"


Please correct me if I am wrong in any of my posts. I like learning from my mistakes too.

Share this post


Link to post
Share on other sites
martin

I thought I would just chime in on this... To avoid the issue noted above where you may delete controls before these ones, you can create your controls in an array instead. This can also solve the issue where your controls may be created on the fly (or not in order).

Dim $userArray[5]

$userArray[0] = GUICtrlCreateGroup("User Info", 264, 8, 233, 281)
$userArray[1] = GUICtrlCreateLabel("User Name", 280, 40, 63, 17)
$userArray[2] = GUICtrlCreateInput("John", 360, 40, 121, 21)
$userArray[3] = GUICtrlCreateLabel("User Age", 280, 104, 66, 17)
$userArray[4] = GUICtrlCreateInput("42", 360, 104, 121, 21)
GUICtrlCreateGroup("", -99, -99, 1, 1)

For $i = 0 To UBound($roomGroupArray)-1
  GUICtrlSetState ( $roomGroupArray[$i], $GUI_HIDE )
Next

I don't know if there are any issues with this method (I haven't noted them) - I'd appreciate a reply if anyone knows of any such problems.

The only thing is you lose logical naming of the controls - i.e. instead of a control called "$lblUserName", it's called "$userArray[1]"

The method is fine IMO. If there is an issue with the names as you suggest then there is no reason why you can't have both

$BtnQuit = GuiCtrlCreateButton(...

$Actrl[0] = $BtnQuit

then when you want to refer to an individual control and make it obvious what you're doing use BtnQuit, and when you need to group them use the array.

My prefered method is

$grp1Start = 0
enum $Grp1 $BtnQuit=0 $ChkNever,..,$Ed1,$grp2Start
enum $Grp2 $BtnSave=$grp2Start, $BtnNext,...., $grp3Start
etc

Global $aCtrls[20]

;create the ctrls in any order you want.
;if you need another control in an existing group just add it in the enum list somewhere.
$aCtrls[$BtnNext] = GuiCtrlCreate.....

;then to deal with a group
for $n = $grp2Start to $Grp3Start - 1
 something($aCtrls{$n])
next

which gives the understanding and flexibility, though it needs more planning. It doesn't work so well if you are using Koda though.

Edited by martin
  • Like 1

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×