Jump to content

SetResizing misaligned


Terenz
 Share

Recommended Posts

Guys, check this:

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

GUICreate("Form 1", 636, 530, -1, -1, BitOR($GUI_SS_DEFAULT_GUI, $WS_MAXIMIZEBOX, $WS_SIZEBOX))

#region First Group
GUICtrlCreateGroup("", 510, 456, 117, 50)
GUICtrlSetResizing(-1, $GUI_DOCKRIGHT + $GUI_DOCKBOTTOM + $GUI_DOCKSIZE)
GUICtrlCreateGroup("", -99, -99, 1, 1)

GUICtrlCreateGroup("", 8, 456, 498, 50)
GUICtrlSetResizing(-1, $GUI_DOCKLEFT + $GUI_DOCKRIGHT + $GUI_DOCKBOTTOM + $GUI_DOCKHEIGHT)
GUICtrlCreateGroup("", -99, -99, 1, 1)
#endregion

#region Second Group
GUICtrlCreateGroup("", 8, 409, 268, 50)
GUICtrlSetResizing(-1, $GUI_DOCKLEFT + $GUI_DOCKBOTTOM + $GUI_DOCKHEIGHT)
GUICtrlCreateGroup("", -99, -99, 1, 1)

GUICtrlCreateGroup("", 280, 409, 347, 50)
GUICtrlSetResizing(-1, $GUI_DOCKRIGHT + $GUI_DOCKBOTTOM + $GUI_DOCKHEIGHT)
GUICtrlCreateGroup("", -99, -99, 1, 1)
#endregion

GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

Run and maximize the window. The space between the two groups of the #region Second Group is different from the normal window ( the first group instead is equal in both cases! ) and this is a problem for me because the control inside that group is misaligned and doesn't fit

In this image, the "green" is the normal window of #region Second Group, in "red"  when is maximized and you can see the difference in pixel:

205fn0y.jpg

There is a way to solve or better align the groups? Thanks

Edited by Terenz

Nothing is so strong as gentleness. Nothing is so gentle as real strength

 

Link to comment
Share on other sites

  • Moderators

Terenz ,

 

this is a problem for me because the control inside that group is misaligned and doesn't fit

So why not get the actual size of the group and resize the control to fit? :huh:

And you do realise that you have different resizing parameters for the 2 rows? So it is hardly surprising that they resize differently. I think you will have to resize the second group manually if you want the spacing to remain constant:

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

$bResized = False

$hGUI = GUICreate("Form 1", 636, 530, -1, -1, BitOR($GUI_SS_DEFAULT_GUI, $WS_MAXIMIZEBOX, $WS_SIZEBOX))
GUISetBkColor(0xCCffCC)

#region First Group
$cGroup_1 = GUICtrlCreateGroup("1", 510, 456, 117, 50)
GUICtrlSetResizing(-1, $GUI_DOCKRIGHT + $GUI_DOCKBOTTOM + $GUI_DOCKSIZE)
;GUICtrlCreateGroup("", -99, -99, 1, 1) ; No need if you immediately create another group

$cGroup_2 = GUICtrlCreateGroup("2", 8, 456, 498, 50)
GUICtrlSetResizing(-1, $GUI_DOCKLEFT + $GUI_DOCKRIGHT + $GUI_DOCKBOTTOM + $GUI_DOCKHEIGHT)
;GUICtrlCreateGroup("", -99, -99, 1, 1)
#endregion

#region Second Group
$cGroup_3 = GUICtrlCreateGroup("3", 8, 409, 268, 50)
GUICtrlSetResizing(-1, $GUI_DOCKLEFT + $GUI_DOCKBOTTOM + $GUI_DOCKHEIGHT)
;GUICtrlCreateGroup("4", -99, -99, 1, 1)

$cGroup_4 = GUICtrlCreateGroup("4", 280, 409, 347, 50)
;GUICtrlSetResizing(-1, $GUI_DOCKRIGHT + $GUI_DOCKBOTTOM + $GUI_DOCKHEIGHT)
GUICtrlCreateGroup("", -99, -99, 1, 1) ; But now you need it
#endregion

GUISetState(@SW_SHOW)

; Get spacing between 1 & 2
$aPos_1 = ControlGetPos($hGUI, "", $cGroup_1)
$aPos_2 = ControlGetPos($hGUI, "", $cGroup_2)
$iSpacing = $aPos_1[0] - ($aPos_2[0] + $aPos_2[2])

GUIRegisterMsg($WM_SIZE, "_WM_SIZE")

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch

    If $bResized Then
        $aClient = WinGetClientSize($hGUI)
        $aPos_3 = ControlGetPos($hGUI, "", $cGroup_3)
        ; Set the same spacing
        Local $iX_4 = $aPos_3[0] + $aPos_3[2] + $iSpacing
        ; Determine correct width
        Local $iW_4 = $aClient[0] - $iX_4 - 10
        ; Resize the control
        ControlMove($hGUI, "", $cGroup_4, $iX_4, $aPos_3[1], $iW_4, $aPos_3[3])

        $bResized = False
    EndIf

WEnd

Func _WM_SIZE($hWnd, $iMsg, $iwParam, $ilParam)

    $bResized = True

EndFunc
But you suprised us all yesterday with the "Maximize/Restore" button - see if you can do it again today! ;)

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

Yes i know they have different resizing parameters. I don't think today i'll surprise you, the only thing i know is GUICtrlSetResizing is limited. I don't have idea how GUICtrlSetResizing work, the last avaible source of autoit don't have it.

Anyway i'll post a couple of example of many, many optional parameter then the Resizing function miss:

Control Positioning and Sizing using a C++ Helper Class

 
From one of the article: "So far, the anchors of the controls always referred to the edges of the main dialog window. However, there are cases where this solution is not flexible enough" etc.
 
P.S. In  _WM_SIZE $bResized become True only when i'll release the mouse from the "manual" resizing, so ControlMove apply only when the resizing is finished, instead GUICtrlSetResizing is in "real time"
Edited by Terenz

Nothing is so strong as gentleness. Nothing is so gentle as real strength

 

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...