Jump to content

Recommended Posts

Hello there.

I'm currently trying to solve a problem I'm having with the GUIExtender-UDF by Melba23, but I can't relly get the hang of it and I think I need someone to straightening this out for me.

What I'm trying to achieve is a "menu-ish" GUI with buttons that takes you deeper and further into the menues, and aswell to have a back-button which lets you return to the previously extended section. I've done this before with the use of multiple child GUIs being hidden/shown, but that was taking too much out of the computer as I'll be working with 20+ windows/sections.

What I've been testing so far is the following:

#include "GUIExtender.au3"
#include <GUIConstantsEx.au3>

$GUI = GUICreate("Test",500,300,-1,-1)

_GUIExtender_Init($GUI, 1)
$Back = GUICtrlCreateButton("Back",50,20,50,25)
$Window1 = _GUIExtender_Section_Start(50, 500)
_GUIExtender_Section_Action($Window1)
$Button1 = GUICtrlCreateButton("Button1",100,100,100,30)
_GUIExtender_Section_End()
$Window2 = _GUIExtender_Section_Start(50, 500)
_GUIExtender_Section_Action($Window2)
$Button2 = GUICtrlCreateButton("Button2",150,100,100,30)
_GUIExtender_Section_End()
$Window3 = _GUIExtender_Section_Start(50, 500)
_GUIExtender_Section_Action($Window3)
$Button3 = GUICtrlCreateButton("Button3",250,100,100,30)
_GUIExtender_Section_End()
_GUIExtender_Section_Extend(0, False,0)
_GUIExtender_Section_Extend($Window1, True,0)
GUISetState()
while 1

Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
Exit
case $Button1
_GUIExtender_Section_Extend(0, False,0)
_GUIExtender_Section_Extend($Window2, True,0)
case $Button2
_GUIExtender_Section_Extend(0, False,0)
_GUIExtender_Section_Extend($Window3, True,0)
case $Button3
_GUIExtender_Section_Extend(0, False,0)
_GUIExtender_Section_Extend($Window1, True,0)
case $Back
EndSwitch
WEnd

When I just had 2 sections created the extend/retract worked as I think it should, which is hideing one and showing the other. But as I added the 3rd section by using the same terms as the precious 2 it's now having both section 2 & 3 extended at same time and somewhat linking them togeather, idk.

I've tried to get the hang of this by the examples provided by Melba and by the UDF itself, but it seem like I got something wrong..

Best regards,

zvvyt

Link to comment
Share on other sites

  • Moderators

zvvyt,

I think this is what you need: ;)

#include <GUIConstantsEx.au3>

#include "GUIExtender.au3"

; Cretae an array to hold the section index numbers
Global $aSection[4]

$hGUI = GUICreate("Test", 600, 300)

_GUIExtender_Init($hGUI, 1)

$aSection[1] = _GUIExtender_Section_Start(0, 200)
_GUIExtender_Section_Action($aSection[1])
$cBack = GUICtrlCreateButton("Back", 50, 20, 100, 30)
$cButton1 = GUICtrlCreateButton("Open Section 2", 50, 100, 100, 30)
_GUIExtender_Section_End()

; Look at the parameters - they are the start point and the width.  The first is the sum of the parameters for the section before
$aSection[2] = _GUIExtender_Section_Start(200, 200)
_GUIExtender_Section_Action($aSection[2])
$cButton2 = GUICtrlCreateButton("Open section 3", 250, 100, 100, 30)
_GUIExtender_Section_End()

$aSection[3] = _GUIExtender_Section_Start(400, 200)
_GUIExtender_Section_Action($aSection[3])
$cButton3 = GUICtrlCreateButton("Close All", 450, 100, 100, 30)
_GUIExtender_Section_End()

; Close all sections and then open the first
_GUIExtender_Section_Extend(0, False)
_GUIExtender_Section_Extend($aSection[1])

GUISetState()
While 1

    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $cButton1
            ; Open the next section
            _GUIExtender_Section_Extend($aSection[2])
        Case $cButton2
            ; Open the next section
            _GUIExtender_Section_Extend($aSection[3])
        Case $cButton3
            ; Close all sections and then open the first
            _GUIExtender_Section_Extend(0, False)
            _GUIExtender_Section_Extend($aSection[1])
        Case $cBack
            ; Look to see which is the last section opened
            For $i = 3 To 2 Step -1
                If _GUIExtender_Section_State($aSection[$i]) Then
                    ; And close it
                    _GUIExtender_Section_Extend($aSection[$i], False)
                    ExitLoop
                EndIf
            Next
    EndSwitch
WEnd

Is that what you wanted? :huh:

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

Hello, Melba! I've been expecting you x)

Is that what you wanted? :huh:

No, not really.

How I would like it is all sections are layered at the same spot, so that the button hides that current "layer" and reveals the next/desired one. Just like how you browse through folders/directories on your computer, more or less.

Something like this, but w/ sections instead of multible child GUIs

#include <WindowsConstants.au3>
#include <winapi.au3>
#include <GUIConstantsEx.au3>

$GUI = GUICreate("Main/Parent",400,500,-1,-1)
GUICtrlCreateLabel("This is on the parent GUI",150,50,100,25)

$Child1 = GUICreate("Child GUI 1",400,450,0,50,$ws_popup,bitor($WS_EX_MDICHILD, $WS_EX_LAYERED),$GUI)
GUISetBkColor(0xacbdef,$Child1)
_WINAPI_SetLayeredWindowAttributes($Child1, 0xacbdef, 255)
GUICtrlCreateLabel("This is the 1st child GUI",150,50,100,25)
$Child1_Button_To_Child2 = GUICtrlCreateButton("To child #2",150,100,100,25)
$Child1_Button_To_Child3 = GUICtrlCreateButton("To child #3",150,200,100,25)

$Child2 = GUICreate("Child GUI 2",400,450,0,50,$ws_popup,bitor($WS_EX_MDICHILD, $WS_EX_LAYERED),$GUI)
GUISetBkColor(0xacbdef,$Child2)
_WINAPI_SetLayeredWindowAttributes($Child2, 0xacbdef, 255)
GUICtrlCreateLabel("This is the 2nd child GUI",150,50,100,25)
$Child2_Button_To_Child1 = GUICtrlCreateButton("To child #1",150,100,100,25)
$Child2_Button_To_Child3 = GUICtrlCreateButton("To child #3",150,200,100,25)

$Child3 = GUICreate("Child GUI 3",400,450,0,50,$ws_popup,bitor($WS_EX_MDICHILD, $WS_EX_LAYERED),$GUI)
GUISetBkColor(0xacbdef,$Child3)
_WINAPI_SetLayeredWindowAttributes($Child3, 0xacbdef, 255)
GUICtrlCreateLabel("This is the 3rd child GUI",150,50,100,25)
$Child3_Button_To_Child1 = GUICtrlCreateButton("To child #1",150,100,100,25)
$Child3_Button_To_Child2 = GUICtrlCreateButton("To child #2",150,200,100,25)

GUISetState(@sw_show,$GUI)
GUISetState(@sw_show,$Child1)
while 1
    $msg = GUIGetMsg()
    select
        Case $msg = $GUI_EVENT_CLOSE
            Exit
        case $msg = $Child2_Button_To_Child1 or $msg = $Child3_Button_To_Child1
            GUISetState(@sw_hide,$Child1)
            GUISetState(@sw_hide,$Child2)
            GUISetState(@sw_hide,$Child3)
            GUISetState(@sw_show,$Child1)
        case $msg = $Child1_Button_To_Child2 or $msg = $Child3_Button_To_Child2
            GUISetState(@sw_hide,$Child1)
            GUISetState(@sw_hide,$Child2)
            GUISetState(@sw_hide,$Child3)
            GUISetState(@sw_show,$Child2)
        case $msg = $Child2_Button_To_Child3 or $msg = $Child1_Button_To_Child3
            GUISetState(@sw_hide,$Child1)
            GUISetState(@sw_hide,$Child2)
            GUISetState(@sw_hide,$Child3)
            GUISetState(@sw_show,$Child3)
    EndSelect
WEnd

The winapi is because I'll be having the sections on a transparent child window and a background on the parent.

Tell me if I'm not making any sense!

Best regards,

Link to comment
Share on other sites

  • Moderators

zvvyt,

all sections are layered at the same spot, so that the button hides that current "layer" and reveals the next/desired one

More like this then: :)

#include <GUIConstantsEx.au3>

#include "GUIExtender.au3"

; Create an array to hold the section index numbers
Global $aSection[4]

$hGUI = GUICreate("Section 1", 600, 300)

_GUIExtender_Init($hGUI, 1)

$aSection[1] = _GUIExtender_Section_Start(0, 200)
_GUIExtender_Section_Action($aSection[1])
$cBack1 = GUICtrlCreateButton("Back", 50, 20, 100, 30)
$cButton1 = GUICtrlCreateButton("Open Section 2", 50, 100, 100, 30)
_GUIExtender_Section_End()

; Look at the parameters - they are the start point and the width.  The first is the sum of the parameters for the section before
$aSection[2] = _GUIExtender_Section_Start(200, 200)
_GUIExtender_Section_Action($aSection[2])
$cBack2 = GUICtrlCreateButton("Back", 250, 20, 100, 30)
$cButton2 = GUICtrlCreateButton("Open section 3", 250, 100, 100, 30)
_GUIExtender_Section_End()

$aSection[3] = _GUIExtender_Section_Start(400, 200)
_GUIExtender_Section_Action($aSection[3])
$cBack3 = GUICtrlCreateButton("Back", 450, 20, 100, 30)
$cButton3 = GUICtrlCreateButton("Close All", 450, 100, 100, 30)
_GUIExtender_Section_End()

; Close all sections and then open the first
_GUIExtender_Section_Extend(0, False)
_GUIExtender_Section_Extend($aSection[1])

GUISetState()
While 1

    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $cButton1
            ; Open the next section
            _GUIExtender_Section_Extend(0, False)
            _GUIExtender_Section_Extend($aSection[2])
            WinSetTitle($hGUI, "", "Section 2")
        Case $cButton2
            ; Open the next section
            _GUIExtender_Section_Extend(0, False)
            _GUIExtender_Section_Extend($aSection[3])
            WinSetTitle($hGUI, "", "Section 3")
        Case $cButton3
            ; Close all sections and then open the first
            _GUIExtender_Section_Extend(0, False)
            _GUIExtender_Section_Extend($aSection[1])
            WinSetTitle($hGUI, "", "Section 1")
        Case $cBack1, $cBack2, $cBack3
            ; Look to see which is the last section opened
            For $i = 3 To 2 Step -1
                If _GUIExtender_Section_State($aSection[$i]) Then
                    ; Close it
                    _GUIExtender_Section_Extend($aSection[$i], False)
                    ; And open the previous
                    _GUIExtender_Section_Extend($aSection[$i - 1])
                    ; Change the title
                    WinSetTitle($hGUI, "", "Section " & $i - 1)
                    ExitLoop
                EndIf
            Next
    EndSwitch
WEnd

Closer? :huh:

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

Closer? :huh:

Not only close, but exactly as i wanted it!

And the way you formed the "back"-function and putting the sections into an array was just spot on!

So what I did wrong was to set the _GUIExtender_Section_Start-parameter wrong? Must've gotten that wrong from the description in the UDF then >_<

And while we're at it, do you have any suggestion how to solve the back-function if I f.ex. got several "categories"?

Say I've got 2 main categories, "Names" and "Numbers" were "Names" have the subcategories "A", "B", "C" ... and "Numbers" got the subcats "1", "2", "3"...

Just need a hint or poke in the right direction, the script I think I can manage myself =)

Thanks once again!

Best regards,

zvvyt

Link to comment
Share on other sites

  • Moderators

zvvyt,

That was harder than I thought it should be - I will have another think about how you might do it this afternoon: :sweating:

#include <GUIConstantsEx.au3>

#include "GUIExtender.au3"

; Create an array to hold the section index numbers and button ControlIDs
Global $aSection[8], $aButton[8], $aBack[8]

$hGUI = GUICreate("Start", 1400, 300, @DesktopWidth / 2)

_GUIExtender_Init($hGUI, 1)

$aSection[1] = _GUIExtender_Section_Start(0, 200)
_GUIExtender_Section_Action($aSection[1])
$aButton[0] = GUICtrlCreateButton("Open Letters", 50, 100, 100, 30)
$aButton[1] = GUICtrlCreateButton("Open Numbers", 50, 150, 100, 30)
_GUIExtender_Section_End()

; Create the "Letters" sections
$aSection[2] = _GUIExtender_Section_Start(200, 200)
_GUIExtender_Section_Action($aSection[2])
$aBack[2] = GUICtrlCreateButton("Back", 250, 20, 100, 30)
$aButton[2] = GUICtrlCreateButton("Open 'Letters 2'", 250, 100, 100, 30)
_GUIExtender_Section_End()

$aSection[3] = _GUIExtender_Section_Start(400, 200)
_GUIExtender_Section_Action($aSection[3])
$aBack[3] = GUICtrlCreateButton("Back", 450, 20, 100, 30)
$aButton[3] = GUICtrlCreateButton("Open 'Letters 3'", 450, 100, 100, 30)
_GUIExtender_Section_End()

$aSection[4] = _GUIExtender_Section_Start(600, 200)
_GUIExtender_Section_Action($aSection[4])
$aBack[4] = GUICtrlCreateButton("Back", 650, 20, 100, 30)
$aButton[4] = GUICtrlCreateButton("Restart", 650, 100, 100, 30)
_GUIExtender_Section_End()

; Create the "Numbers" sections
$aSection[5] = _GUIExtender_Section_Start(800, 200)
_GUIExtender_Section_Action($aSection[5])
$aBack[5] = GUICtrlCreateButton("Back", 850, 20, 100, 30)
$aButton[5] = GUICtrlCreateButton("Open 'Numbers 2'", 850, 100, 100, 30)
_GUIExtender_Section_End()

$aSection[6] = _GUIExtender_Section_Start(1000, 200)
_GUIExtender_Section_Action($aSection[6])
$aBack[6] = GUICtrlCreateButton("Back", 1050, 20, 100, 30)
$aButton[6] = GUICtrlCreateButton("Open 'Numbers 3'", 1050, 100, 100, 30)
_GUIExtender_Section_End()

$aSection[7] = _GUIExtender_Section_Start(1200, 200)
_GUIExtender_Section_Action($aSection[7])
$aBack[7] = GUICtrlCreateButton("Back", 1250, 20, 100, 30)
$aButton[7] = GUICtrlCreateButton("Restart", 1250, 100, 100, 30)
_GUIExtender_Section_End()

; Close all sections and then open the first
_GUIExtender_Section_Extend(0, False)
_GUIExtender_Section_Extend($aSection[1])

GUISetState()

While 1

    $iMsg = GUIGetMsg()
    Switch $iMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case Else
            ; Check it is a valid ControlID as we have empty elements in the array which will fire on 0
            If $iMsg > 0 Then
                ; Now look at each section in turn
                For $i = 0 To 7
                    ; Look for "Forward" buttons
                    If $aButton[$i] = $iMsg Then
                        Switch $i
                            Case 0, 1
                                ; Close all sections
                                _GUIExtender_Section_Extend(0, False)
                                ; Open the first relevant section
                                $iSection = 2 + (3 * $i)
                                _GUIExtender_Section_Extend($aSection[$iSection])
                                ; Change title
                                If $i = 0 Then
                                    WinSetTitle($hGUI, "", "Letters 1")
                                Else
                                    WinSetTitle($hGUI, "", "Numbers 1")
                                EndIf
                            Case 2, 3, 5, 6
                                ; Close all sections
                                _GUIExtender_Section_Extend(0, False)
                                ; Open the next
                                _GUIExtender_Section_Extend($aSection[$i + 1])
                                ; Change title
                                If $i < 4 Then
                                    WinSetTitle($hGUI, "", "Letters " & $i)
                                Else
                                    WinSetTitle($hGUI, "", "Numbers " & $i - 3)
                                EndIf
                            Case 4, 7
                                ; Close all sections
                                _GUIExtender_Section_Extend(0, False)
                                ; Open the first
                                _GUIExtender_Section_Extend($aSection[1])
                                ; Change title
                                WinSetTitle($hGUI, "", "Start")
                        EndSwitch
                        ExitLoop
                    EndIf

                    ; Now look for "Back" buttons
                    If $aBack[$i] = $iMsg Then
                        ; Look to see which is the last section opened
                        For $j = 7 To 2 Step -1
                            If _GUIExtender_Section_State($aSection[$j]) = 1 Then
                                Switch $j
                                    Case 2, 5
                                        ; Close all sections
                                        _GUIExtender_Section_Extend(0, False)
                                        ; Open the first
                                        _GUIExtender_Section_Extend($aSection[1])
                                        ; Change title
                                        WinSetTitle($hGUI, "", "Start")
                                    Case 3, 4
                                        ; Close all sections
                                        _GUIExtender_Section_Extend(0, False)
                                        ; Open the previous
                                        _GUIExtender_Section_Extend($aSection[$j - 1])
                                        WinSetTitle($hGUI, "", "Letters " & $j - 2)
                                    Case 6, 7
                                        ; Close all sections
                                        _GUIExtender_Section_Extend(0, False)
                                        ; Open the previous
                                        _GUIExtender_Section_Extend($aSection[$j - 1])
                                        WinSetTitle($hGUI, "", "Numbers " & $j - 5)
                                EndSwitch
                                ExitLoop
                            EndIf
                        Next
                    EndIf
                Next
            EndIf
    EndSwitch

WEnd

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

That was harder than I thought it should be

Are you thinking about the back-function with this script?

Isn't it possible to just have an array or variable declared as you move further into the categories, and then have a _GUIExtender_Section_Extend($Last_category) to have the last one shown and so on?

And that "back"-part of your most recent code seem to work for that script at least =)

Best regards,

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

×
×
  • Create New...