Sign in to follow this  
Followers 0
Kaso

help resizing a gui using a button control

5 posts in this topic

I want to start my gui at a particular size. When I press a button I want the gui to change size to make room for the new information displayed. I assume its a combination for guicreate and gui delete but I could not get it to work. Any Help would be appreciated

GUICreate("Name...",100,100); will create a dialog box that when displayed is centered
GUISetState(@SW_SHOW)   ; will display an empty dialog box
$btn1 = GUICtrlCreateButton("test",10,10)
While 1
$msg = GUIGetMsg()
if $msg = $btn1 Then
Code to change the gui size
EndIf
If $msg = $GUI_EVENT_CLOSE Then ExitLoop
WEnd

Share this post


Link to post
Share on other sites



Maybe this

#include <GUIConstants.au3>
GUICreate("Name...",100,100); will create a dialog box that when displayed is centered
GUISetState(@SW_SHOW)   ; will display an empty dialog box
$btn1 = GUICtrlCreateButton("test",10,10)
While 1
$msg = GUIGetMsg()
if $msg = $btn1 Then
$POS = WinGetPos("Name...")
WinMove("Name...", "", $POS[0], $POS[1], 200, 200)
EndIf
If $msg = $GUI_EVENT_CLOSE Then ExitLoop
WEnd

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

this is a demo i wrote not long ago..

maybe you could use this idea

#Include <GUIConstants.au3>

; Default values for main gui
$title = "My Shrink"
$width = 500
$height = 400
$left = 300 
$top = 300 


; Create the main gui 
$gui = GuiCreate($title, $width, $height, $left, $top, $WS_CLIPSIBLINGS + $WS_SYSMENU, $WS_EX_ACCEPTFILES + $WS_EX_TOOLWINDOW + $WS_EX_TOPMOST)

; create the buttons then hide or expand the window ( your choice )
$xpand = GUICtrlCreateButton( "Xpand the window", 200, 110, 100, 20)
$hide = GUICtrlCreateButton( "Hide controls", 100, 310, 100, 20)
$dummy = GUICtrlCreateButton( "Dummy control", 200, 310, 100, 20)
$show = GUICtrlCreateButton( "Show controls", 300, 310, 100, 20)

; set and hide gui
GuiSetState(@SW_HIDE)

; hide controls
GUICtrlSetState($hide, $GUI_HIDE )
GUICtrlSetState($dummy, $GUI_HIDE )
GUICtrlSetState($show, $GUI_HIDE )
WinMove($title, "",  $left, $top, $width, 100)
GuiSetState(@SW_SHOW)

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            Exit
        Case $msg = $xpand
            Set_xpand()
        Case $msg = $hide
            Set_hide()
        Case $msg = $show
            Set_show()  
    EndSelect
WEnd


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

func Set_xpand()
    If GUICtrlRead($xpand) = "Xpand the window" Then
        GUICtrlSetState($xpand, $GUI_HIDE )
        $inc = 100
        While $inc < 400
            $inc = $inc + 1
            WinMove($title, "",  $left, $top, $width, $inc)
        WEnd
        Set_show()  
        GUICtrlSetData($xpand, "Shrink the window")
    Else
        Set_hide()
        GUICtrlSetState($show, $GUI_HIDE )
        $inc = 400
        While $inc > 100
            $inc = $inc - 1
            WinMove($title, "",  $left, $top, $width, $inc)
        WEnd
        GUICtrlSetState($xpand, $GUI_SHOW )
        GUICtrlSetData($xpand, "Xpand the window")
    EndIf
EndFunc

Func Set_hide()
    GUICtrlSetState($xpand, $GUI_HIDE )
    GUICtrlSetState($dummy, $GUI_HIDE )
    GUICtrlSetState($hide, $GUI_HIDE )
EndFunc

Func Set_show()
    GUICtrlSetState($xpand, $GUI_SHOW )
    GUICtrlSetState($dummy, $GUI_SHOW )
    GUICtrlSetState($hide, $GUI_SHOW )
    GUICtrlSetState($show, $GUI_SHOW )
EndFunc

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

that does work, thank you. But In the resizing it also moved the inputs and buttons in my GUI. Is there a style or something to add? so that they don't move

Share this post


Link to post
Share on other sites

yes...

#include <GUIConstants.au3>

GUICreate("My GUI Button") ; will create a dialog box that when displayed is centered.

Opt("GUICoordMode",2); this is one of many special, coordinates modes, this one is based on 2, the cell position.
GUICtrlCreateButton ("OK",  10, 30, 50); this creates the button, the first text is what is displayed on the button.
; the second is how far from the left, the third how far from the top, fourth is how long the button is.

; this button is based on the cell coordinates, of the previous button.
GUICtrlCreateButton ( "Cancel",  0, -1) 

GUISetState ()    ; will display an  dialog box with the 2 buttons.

; Run the GUI until the dialog is closed.
While 1
    $msg = GUIGetMsg(); this checks for a message/input from the GUI.
    
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop; this states, on an exit event, exit the loop.
Wend

OR....

if you notice in my second script .... i created the buttons ( etc ) first then sized the window so they were out of the gui... when the gui is expanded... the buttons fit/show in the larger gui

8)


NEWHeader1.png

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