Jump to content

How to Handle.... 10 Children?


Valuater
 Share

Recommended Posts

Like This...

#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>

Dim $show = 0, $Child_[11], $children = 10

$Main = GuiCreate("MyGUI", 516, 323, (@DesktopWidth-516)/2, (@DesktopHeight-323)/2)

$Button_1 = GuiCtrlCreateButton("&Next >", 335, 290, 80, 25)
$Button_2 = GuiCtrlCreateButton("< &Back", 250, 290, 80, 25)
$Button_3 = GuiCtrlCreateButton("&Exit", 420, 290, 80, 25)
$Button_6 = GuiCtrlCreateButton("", 10, 270, 495, 3, -1, $WS_EX_STATICEDGE)

GuiSetState()

$Child_[1] = GuiCreate("", 508, 238, 1, 1, BitOr($WS_CHILD,$WS_TABSTOP)+$WS_DLGFRAME ,-1, $main)
$Label_1 = GuiCtrlCreateLabel("Child 1", 10, 10, 230, 30)
GuiSetState()

$Child_[2] = GuiCreate("", 508, 238, 1, 1, BitOr($WS_CHILD,$WS_TABSTOP)+$WS_DLGFRAME ,-1, $main)
$Label_1 = GuiCtrlCreateLabel("Child 2.", 20, 20, 290, 30)
GuiSetState(@SW_HIDE)

$Child_[3] = GuiCreate("", 508, 238, 1, 1, BitOr($WS_CHILD,$WS_TABSTOP)+$WS_DLGFRAME ,-1, $main)
$Label_1 = GuiCtrlCreateLabel("Child 3.", 30, 30, 290, 30)
GuiSetState(@SW_HIDE)

$Child_[4] = GuiCreate("", 508, 238, 1, 1, BitOr($WS_CHILD,$WS_TABSTOP)+$WS_DLGFRAME ,-1, $main)
$Label_1 = GuiCtrlCreateLabel("Child 4.", 40, 40, 290, 30)
GuiSetState(@SW_HIDE)

$Child_[5] = GuiCreate("", 508, 238, 1, 1, BitOr($WS_CHILD,$WS_TABSTOP)+$WS_DLGFRAME ,-1, $main)
$Label_1 = GuiCtrlCreateLabel("Child 5.", 50, 50, 290, 30)
GuiSetState(@SW_HIDE)

$Child_[6] = GuiCreate("", 508, 238, 1, 1, BitOr($WS_CHILD,$WS_TABSTOP)+$WS_DLGFRAME ,-1, $main)
$Label_1 = GuiCtrlCreateLabel("Child 6.", 60, 60, 290, 30)
GuiSetState(@SW_HIDE)

$Child_[7] = GuiCreate("", 508, 238, 1, 1, BitOr($WS_CHILD,$WS_TABSTOP)+$WS_DLGFRAME ,-1, $main)
$Label_1 = GuiCtrlCreateLabel("Child 7.", 70, 70, 290, 30)
GuiSetState(@SW_HIDE)

$Child_[8] = GuiCreate("", 508, 238, 1, 1, BitOr($WS_CHILD,$WS_TABSTOP)+$WS_DLGFRAME ,-1, $main)
$Label_1 = GuiCtrlCreateLabel("Child 8.", 80, 80, 290, 30)
GuiSetState(@SW_HIDE)

$Child_[9] = GuiCreate("", 508, 238, 1, 1, BitOr($WS_CHILD,$WS_TABSTOP)+$WS_DLGFRAME ,-1, $main)
$Label_1 = GuiCtrlCreateLabel("Child 9.", 90, 90, 290, 30)
GuiSetState(@SW_HIDE)

$Child_[10] = GuiCreate("", 508, 238, 1, 1, BitOr($WS_CHILD,$WS_TABSTOP)+$WS_DLGFRAME ,-1, $main)
$Label_1 = GuiCtrlCreateLabel("Child 10..... You Must be Nuts if you have ... 10 Children!!!", 50, 100, 390, 30)
GUICtrlSetFont(-1, 10, 650)
GuiSetState(@SW_HIDE)

While 1
$msg = GuiGetMsg()

Select
Case $msg = $GUI_EVENT_CLOSE Or $msg = $Button_3
ExitLoop
Case $msg = $Button_1
    Set_Next()
Case $msg = $Button_2
    Set_Back()
;;;
EndSelect
WEnd


;--------- Functions -------------------

Func Set_Next()
    
    For $x = 1 to $children -1
        $Nwin = WinGetState( $child_[$x] )
        If $Nwin  > 5 Then
            GuiSetState( @SW_HIDE, $child_[$x])
            GuiSetState( @SW_SHOW, $child_[$x +1])
            Return
        EndIf
    Next
    
EndFunc

Func Set_Back()
    
    For $x = $children To 1 Step -1
        $Nwin = WinGetState( $child_[$x] )
        If $Nwin  > 5 Then
            GuiSetState( @SW_HIDE, $child_[$x])
            GuiSetState( @SW_SHOW, $child_[$x -1])
            Return
        EndIf
    Next
    
EndFunc

Update May 2008 to Autoit 3.2.12.0

Enjoy!!!

8)

Edited by Valuater

NEWHeader1.png

Link to comment
Share on other sites

  • 1 year later...

Like This...

(Snipped)

Enjoy!!!

8)

Not bad but PX currently has 18 Windows soI handled it a bit differently. It loads with 6, only 4 of which are visible on startup. My 5th tab causes 2 to be hidden and the 2 previously hidden to show. The rest of the Windows are for builtin tools and in most of those cases I only have to use 2 new Windows so that's when I do the GUICreate() for those. When I exit that particular tool I delete those GUI's and restore the main windows again. I just thought it was better than having all of them loaded at the same time and the load time for those tool windows is fast as is the restore.

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

  • 2 weeks later...
  • 1 year later...

How did you even dig up this topic after 2 years?

It's never to late to wake up a good basic scripting exeample and spend a thanks for that.

Great example, Valuater.

I never thought to use an array for set up GUI on GUI or Tabs on Tabs.

That would have been avoid some problem I've had in the past.

Attached your example with a simplyfied child switch.

Best regards, Reinhard

;; Valuater
#include <GuiConstants.au3>

Dim $show = 0, $Child_[11], $children = 10, $ChildActual= 1

$Main = GuiCreate("MyGUI", 516, 323, (@DesktopWidth-516)/2, (@DesktopHeight-323)/2)

$Button_1 = GuiCtrlCreateButton("&Next >", 335, 290, 80, 25)
$Button_2 = GuiCtrlCreateButton("< &Back", 250, 290, 80, 25)
$Button_3 = GuiCtrlCreateButton("&Exit", 420, 290, 80, 25)
$Button_6 = GuiCtrlCreateButton("", 10, 270, 495, 3, -1, $WS_EX_STATICEDGE)

GuiSetState()

$Child_[1] = GuiCreate("", 508, 238, 1, 1, BitOr($WS_CHILD,$WS_TABSTOP)+$WS_DLGFRAME ,-1, $main)
$Label_1 = GuiCtrlCreateLabel("Child 1", 10, 10, 230, 30)
GuiSetState()

$Child_[2] = GuiCreate("", 508, 238, 1, 1, BitOr($WS_CHILD,$WS_TABSTOP)+$WS_DLGFRAME ,-1, $main)
$Label_1 = GuiCtrlCreateLabel("Child 2.", 20, 20, 290, 30)
GuiSetState(@SW_HIDE)

$Child_[3] = GuiCreate("", 508, 238, 1, 1, BitOr($WS_CHILD,$WS_TABSTOP)+$WS_DLGFRAME ,-1, $main)
$Label_1 = GuiCtrlCreateLabel("Child 3.", 30, 30, 290, 30)
GuiSetState(@SW_HIDE)

$Child_[4] = GuiCreate("", 508, 238, 1, 1, BitOr($WS_CHILD,$WS_TABSTOP)+$WS_DLGFRAME ,-1, $main)
$Label_1 = GuiCtrlCreateLabel("Child 4.", 40, 40, 290, 30)
GuiSetState(@SW_HIDE)

$Child_[5] = GuiCreate("", 508, 238, 1, 1, BitOr($WS_CHILD,$WS_TABSTOP)+$WS_DLGFRAME ,-1, $main)
$Label_1 = GuiCtrlCreateLabel("Child 5.", 50, 50, 290, 30)
GuiSetState(@SW_HIDE)

$Child_[6] = GuiCreate("", 508, 238, 1, 1, BitOr($WS_CHILD,$WS_TABSTOP)+$WS_DLGFRAME ,-1, $main)
$Label_1 = GuiCtrlCreateLabel("Child 6.", 60, 60, 290, 30)
GuiSetState(@SW_HIDE)

$Child_[7] = GuiCreate("", 508, 238, 1, 1, BitOr($WS_CHILD,$WS_TABSTOP)+$WS_DLGFRAME ,-1, $main)
$Label_1 = GuiCtrlCreateLabel("Child 7.", 70, 70, 290, 30)
GuiSetState(@SW_HIDE)

$Child_[8] = GuiCreate("", 508, 238, 1, 1, BitOr($WS_CHILD,$WS_TABSTOP)+$WS_DLGFRAME ,-1, $main)
$Label_1 = GuiCtrlCreateLabel("Child 8.", 80, 80, 290, 30)
GuiSetState(@SW_HIDE)

$Child_[9] = GuiCreate("", 508, 238, 1, 1, BitOr($WS_CHILD,$WS_TABSTOP)+$WS_DLGFRAME ,-1, $main)
$Label_1 = GuiCtrlCreateLabel("Child 9.", 90, 90, 290, 30)
GuiSetState(@SW_HIDE)

$Child_[10] = GuiCreate("", 508, 238, 1, 1, BitOr($WS_CHILD,$WS_TABSTOP)+$WS_DLGFRAME ,-1, $main)
$Label_1 = GuiCtrlCreateLabel("Child 10..... You Must be Nuts if you have ... 10 Children!!!", 50, 100, 390, 30)
GUICtrlSetFont(-1, 10, 650)
GuiSetState(@SW_HIDE)

While 1
$msg = GuiGetMsg()

Select
Case $msg = $GUI_EVENT_CLOSE Or $msg = $Button_3
ExitLoop
Case $msg = $Button_1
    Set_ChildSwitch(+1)
Case $msg = $Button_2
    Set_ChildSwitch(-1)
;;;
EndSelect
WEnd


;--------- Functions -------------------

func Set_ChildSwitch($ud)
    GuiSetState( @SW_Hide, $child_[$ChildActual])
    $ChildActual += $ud
    if $Childactual = 11 then $Childactual = 1 
    if $childActual = 0 then $Childactual = 10
    GuiSetState( @SW_SHOW, $child_[$ChildActual])
endFunc
Edited by ReFran
Link to comment
Share on other sites

Is there a forum rule saying "No digging up topics that are 2 years old."?

I was going to reply to that, but it's just a stupid thing to ask.

I can ask questions like that, and all you have to do is answer me or shut up. There is no need to question every question I ask, especially not by you.

Edited by Manadar
Link to comment
Share on other sites

  • 2 months later...

the first script posted in this thread gives error.

please resolve it.

Did you look at the age of the first post?

You can resolve it yourself by # including the appropriate Constants files. See the help file for a list of which ones will have to be added. All of those used to be in GUIConstants.au3 but that has been changed.

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

the first script posted in this thread gives error.

please resolve it.

I have been going through my scripts when i have time to update to the current Autoit 3.2.12.0

You will note the ones that are updates at the bottom (usually)

however, for this one it is as simple as changing

this...

#include <GuiConstants.au3>

to this..

#include <GuiConstantsEx.au3>

#include <WindowsConstants.au3>

8)

NEWHeader1.png

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