Sign in to follow this  
Followers 0
Wb-FreeKill

Easier/Faster way to do this?

10 posts in this topic

Is there an easier and faster way to do this, cuz when you have about 10 of these in a loop, to hide/show the different buttons when you select a menu in the TREEVIEW.. every time you select a new TreeviewItem, it have to hide all the other buttons form the previus, can i do it in a better way @ less cpu usage?

Func PressList()
    If $msg = $generalitem Then
            GUICtrlSetState($LogEdit,$GUI_HIDE)
            GUICtrlSetState($FilesLogEdit,$GUI_HIDE)
            For $i = 1 to 14
            GUICtrlSetState ($Shutdwn[$i],$GUI_HIDE)
            Next
            For $i = 0 to 14
            GUICtrlSetState ($Windowmng[$i],$GUI_HIDE)
            Next
            For $i = 1 to 13
            GUICtrlSetState ($Mousemng[$i],$GUI_HIDE)
            Next
            For $i = 1 to 12
            GUICtrlSetState ($MessageBoxes[$i],$GUI_HIDE)
            Next
            For $i = 1 to 20
            GUICtrlSetState ($OtherStuff[$i],$GUI_HIDE)
            Next
            For $i = 1 to 14
            GUICtrlSetState ($InternetX[$i],$GUI_HIDE)
            Next
            For $i = 1 to 6
            GUICtrlSetState ($chat[$i],$GUI_HIDE)
            Next
            For $i = 1 to 15
            GUICtrlSetState ($h1[$i],$GUI_HIDE)
            Next
            For $i = 1 to 15
            GUICtrlSetState ($1[$i],$GUI_HIDE)
            Next
    EndIf
EndFunc

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Dam lots of controls - well normally I would do like this as an example...

Put all control IDs into a multidimentional array like this

Group[Control group,2,3... etc.][the Controls,2,3,4... etc.]

Then put in the splitter variable into a string like $split = 14 14 13 12 20....etc. and split it into an array with...

$sp = StringSplit($splitter) then you got the spot to split to a new array as $sp[1] would be the first target etc...

FOR $a = 1 FOR 11 // 11 groups

FOR $b = 1 TO $sp[$a]

GUICtrlSetState (Group[$a][$b],$GUI_HIDE)

Next

Next

Well something like this would do...

Kåre

Edited by kjactive

Share this post


Link to post
Share on other sites

Hey Kåre, i see your from copenhagen too :) well, im from Amager.. nice to see Danish people in here!

I understand what you explained, but not exatcly how to do it.. i se the structure in it, but this:

FOR $a = 1 FOR 11 // 11 groups

FOR $b = 1 TO $sp[$a]

Confuses me :D

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Hallå well I keep on in english, Naa it was just an example and I was not that correct...

$split = 14 14 13 12 20....etc // How many controls in the rows as string

then AutoIt has a nice 'split it up into array' function...

$sp = StringSplit($split,' ') // here you split 14 14 13 12 20... into $sp[] with a blank character as delimiter...

$sp[1] = 14 and $sp[3] = 13 etc.

Then this would be...

FOR $a = 1 FOR $sp[0] // $sp[0] = 11 groups starting as $a = 1

FOR $b = 1 TO $sp[$a] // FOR 1 TO 14 as $a was one - 2 3 4...etc.

GUICtrlSetState (Group[$a][$b],$GUI_HIDE) // this hold Control IDs

Next

Next

Actually I would put this into a function and make $GUI_HIDE as an argument then one can do the HIDE / SHOW to all the controls from just one same function well every action on the controls can then be done from just this one function...

Very tight code but I hope you got the point as there are just too many controls in your example to do a script for you...

Kåre

Edited by kjactive

Share this post


Link to post
Share on other sites

I think this can be done a bit simpler.

Dim $Group[11][21]; 20 - max controls + 1 as end marker

For $a = 0 To 10; 11 groups
    $b = 0
    While $Group[$a][$b] > 0; Until first zero item (marker) 
        GUICtrlSetState (Group[$a][$b],$GUI_HIDE)
        $b = $b + 1
    Wend
Next

Share this post


Link to post
Share on other sites

Okay, im taking this tread up again, because theres something dont understand how to do..

I'm aware of this, and how it works:

Dim $Group[11][21]; 20 - max controls + 1 as end marker

For $a = 0 To 10; 11 groups
    $b = 0
    While $Group[$a][$b] > 0; Until first zero item (marker) 
        GUICtrlSetState (Group[$a][$b],$GUI_HIDE)
        $b = $b + 1
    Wend
Next

But how to i group the control to use in this func?

Share this post


Link to post
Share on other sites

What about putting all the controls in a child GUI and hiding the GUI instead?


[font="Times"] If anyone remembers me, I am back. Maybe to stay, maybe not.----------------------------------------------------------------------------------------------------------[/font][font="Times"]Things I am proud of: Pong! in AutoIt | SearchbarMy website: F.R.I.E.S.A little website that is trying to get started: http://thepiratelounge.net/ (not mine)[/font][font="Times"] ----------------------------------------------------------------------------------------------------------[/font][font="Arial"]The newbies need to stop stealing avatars!!! It is confusing!![/font]

Share this post


Link to post
Share on other sites

What about putting all the controls in a child GUI and hiding the GUI instead?

<{POST_SNAPBACK}>

that would work, if i would like nice when a gui is in a gui..

Share this post


Link to post
Share on other sites

heres an example

#include <guiconstants.au3>
$Screen = 1
$Main = GUICreate ( "Child Example", 400, 400 )
$Menu = GUICtrlCreateList ( "", 0, 0, 100, 400 )
GUICtrlSetData ( -1, "Screen1|Screen2|Screen3", "Screen1" )
GUISetState ( )
$First = GUICreate ( "Screen 1", 300, 400, 100, 0, $WS_CHILD, -1, $Main )
GUICtrlCreateButton ( "Screen 1 Button", 100, 100, 100, 25 )
GUISetState ( )
$Second = GUICreate ( "Screen 2", 300, 400, 100, 0, $WS_CHILD, -1, $Main )
GUICtrlCreateButton ( "Screen 2 Button", 200, 100, 75, 20 )
GUICtrlCreateLabel ( "Hello!!!", 5, 5, 100, 20 )
GUISetState ( )
$Third = GUICreate ( "Screen 3", 300, 400, 100, 0, $WS_CHILD, -1, $Main )
GUICtrlCreateButton ( "Screen 3 Button", 0, 0, 50, 25 )
GUICtrlCreateCombo ( "Combo", 50, 75, 100, 20 )
GUISetState ( )
Do
    Sleep ( 10 )
    $Data = GUICtrlRead ( $Menu )
    If $Data = "Screen1" And Not ( $Screen = 1 ) Then
        $Screen = 1
        GUISetState ( @SW_SHOW, $First )
        GUISetState ( @SW_HIDE, $Second )
        GUISetState ( @SW_HIDE, $Third )
    ElseIf $Data = "Screen2" And Not ( $Screen = 2 ) Then
        $Screen = 2
        GUISetState ( @SW_HIDE, $First )
        GUISetState ( @SW_SHOW, $Second )
        GUISetState ( @SW_HIDE, $Third )
    ElseIf $Data = "Screen3" And Not ( $Screen = 3 ) Then
        $Screen = 3
        GUISetState ( @SW_HIDE, $First )
        GUISetState ( @SW_HIDE, $Second )
        GUISetState ( @SW_SHOW, $Third )
    EndIf
Until GUIGetMsg ( ) = -3

[font="Times"] If anyone remembers me, I am back. Maybe to stay, maybe not.----------------------------------------------------------------------------------------------------------[/font][font="Times"]Things I am proud of: Pong! in AutoIt | SearchbarMy website: F.R.I.E.S.A little website that is trying to get started: http://thepiratelounge.net/ (not mine)[/font][font="Times"] ----------------------------------------------------------------------------------------------------------[/font][font="Arial"]The newbies need to stop stealing avatars!!! It is confusing!![/font]

Share this post


Link to post
Share on other sites

okay ive maked something similr, and it works much better, thx!

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