Jump to content

How to resize the GUI


ChrisMasc
 Share

Recommended Posts

Hello everybody.

I've created a Gui which lists all SQL Databases from entire user Input and will create a Checkbox for each Database among each other.

My GUI is created with GUICreate("Input Parameters", 500, $height, @DesktopWidth / 2 - 300, @DesktopHeight /2 -250, -1, 0x00000018)

Now I want to resize the height of the GUI by means of the Number of Results from Database Query. So the GUI Height should expand with each created Checkbox.

Have anyone a solution for my problem.

Many Thanks in advance.

Best regards,

Chris

Link to comment
Share on other sites

  • Moderators

ChrisMasc,

Look at WinMove in the Help file. Not the most intuitive place to look, I agree, but that is where you need to go!

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

do for ... next

and for ever checkbox you make, make $x += 20 then do the winmove with $x

do guess and check for the 20 value, you may need to make it 21, or something around that

Edited by billthecreator

[font=Microsoft Sans Serif]My Scripts: From Most recent to least.[/font]Countdown GUI | QLOCK TWO | FlipClock | Slot Machine My UDF:_GenerateRandomNoRepeat | _GuiSnap

Link to comment
Share on other sites

Hi,

#include <GUIConstantsEx.au3>

Global $hGui, $ChkBox[1], $Msg, $WGP

$hGui = GUICreate("", 135, 25)
$ChkBox[0] = GUICtrlCreateCheckbox("Add another checkbox", 5, 5, 125, 15)
GUICtrlSetResizing(-1, $GUI_DOCKMENUBAR)
GUISetState()

While 1
    $Msg = GUIGetMsg()
    Switch $Msg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $ChkBox[0] To $ChkBox[UBound($ChkBox) - 1]
            $WGP = WinGetPos($hGui)
            If GUICtrlRead($Msg) = $GUI_CHECKED Then
                ReDim $ChkBox[UBound($ChkBox) + 1]
                $ChkBox[UBound($ChkBox) - 1] = GUICtrlCreateCheckbox("Add another checkbox", 5, ((UBound($ChkBox) - 1) * 25) + 5, 125, 15)
                GUICtrlSetResizing(-1, $GUI_DOCKMENUBAR)
                If UBound($ChkBox) - 1 >= 2 Then GUICtrlSetState($ChkBox[UBound($ChkBox) - 3], $GUI_DISABLE)
                WinMove($hGui, "", Default, Default, Default, $WGP[3] + 25)
            Else
                GUICtrlDelete($ChkBox[UBound($ChkBox) - 1])
                If UBound($ChkBox) - 1 >= 2 Then GUICtrlSetState($ChkBox[UBound($ChkBox) - 3], $GUI_ENABLE)
                ReDim $ChkBox[UBound($ChkBox) - 1]
                WinMove($hGui, "", Default, Default, Default, $WGP[3] - 25)
            EndIf
    EndSwitch
WEnd

Cheers

Edited by smashly
Link to comment
Share on other sites

  • 2 weeks later...

Hi smashly,

Many Thanks for your great and easy Solution. But i've still one quetsion there. I have some Labels in my GUI. Every time i resize my GUI the Labels are changing its Position which is related to the whole GUI Size. The Labels schould be placed always on the same Position no matter how often the Gui is resized. Is there any Posibility for this?

To see my Problem test the script below. I've only added line Number 4 (GuiCtrlCreateLabel)

Thanks in advance

Chris

#include <GUIConstantsEx.au3>

Global $hGui, $ChkBox[1], $Msg, $WGP

$hGui = GUICreate("", 335, 50)

GUICtrlCreateLabel("Test Text schould be placed on same position", 150, 10)

$ChkBox[0] = GUICtrlCreateCheckbox("Add another checkbox", 5, 5, 125, 15)

GUICtrlSetResizing(-1, $GUI_DOCKMENUBAR)

GUISetState()

While 1

$Msg = GUIGetMsg()

Switch $Msg

Case $GUI_EVENT_CLOSE

Exit

Case $ChkBox[0] To $ChkBox[uBound($ChkBox) - 1]

$WGP = WinGetPos($hGui)

If GUICtrlRead($Msg) = $GUI_CHECKED Then

ReDim $ChkBox[uBound($ChkBox) + 1]

$ChkBox[uBound($ChkBox) - 1] = GUICtrlCreateCheckbox("Add another checkbox", 5, ((UBound($ChkBox) - 1) * 25) + 5, 125, 15)

GUICtrlSetResizing(-1, $GUI_DOCKMENUBAR)

If UBound($ChkBox) - 1 >= 2 Then GUICtrlSetState($ChkBox[uBound($ChkBox) - 3], $GUI_DISABLE)

WinMove($hGui, "", Default, Default, Default, $WGP[3] + 25)

Else

GUICtrlDelete($ChkBox[uBound($ChkBox) - 1])

If UBound($ChkBox) - 1 >= 2 Then GUICtrlSetState($ChkBox[uBound($ChkBox) - 3], $GUI_ENABLE)

ReDim $ChkBox[uBound($ChkBox) - 1]

WinMove($hGui, "", Default, Default, Default, $WGP[3] - 25)

EndIf

EndSwitch

WEnd

Link to comment
Share on other sites

Hi, your welcome

Use GUICtrlSetResizing() for each control that you want to tell how to behave.

In AutoIt help file -> Function Reference -> Gui Reference -> Gui Control Update -> GUICtrlSetResizing()

There you can find the Docking Values and how the function can be used.

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

Global $hGui, $ChkBox[1], $Msg, $WGP
$hGui = GUICreate("", 335, 50, -1, -1, $WS_OVERLAPPEDWINDOW) 
GUICtrlCreateLabel("Test Text stays in the same position", 150, 10)
GUICtrlSetResizing(-1, BitOr($GUI_DOCKTOP, $GUI_DOCKLEFT, $GUI_DOCKSIZE)); <- Set the resizing for the control
$ChkBox[0] = GUICtrlCreateCheckbox("Add another checkbox", 5, 5, 125, 15)
GUICtrlSetResizing(-1, BitOr($GUI_DOCKTOP, $GUI_DOCKLEFT, $GUI_DOCKSIZE)); <- Set the resizing for the control
GUISetState()

While 1
    $Msg = GUIGetMsg()
    Switch $Msg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $ChkBox[0] To $ChkBox[UBound($ChkBox) - 1]
            $WGP = WinGetPos($hGui)
            If GUICtrlRead($Msg) = $GUI_CHECKED Then
                ReDim $ChkBox[UBound($ChkBox) + 1]
                $ChkBox[UBound($ChkBox) - 1] = GUICtrlCreateCheckbox("Add another checkbox", 5, ((UBound($ChkBox) - 1) * 25) + 5, 125, 15)
                GUICtrlSetResizing(-1, BitOr($GUI_DOCKTOP, $GUI_DOCKLEFT, $GUI_DOCKSIZE)) ; <- Set the resizing for the control
                If UBound($ChkBox) - 1 >= 2 Then GUICtrlSetState($ChkBox[UBound($ChkBox) - 3], $GUI_DISABLE)
                WinMove($hGui, "", Default, Default, Default, $WGP[3] + 25)
            Else
                GUICtrlDelete($ChkBox[UBound($ChkBox) - 1])
                If UBound($ChkBox) - 1 >= 2 Then GUICtrlSetState($ChkBox[UBound($ChkBox) - 3], $GUI_ENABLE)
                ReDim $ChkBox[UBound($ChkBox) - 1]
                WinMove($hGui, "", Default, Default, Default, $WGP[3] - 25)
            EndIf
    EndSwitch
WEnd
Cheers
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...