Sign in to follow this  
Followers 0
Uten

Grouping controls to hide and show them all

6 posts in this topic

Is it possible to group controls in a container (tab, frame) such that all controls inside the container disappears when you hide the container?

Just a sample to play with.

So, when I hide the tab container I expected all the controls inside it to disappear.

Yes, I know that I can sett the $GUI_HIDE state on each control manually, but where is the fun in that ;)

#include <GUIConstants.au3>

Func GuiHideControls()

    $Form3 = GUICreate("AForm3", 413, 155, 303, 219)
    $tab=GUICtrlCreateTab (10,10, 200,100)

    $tab0=GUICtrlCreateTabitem ("tab0")
    GUICtrlCreateLabel ("label0", 30,80,50,20)
    $tab0OK=GUICtrlCreateButton ("OK0", 20,50,50,20)
    $tab0input=GUICtrlCreateInput ("default", 80,50,70,20)

    $tab1=GUICtrlCreateTabitem ( "tab----1")
    GUICtrlCreateLabel ("label1", 30,80,50,20)
    $tab1combo=GUICtrlCreateCombo ("", 20,50,60,120)
    GUICtrlSetData(-1,"Trids|CyberSlug|Larry|Jon|Tylo", "Jon") ; default Jon
    $tab1OK=GUICtrlCreateButton ("OK1", 80,50,50,20)

    $tab2=GUICtrlCreateTabitem ("tab2")
    GUICtrlSetState(-1,$GUI_SHOW)   ; will be display first
    GUICtrlCreateLabel ("label2", 30,80,50,20)
    $tab2OK=GUICtrlCreateButton ("OK2", 140,50,50)

    GUICtrlCreateTabitem ("")   ; end tabitem definition

    GUISetState(@SW_SHOW)

    ;Hide and show buttons
    $Button3 = GUICtrlCreateButton("SHOW container", 48, 130, 100, 25, 0)
    $Button4 = GUICtrlCreateButton("Hide container", 280, 130, 100, 25, 0)
    GUISetState(@SW_SHOW)

    While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
            Case $GUI_EVENT_CLOSE
                Exit
            Case $Button3
                consoleWrite("SHOW" & @LF)
                GuiCtrlSetState($tab, $GUI_SHOW)
            Case $Button4
                GuiCtrlSetState($tab, $GUI_HIDE)
                consoleWrite("HIDE" & @LF)
        EndSwitch
    WEnd    
EndFunc 
; run
GuiHideControls()
exit

Share this post


Link to post
Share on other sites



Hi,

I know you know this, but anyhow it might be a workaround.

#include <GUIConstants.au3>

Func GuiHideControls()

    $Form3 = GUICreate("AForm3", 413, 155, 303, 219)
    $tab = GUICtrlCreateTab(10, 10, 200, 100)

    $tab0 = GUICtrlCreateTabItem("tab0")
    $l0 = GUICtrlCreateLabel("label0", 30, 80, 50, 20)
    $tab0OK = GUICtrlCreateButton("OK0", 20, 50, 50, 20)
    $tab0input = GUICtrlCreateInput("default", 80, 50, 70, 20)

    $tab1 = GUICtrlCreateTabItem("tab----1")
    $l1 = GUICtrlCreateLabel("label1", 30, 80, 50, 20)
    $tab1combo = GUICtrlCreateCombo("", 20, 50, 60, 120)
    GUICtrlSetData(-1, "Trids|CyberSlug|Larry|Jon|Tylo", "Jon") ; default Jon
    $tab1OK = GUICtrlCreateButton("OK1", 80, 50, 50, 20)

    $tab2 = GUICtrlCreateTabItem("tab2")
    GUICtrlSetState(-1, $GUI_SHOW)   ; will be display first
    $l2 = GUICtrlCreateLabel("label2", 30, 80, 50, 20)
    $tab2OK = GUICtrlCreateButton("OK2", 140, 50, 50)

    GUICtrlCreateTabItem("")   ; end tabitem definition
    Global $1[4] = [$tab0, $l0, $tab0OK, $tab0input]
    Global $2[4] = [$tab1, $l1, $tab1OK, $tab1combo]
    Global $3[3] = [$tab2, $l2, $tab2OK]

    GUISetState(@SW_SHOW)

    ;Hide and show buttons
    $Button3 = GUICtrlCreateButton("SHOW container", 48, 130, 100, 25, 0)
    $Button4 = GUICtrlCreateButton("Hide container", 280, 130, 100, 25, 0)
    GUISetState(@SW_SHOW)

    While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
            Case $GUI_EVENT_CLOSE
                Exit
            Case $Button3
                Switch GUICtrlRead($tab)
                    Case 0
                        _Hide($1, 1)
                    Case 1
                        _Hide($2, 1)
                    Case 2
                        _Hide($3, 1)
                EndSwitch
                
            Case $Button4
                Switch GUICtrlRead($tab)
                    Case 0
                        _Hide($1, 0)
                    Case 1
                        _Hide($2, 0)
                    Case 2
                        _Hide($3, 0)
                EndSwitch
        EndSwitch
    WEnd
EndFunc   ;==>GuiHideControls
; run
GuiHideControls()

Func _Hide($1, $state = 1)
    If $state Then
        For $i = 0 To UBound($1) - 1
            GUICtrlSetState($1[$i], $GUI_SHOW)
        Next
    Else
        For $i = 0 To UBound($1) - 1
            GUICtrlSetState($1[$i], $GUI_HIDE)
        Next
    EndIf
EndFunc   ;==>_Hide
Exit

So long,

Mega


Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post


Link to post
Share on other sites

Yea, I ended up using the same technique. But still thinks it's strange that every control is not hidden when the container is.

Thanks for the sample and answer Mega..;)

Share this post


Link to post
Share on other sites

Yea, I ended up using the same technique. But still thinks it's strange that every control is not hidden when the container is.

Thanks for the sample and answer Mega..;)

Hi,

no problem. Maybe Holger, jpm or garfrost can show us the things how autoit builds its GUI layers.

So long,

Mega


Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post


Link to post
Share on other sites

There are three methods I have used for hiding a large group of controls at once. None of them are perfect, and I kind of pick and choose depending on what I'm doing with the GUI.

Function + Array

This was the first method I ever used, and is pretty well the same as what th.meger contributed.

Func _GuiCtrlGroupSetState(ByRef $a_GroupArray, $i_State)
    For $i = 1 To $a_GroupArray[0]
        GUICtrlSetState($a_GroupArray[$i], $i_State)
    Next
EndFuncoÝ÷ ØÚ-)಩[ºØ­Ëazj,¶·¥¦åy©Ý²êÞÁ¬¨~x&º[b¦W¢{[']z{ZmÊ'¶º%ý²¢éݶ¬ëa¡Ö¥Ûeyæ¬êí¢ënëbµ×x­z¡jÈ­ßÛƽ©íj¬~ÞÅ©©ì¨¹Æ§¢yr«Þ¢w­i·(ÚèÞiÈFPZ²'²¢ç+y«^jÖrí®m«b²z-¾+"nW¨Ø^B+"±«,jey«º ­®P«y«^M¦õÓ]5Õ8^*.r·µæ­i¶§v­¶¢{k¢[2¢ìا¶­º.¥ÊÞj×az»Znj+yÊ'¶º%±ëbjzn¶Ø^^­ëÞ¯*.Á©í¶²v÷öØZ½ëhmì"¶§¶¢éݲíé{ZmÊ'¶º%ÛôázxÊ°j{m¢y¨+¢êh®Ö¡÷(Úę̀º;¬¶ë趹RzÔ­j×´ß â}÷«z{Si²-zm7èeHs{¦¦WºÚ"µÍÚ[ÛYH    ÑÕRPÛÛÝ[Ë]LÉÝÂÕRPÜX]J    ÌÎNÕXÝ  ÌÎNË
BÌÍÝXHÕRPÝÜX]UXLLLLKJBÌÍÝXHHÕRPÝÜX]UX][J    ÌÎNÌIÌÎNÊBQÕRPÝÜX]P]Û ÌÎNÐ]ÛÌÎNË
ÌÌ
BQÕRPÝÜX]SX[
    ÌÎNÓX[   ÌÌÎÉÌÎNË
L
L
L
BQÕRPÝÜX]SX[
    ÌÎNÓX[ÌÎNËLL
L
BÌÍÝXHÕRPÝÜX]UX][J    ÌÎNÌÌÎNÊBQÕRPÝÜX]P]Û  ÌÎNÐ]ÛÌÎNË
Ì
Ì
BQÕRPÝÜX]SX[
    ÌÎNÓX[   ÌÌÎÉÌÎNË
L
L
L
BQÕRPÝÜX]SX[
    ÌÎNÓX[ÌÎNËL
L
BÌÍÝXHÕRPÝÜX]UX][J    ÌÎNÌ ÌÎNÊBÕRPÝÜX]UX][J ÌÎNÉÌÎNÊBÌÍØ]ÛHÕRPÝÜX]P]Û ÌÎNØÛXÚÈYIÌÎNËN

BÕRTÙ]Ý]J
BÌÍÚUXÙ[XÝHÚ[HBIÌÍÙÛHHÕRQÙ]ÙÊ
BTÝÚ]Ú   ÌÍÙÛBBPØÙH    ÌÍØ]ÛBBTÝÚ]Ú ÌÍÚUXÙ[XÝBBBPØÙHBBBBQÝZPÝÙ]Ý]J   ÌÍÝX ÌÍÑÕRWÔÒÕÊBBBBPØÙHBBBBBQÝZPÝÙ]Ý]J ÌÍÝXK    ÌÍÑÕRWÔÒÕÊBBBBPØÙHBBBBQÝZPÝÙ]Ý]J  ÌÍÝX ÌÍÑÕRWÔÒÕÊBBBQ[ÝÚ]ÚBBIÌÍÚUXÙ[XÝ
ÏHBBBRY    ÌÍÚUXÙ[XÝ  ÝÈ[   ÌÍÚUXÙ[XÝHBPØÙH  ÌÍÑÕRWÑUSÐÓÔÑBBBQ^]Q[ÝÚ]ÚÑ[

Hidden Child GUI Window

This method is similar to the tab control idea above, but instead of switching hidden tabs around to hide/show your controls, you hide/show child GUIs embedded in your parent GUI. The disadvantages to this one were that you couldn't place the controls anywhere you wanted, because your child GUI can overlap other controls and end up hiding them, so you have a specific rectangular area that you can hide/show your controls from. Another disadvantage is that, as far as I have been able to figure, you won't be able to press tab to get around to controls on the child GUI from your parent GUI.

Sorry I don't have time to write up an example for this one right now, I have to get going, maybe later.

Hopefully some of this extensive (re: long and boring :P) post will help somebody out. I'd hate to think I typed all this up for no good reason.

Later.

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

I know this post is a decade old, but for future askers of the same question:

Hiding a Tab control will not hide the controls belonging to it. While this is counterintuitive, I've used this behavior much to my advantage (as described here). Anyway, one trick would be to create a dummy tab item in your tab control. When you wish to "hide" your entire tab control, if you hide the control itself and at the same time switch to your dummy tab, then that should get the desired effect.

One possible drawback is if your tab control does not have a transparent background then you might not see things "beneath" it, if that's what you're going for. But if your tab control has a specific color, you should be able to work around this by setting its background color to transparent, and adding a Graphic control with the same dimensions as your tab control, and set its color to the desired background color. Then, add an instance of this graphic control to each tab item.

- Jeemo

Edited by Jeemo
Typo

An emoticon is worth a dozen words.

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  
Followers 0