Jump to content
Sign in to follow this  
satanttin

guictrlsetstate question

Recommended Posts

satanttin

Hello,

I have a question i would like to know is it possible to mass hide controls and mass show controls? because i have a few controls i want to hide in certain menu's.

as example with menu 1 i want to show label 1/10 and if i press on menu 2 i want to show button 1/10 can someone give me pointers where to go with this?

cause my script would be way too long if i do this one by one.

If it's not possible i just add em one by one tho.

Share this post


Link to post
Share on other sites
water

Either set the controls to enabled/disabled (using $GUI_ENABLE / $GUI_DISABLE) or use Melba's >GUIExtender UDF to show/hide a part of the GUI.

Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-01-27 - Version 1.3.3.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
satanttin

Either set the controls to enabled/disabled (using $GUI_ENABLE / $GUI_DISABLE) or use Melba's >GUIExtender UDF to show/hide a part of the GUI.

yes but  $gui_enable/disable is the same as $gui_show/hide right? since when they are hided i can't use em and can't click on it?

Share this post


Link to post
Share on other sites
water

No.

$GUI_SHOW Control will be visible. On Tabitem control will select the first tab to be displayed.

$GUI_HIDE Control will not be visible.

$GUI_ENABLE Control will be enabled.

$GUI_DISABLE Control will be greyed out.

Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-01-27 - Version 1.3.3.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
satanttin

greyed out but still visable?

cause if that's the case it would be anoying since the different menu's will overlap some of the controls that will be ontop of each other.

and the tab display will be ok because the program is just for clicking buttons and seeing text so no need that the tabitem control will be in the correct order?

Share this post


Link to post
Share on other sites
michaelslamet

I started most of my "main" scripts in 2010. That was the first time I hear about AutoIT.

I wrote most of the GUI Controls manually, that is write them one by one, line by line.

When I need to mass control them (eg: disable/enable them, move them to new position, checked/unchecked them), it's pain in the as*

Later on, I learned I should put them on array, so I can use For...Next loop to control them, something like:

For $a = 0 to Ubound($aList_of_Websites)-1
    $hCheckBox[$a] = GUICtrlCreateCheckbox($aList_of_Websites[$a], 20, 100 + (20 * $a))
    GUICtrlSetState($hCheckBox[$a], $GUI_CHECKED)
Next

 

Maybe you should put those controls into array?

Share this post


Link to post
Share on other sites
water

It becomes a bit hard to follow what you have and what you try to achieve.

Have you already coded something you can post?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-01-27 - Version 1.3.3.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
satanttin

I started most of my "main" scripts in 2010. That was the first time I hear about AutoIT.

I wrote most of the GUI Controls manually, that is write them one by one, line by line.

When I need to mass control them (eg: disable/enable them, move them to new position, checked/unchecked them), it's pain in the as*

Later on, I learned I should put them on array, so I can use For...Next loop to control them, something like:

For $a = 0 to Ubound($aList_of_Websites)-1
    $hCheckBox[$a] = GUICtrlCreateCheckbox($aList_of_Websites[$a], 20, 100 + (20 * $a))
    GUICtrlSetState($hCheckBox[$a], $GUI_CHECKED)
Next

Maybe you should put those controls into array?

ermm well i'm not that smart hehe xD and seems way too difficult to me so might stick with doing it manual.

not that bad once i set it up good it can stay as it is for a long time anyways, it's just a small program. but thanks for your reply :)

Share this post


Link to post
Share on other sites
satanttin

It becomes a bit hard to follow what you have and what you try to achieve.

Have you already coded something you can post?

Func Gui_Main()
GUISetState(@SW_SHOW, $Main)
GUIDelete($Gui_Startup)
GUICtrlSetState($LName, $GUI_SHOW)
GUICtrlSetState($LDepartment, $GUI_SHOW)
EndFunc

something like that when i open a new gui i want such things automaticly be shown and other labels and what not be hidden till i goto home where other controls need to be visable and those not.

Share this post


Link to post
Share on other sites
water

Here is an example how the array thing works. You can either create the controls in a loop or manually. It's important to store the returned ControlIds in a array.

#include <GUIConstantsEx.au3>

Global $msg, $ahCheckBoxes[10]
GUICreate("My GUI")
; Create some (5) checkboxes in a loop
For $iIndex = 0 To 4
    $ahCheckBoxes[$iIndex] = GUICtrlCreateCheckbox($ahCheckBoxes[$iIndex], 20, 50 + (20 * $iIndex), 15, 15)
Next
; Create some (5) checkboxes manually
$ahCheckBoxes[5] = GUICtrlCreateCheckbox($ahCheckBoxes[$iIndex], 20, 50 + (20 * 5), 15, 15)
$ahCheckBoxes[6] = GUICtrlCreateCheckbox($ahCheckBoxes[$iIndex], 20, 50 + (20 * 6), 15, 15)
$ahCheckBoxes[7] = GUICtrlCreateCheckbox($ahCheckBoxes[$iIndex], 20, 50 + (20 * 7), 15, 15)
$ahCheckBoxes[8] = GUICtrlCreateCheckbox($ahCheckBoxes[$iIndex], 20, 50 + (20 * 8), 15, 15)
$ahCheckBoxes[9] = GUICtrlCreateCheckbox($ahCheckBoxes[$iIndex], 20, 50 + (20 * 9), 15, 15)
$hCheck = GUICtrlCreateButton("Check all", 20, 260, 80)
$hUncheck = GUICtrlCreateButton("Uncheck all", 110, 260, 80)
GUISetState(@SW_SHOW)
While 1
    $msg = GUIGetMsg()
    Switch $msg
        Case $GUI_EVENT_CLOSE
            ExitLoop
        Case $hCheck
            For $iIndex = 0 To UBound($ahCheckBoxes) - 1
                GUICtrlSetState($ahCheckBoxes[$iIndex], $GUI_CHECKED)
            Next
        Case $hUncheck
            For $iIndex = 0 To UBound($ahCheckBoxes) - 1
                GUICtrlSetState($ahCheckBoxes[$iIndex], $GUI_UnCHECKED)
            Next
    EndSwitch
WEnd
GUIDelete()

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-01-27 - Version 1.3.3.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
michaelslamet

ermm well i'm not that smart hehe xD and seems way too difficult to me so might stick with doing it manual.

not that bad once i set it up good it can stay as it is for a long time anyways, it's just a small program. but thanks for your reply :)

 

If I'm that smart, I already have a capability to create some powerful UDFs and share it here :ph34r:

Share this post


Link to post
Share on other sites
satanttin

 

Here is an example how the array thing works. You can either create the controls in a loop or manually. It's important to store the returned ControlIds in a array.

#include <GUIConstantsEx.au3>

Global $msg, $ahCheckBoxes[10]
GUICreate("My GUI")
; Create some (5) checkboxes in a loop
For $iIndex = 0 To 4
    $ahCheckBoxes[$iIndex] = GUICtrlCreateCheckbox($ahCheckBoxes[$iIndex], 20, 50 + (20 * $iIndex), 15, 15)
Next
; Create some (5) checkboxes manually
$ahCheckBoxes[5] = GUICtrlCreateCheckbox($ahCheckBoxes[$iIndex], 20, 50 + (20 * 5), 15, 15)
$ahCheckBoxes[6] = GUICtrlCreateCheckbox($ahCheckBoxes[$iIndex], 20, 50 + (20 * 6), 15, 15)
$ahCheckBoxes[7] = GUICtrlCreateCheckbox($ahCheckBoxes[$iIndex], 20, 50 + (20 * 7), 15, 15)
$ahCheckBoxes[8] = GUICtrlCreateCheckbox($ahCheckBoxes[$iIndex], 20, 50 + (20 * 8), 15, 15)
$ahCheckBoxes[9] = GUICtrlCreateCheckbox($ahCheckBoxes[$iIndex], 20, 50 + (20 * 9), 15, 15)
$hCheck = GUICtrlCreateButton("Check all", 20, 260, 80)
$hUncheck = GUICtrlCreateButton("Uncheck all", 110, 260, 80)
GUISetState(@SW_SHOW)
While 1
    $msg = GUIGetMsg()
    Switch $msg
        Case $GUI_EVENT_CLOSE
            ExitLoop
        Case $hCheck
            For $iIndex = 0 To UBound($ahCheckBoxes) - 1
                GUICtrlSetState($ahCheckBoxes[$iIndex], $GUI_CHECKED)
            Next
        Case $hUncheck
            For $iIndex = 0 To UBound($ahCheckBoxes) - 1
                GUICtrlSetState($ahCheckBoxes[$iIndex], $GUI_UnCHECKED)
            Next
    EndSwitch
WEnd
GUIDelete()

Thanks for the demo but this is way to hard for me to implent this option.

So guys thanks for the advice but i got to go with the manual feature all the scripting and testing is not worth for a few controls if it where 100+ ok but it's not.

So i mak this one as solved.

Share this post


Link to post
Share on other sites
Melba23

satanttin,

Have you looked at my GUIExtender UDF as suggested earlier? It might be just what you are looking for. ;)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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
satanttin

satanttin,

Have you looked at my GUIExtender UDF as suggested earlier? It might be just what you are looking for. ;)

M23

@Melba23 yes i did just didn't figured it out xD never worked with a udf anyways :P

since i love to write my own scripts. (and because i just didn't get what it did exactly)

Share this post


Link to post
Share on other sites
Melba23

satanttin,

 

never worked with a udf anyways

Then you are missing out on what is probably the greatest advantage of the language and the forum - being able to harness the power of code from others into your own scripts without too much difficulty. But if that is your choice..... ;)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

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  

×