foozoor

GUI application that doesn't resize properly

6 posts in this topic

#1 ·  Posted (edited)

I have a problem with my little gui application that doesn't resize properly.

Here is the current code:

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


InitGui()


Func InitGui()

    Opt("GUICoordMode", 0)

    GUICreate("TestApplication", 320, 268, -1, -1, $WS_SIZEBOX)
    GUISetBkColor(0x00E0FFFF)

    Local $idList = GUICtrlCreateListView("Name|Category|Action|Description", 8, 8, 304, 200)
    GUICtrlSetResizing($idList, $GUI_DOCKLEFT + $GUI_DOCKRIGHT + $GUI_DOCKTOP + $GUI_DOCKBOTTOM)

    Local $idProgress = GUICtrlCreateProgress(-1, 208, 220, 20)
    GUICtrlSetResizing($idProgress, $GUI_DOCKAUTO + $GUI_DOCKLEFT + $GUI_DOCKBOTTOM + $GUI_DOCKHEIGHT)

    Local $idBtn = GUICtrlCreateButton('OK', 227, -1, 78, 20)
    GUICtrlSetResizing($idBtn, $GUI_DOCKAUTO + $GUI_DOCKRIGHT + $GUI_DOCKBOTTOM + $GUI_DOCKHEIGHT)

    GUISetState(@SW_SHOW)

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop

        EndSwitch
    WEnd

EndFunc

Here is what I get when I start the application:

6uIvnb0.png

Here is what I get when I resize the application:

eRI3iDM.png

As you can see there are some weird problems:

First why my button is smaller than my progress bar?
They have the same heigh! How to solve this?

And how to keep 8px between the progress bar and my button after resize?

Thank you in advance for your precious help.

Edited by foozoor

Share this post


Link to post
Share on other sites



 foozoor,

Quote

why my button is smaller than my progress bar?

Because button controls have a small border - a Windows "feature".

Quote

how to keep 8px between the progress bar and my button after resize?

I tend to use a WM_SIZE handler in these situations rather than GUICtrlSetResizing as the latter never seems to work correctly for complex GUIs:

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

Global $hGUI, $idProgress, $idBtn

InitGui()


Func InitGui()

    Opt("GUICoordMode", 0)

    $hGUI = GUICreate("TestApplication", 320, 268, -1, -1, $WS_SIZEBOX)
    GUISetBkColor(0x00E0FFFF)

    Local $idList = GUICtrlCreateListView("Name|Category|Action|Description", 8, 8, 304, 200)
    GUICtrlSetResizing($idList, $GUI_DOCKLEFT + $GUI_DOCKRIGHT + $GUI_DOCKTOP + $GUI_DOCKBOTTOM)

    $idProgress = GUICtrlCreateProgress(-1, 208, 220, 20)
    GUICtrlSetResizing($idProgress, $GUI_DOCKLEFT + $GUI_DOCKBOTTOM + $GUI_DOCKHEIGHT)

    $idBtn = GUICtrlCreateButton('OK', 227, -1, 78, 20)

    GUISetState(@SW_SHOW)

    GUIRegisterMsg($WM_SIZING, "_WM_SIZE")

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
        EndSwitch
    WEnd

EndFunc

Func _WM_SIZE($hWnd, $iMsg, $wParam, $lParam)

    ; Get new sizes & positions for GUI and progress
    $aWinPos = WinGetClientSize($hGUI)
    $aCtrlPos = ControlGetPos($hGUI, "", $idProgress)
    ; Calculate required button location and width
    $iButton_X = $aCtrlPos[0] + $aCtrlPos[2] + 8
    $iButton_Y = $aCtrlPos[1]
    $iButtonWidth = $aWinPos[0] - $iButton_X - 8
    ; Move button
    ControlMove($hGUI, "", $idBtn, $iButton_X, $iButton_Y, $iButtonWidth, 20)

EndFunc

Please ask if you have any questions.

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
Quote

I tend to use a WM_SIZE handler in these situations rather than GUICtrlSetResizing as the latter never seems to work correctly for complex GUIs

I didn't know my gui was that complex.;)

Maybe should I use one control by line to avoid these kind of problems?

I tried your code but it seems to be a little bit buggy:

7fITakd.gif

Share this post


Link to post
Share on other sites

foozoor,

The GUICtrlResizing functions do a great job most of the time, but as soon as controls do not match up with the anchors (edges and midpoints) they can get a bit flaky. I would class any such GUI as "complex" for resizing purposes, based on the location rather then the number of controls.

Sorry if you find the code buggy - it works fine on my Win7 machine.

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
Quote

Sorry if you find the code buggy - it works fine on my Win7 machine.

Ok I found what went wrong, it seems it doesn't work with "Adjust for best performance" in performance options.

TsogWs7.png

Your code works great with default performance options! Thanks you!

1 person likes this

Share this post


Link to post
Share on other sites

foozoor,

My pleasure, as always.

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

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