DigDeep

Expand and Contract Lable with buttons

3 posts in this topic

#1 ·  Posted

Do we have any example of this already or can someone help to get this please?

The GUI Form should not expand / Contract. It should be only the Lable and buttons to Hide / Unhide.

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form2 = GUICreate("Form2", 631, 494, 776, 200)
$Label1 = GUICtrlCreateLabel("Label1", 80, 16, 476, 73)

$Button1 = GUICtrlCreateButton("Button1", 112, 64, 75, 25)
$Button2 = GUICtrlCreateButton("Button2", 112, 168, 75, 25)
GUICtrlSetState(-1, $GUI_HIDE)
$Button3 = GUICtrlCreateButton("Button3", 120, 272, 75, 25)
GUICtrlSetState(-1, $GUI_HIDE)
$Button4 = GUICtrlCreateButton("Button4", 120, 352, 75, 25)
GUICtrlSetState(-1, $GUI_HIDE)

$Close = GUICtrlCreateButton("Close", 288, 440, 75, 25)
GUICtrlSetState(-1, $GUI_HIDE)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
            
        Case $Button1
            ; This will expand the Lable until 457 height and show the buttons 2, 3, 4 and Close
        
        Case $Close
            ;This will contract the Lable back to 73 height and hide the buttons Close, 4, 3 and 2
            
    EndSwitch
WEnd

Share this post


Link to post
Share on other sites



#2 ·  Posted

DigDeep,

You do not need to dig too far down:

#include <GUIConstantsEx.au3>

$Form2 = GUICreate("Form2", 631, 494, 776, 200)

$Label1 = GUICtrlCreateLabel("Label1", 80, 16, 476, 73)
GUICtrlSetState(-1, $GUI_DISABLE) ; Otherwise Button 1 will not work because of the overlap
GUICtrlSetBkColor(-1, 0xFFCCCC)

$Button1 = GUICtrlCreateButton("Button1", 112, 64, 75, 25)
$Button2 = GUICtrlCreateButton("Button2", 112, 168, 75, 25)
GUICtrlSetState(-1, $GUI_HIDE)
$Button3 = GUICtrlCreateButton("Button3", 120, 272, 75, 25)
GUICtrlSetState(-1, $GUI_HIDE)
$Button4 = GUICtrlCreateButton("Button4", 120, 352, 75, 25)
GUICtrlSetState(-1, $GUI_HIDE)

$Close = GUICtrlCreateButton("Close", 288, 440, 75, 25)
GUICtrlSetState(-1, $GUI_HIDE)

GUISetState(@SW_SHOW)

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit

        Case $Button1
            ControlMove($Form2, "", $Label1, 80, 16, 476, 457)
            For $i = $Button2 To $Close
                GUICtrlSetState($i, $GUI_SHOW)
            Next
            ; This will expand the Lable until 457 height and show the buttons 2, 3, 4 and Close

        Case $Close
            ControlMove($Form2, "", $Label1, 80, 16, 476, 73)
            For $i = $Button2 To $Close
                GUICtrlSetState($i, $GUI_HIDE)
            Next
            ;This will contract the Lable back to 73 height and hide the buttons Close, 4, 3 and 2

    EndSwitch
WEnd

Note that the trick using the ControlIDs as the loop limiters will only work if the controls are created consecutively.

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

#3 ·  Posted

thanks

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