Jump to content

guictrlsetstate question


 Share

Go to solution Solved by water,

Recommended Posts

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.

Link to comment
Share on other sites

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 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

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 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

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 :)

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

  • Solution

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 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

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:

Link to comment
Share on other sites

 

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.

Link to comment
Share on other sites

  • Moderators

satanttin,

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

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

 

Link to comment
Share on other sites

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)

Link to comment
Share on other sites

  • Moderators

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

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

 

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