Jump to content

Another Noob question


CMJ
 Share

Recommended Posts

I have a GUI interfacing with a SQLite db and everything is working great. Under two weeks from installing AutoIt to a functional program doing what I wanted. Fantastic!

Now i am looking to dress things up some and I need a nudge in the right direction. Let's say I have a GUI that has two controls - two ListViews - next to each other. How can I make the controls re-sizable so that if you drag the edge between the two controls one grows and the other shrinks? Like the Console area at the bottom of the SciTE window.

I have tried putting two child windows in a parent but when they are resized they overlap and that is not what I want. Can anyone point me to an example of this in action?

Thanks in advance.

cj

Link to comment
Share on other sites

GuiCtrlSetResizing() is a good place to start.

Thanks for the tip but I guess I need more than a tip. I have been using GUICtrlSetResizing to control how my controls behave when the window (the entire GUI) is resized. This is working as I expected. Can this function also be used to enable resizing of the actual control?

I will keep reading and see if I can find what I missed. Thanks again for the reply.

cj

Link to comment
Share on other sites

  • Moderators

CMJ,

This is a work in progress, but I thought you might be interested to see what I was up to! ;)

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

Global Const $SC_DRAGMOVE = 0xF012

$hGUI = GUICreate("Test", 500, 500)
GUISetState()

$aMain_Pos = WinGetPos($hGUI)
Global $iBorder = _WinAPI_GetSystemMetrics(8) ; Border width
Global $iBar = _WinAPI_GetSystemMetrics(4) ; Title bar height

$hGUI_Left = GUICreate("GUI_Left", 249, 500, -1, -1, $WS_POPUP, $WS_EX_MDICHILD, $hGUI)
$hLV_L = GUICtrlCreateListView("Col 10|Col 11", 10, 10, 230, 480)
GUICtrlSetResizing(-1, $GUI_DOCKAUTO)
WinMove($hGUI_Left, "", $aMain_Pos[0] + $iBorder, $aMain_Pos[1] + $iBorder + $iBar)
GUISetState()
$hGUI_Right = GUICreate("GUI_Right", 249, 500, -1, -1, $WS_POPUP, $WS_EX_MDICHILD, $hGUI)
$hLV_R = GUICtrlCreateListView("Col 10|Col 11", 10, 10, 230, 480)
GUICtrlSetResizing(-1,  $GUI_DOCKAUTO)
WinMove($hGUI_Right, "", $aMain_Pos[0] + $iBorder + 251, $aMain_Pos[1] + $iBorder + $iBar)
GUISetState()
$hGUI_Sep = GUICreate("GUI_Sep", 2, 500, -1, -1, $WS_POPUP, $WS_EX_MDICHILD, $hGUI)
GUISetBkColor(0x000000, $hGUI_Sep)
WinMove($hGUI_Sep, "", $aMain_Pos[0] + $iBorder + 249, $aMain_Pos[1] + $iBorder + $iBar)
GUISetState()

; Register message handlers
GUIRegisterMsg($WM_MOUSEMOVE, "_SetCursor")
GUIRegisterMsg($WM_LBUTTONDOWN, "_WM_LBUTTONDOWN")
GUIRegisterMsg($WM_WINDOWPOSCHANGING, "WM_WINDOWPOSCHANGING")


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

; Set cursor to correct resizing form if mouse is over GUI_Sep
Func _SetCursor()

    Local $aCurInfo = GUIGetCursorInfo($hGUI_Sep)
    Switch $aCurInfo[0]
        Case 0 To 2
            GUISetCursor(13, 1)
        Case Else
            GUISetCursor(0, 1)
    EndSwitch

EndFunc ;==>SetCursor

; Check cursor type and drag separator if required
Func _WM_LBUTTONDOWN($hWnd, $iMsg, $wParam, $lParam)

    Local $aCurInfo = GUIGetCursorInfo($hGUI_Sep)
    Switch $aCurInfo[0]
        Case 0 To 2
            _SendMessage($hGUI_Sep, $WM_SYSCOMMAND, $SC_DRAGMOVE, 0)
    EndSwitch

EndFunc ;==>WM_LBUTTONDOWN

; Handler for the separator moving
Func WM_WINDOWPOSCHANGING($hWnd, $Msg, $wParam, $lParam)

    ; If it the separator sending the message
    If $hWnd = $hGUI_Sep Then

        ; Get main GUI position and calculate current min and max positions for separator
        $aMain_Pos = WinGetPos($hGUI)
        Local $iY = $aMain_Pos[1] + $iBorder + $iBar ; Only one value needed as we do not want any vertical movement
        Local $iX_Min = $aMain_Pos[0] + $iBorder + 100
        Local $iX_Max = $aMain_Pos[0] + $iBorder + 398
        Local $iNull = $aMain_Pos[0] + $iBorder + 250

        ; Get current separator position
        Local $stWinPos = DllStructCreate("uint;uint;int;int;int;int;uint", $lParam)
        Local $iLeft = DllStructGetData($stWinPos, 3)
        Local $iTop = DllStructGetData($stWinPos, 4)
        
        ; Adjust as necessary to remain within the limits we set
        If $iLeft < $iX_Min Then $iLeft = $iX_Min
        If $iLeft > $iX_Max Then $iLeft = $iX_Max
        DllStructSetData($stWinPos, 3, $iLeft)
        If $iTop <> $iY Then DllStructSetData($stWinPos, 4, $iY)

        ; Now resize the other GUIs
        WinMove($hGUI_Left, "", $aMain_Pos[0] + $iBorder, $aMain_Pos[1] + $iBorder + $iBar, 250 - ($iNull - $iLeft), 500)
        WinMove($hGUI_Right, "", $iLeft + 2, $aMain_Pos[1] + $iBorder + $iBar, $aMain_Pos[0] + $iBorder + 500 - ($iLeft + 2), 500)

    EndIf

EndFunc

Comments (other than "It is crap"! ;) ) from anyone else welcomed. :)

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

CMJ,

This is a work in progress, but I thought you might be interested to see what I was up to! :)

...

Comments (other than "It is crap"! :P ) from anyone else welcomed. ;)

M23

No wonder I was not able to figure this out. ;) It is way beyond my level. I see what you are doing though. I can't wait to see if you can get it working!

Thanks for the help.

cj

Edited by CMJ
Link to comment
Share on other sites

  • Moderators

CMJ,

I can't wait to see if you can get it working!

That hurt! ;)

I thought it was "working" - just not quite well enough! :)

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

CMJ,

That hurt! ;)

I thought it was "working" - just not quite well enough! :)

M23

AAAAH! Sorry. I thought since you said work in progress that what I saw was expected.

When the program launches I see the two list views and a black line down the middle. When I mouse over the black line I get the double ended arrow. When I click the black line to drag it I get what you see in the SS that is attached.

It floats around like this a little and then the black line disappears and you can't do anything. If I move the window before clicking the black line then the window moves but the black line does not.

cj

Link to comment
Share on other sites

  • Moderators

CMJ,

Try this one: ;)

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

Global Const $SC_DRAGMOVE = 0xF012

; Flag for main GUI movement
Global $fMain_Move = True

; Create main GUI
$hGUI = GUICreate("Test", 500, 500)
GUISetState()

; Get GUI border and title size
$aMain_Pos = WinGetPos($hGUI)
Global $iBorder = _WinAPI_GetSystemMetrics(8) ; Border width
Global $iBar = _WinAPI_GetSystemMetrics(4) ; Title bar height

; Create and position child GUIs
$hGUI_Left = GUICreate("GUI_Left", 249, 500, -1, -1, $WS_POPUP, $WS_EX_MDICHILD, $hGUI)
$hLV_L = GUICtrlCreateListView("Col 10|Col 11", 10, 10, 230, 480)
GUICtrlSetResizing(-1, $GUI_DOCKAUTO)
WinMove($hGUI_Left, "", $aMain_Pos[0] + $iBorder, $aMain_Pos[1] + $iBorder + $iBar)
GUISetState()
$hGUI_Right = GUICreate("GUI_Right", 249, 500, -1, -1, $WS_POPUP, $WS_EX_MDICHILD, $hGUI)
$hLV_R = GUICtrlCreateListView("Col 10|Col 11", 10, 10, 230, 480)
GUICtrlSetResizing(-1,  $GUI_DOCKAUTO)
WinMove($hGUI_Right, "", $aMain_Pos[0] + $iBorder + 251, $aMain_Pos[1] + $iBorder + $iBar)
GUISetState()
$hGUI_Sep = GUICreate("GUI_Sep", 2, 500, -1, -1, $WS_POPUP, $WS_EX_MDICHILD, $hGUI)
GUISetBkColor(0x000000, $hGUI_Sep)
WinMove($hGUI_Sep, "", $aMain_Pos[0] + $iBorder + 249, $aMain_Pos[1] + $iBorder + $iBar)
GUISetState()

; Register message handlers
GUIRegisterMsg($WM_MOUSEMOVE, "_SetCursor")
GUIRegisterMsg($WM_LBUTTONDOWN, "_WM_LBUTTONDOWN")
GUIRegisterMsg($WM_WINDOWPOSCHANGING, "WM_WINDOWPOSCHANGING")

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

; Set cursor to <-> if mouse is over seperator GUI
Func _SetCursor()

    Local $aCurInfo = GUIGetCursorInfo($hGUI_Sep)
    Switch $aCurInfo[0]
        Case 0 To 2
            GUISetCursor(13, 1)
        Case Else
            GUISetCursor(0, 1)
    EndSwitch

EndFunc ;==>SetCursor

; Check cursor type and drag separator if required
Func _WM_LBUTTONDOWN($hWnd, $iMsg, $wParam, $lParam)

    If MouseGetCursor() = 13 Then _SendMessage($hGUI_Sep, $WM_SYSCOMMAND, $SC_DRAGMOVE, 0)

EndFunc ;==>WM_LBUTTONDOWN

; Handler for the GUI moving
Func WM_WINDOWPOSCHANGING($hWnd, $Msg, $wParam, $lParam)

    Switch $hWnd
        Case $hGUI
            ; Set the flag to show the main GUI is moving
            $fMain_Move = True
        Case $hGUI_Sep
            ; If the main GUI is moving, ignore any separator GUI moving messages
            If $fMain_Move Then
                $fMain_Move = False
            Else
                ; Get main GUI position and calculate current min, max and null positions for separator
                $aMain_Pos = WinGetPos($hGUI)
                Local $iX_Min = $aMain_Pos[0] + $iBorder + 100
                Local $iX_Max = $aMain_Pos[0] + $iBorder + 398
                Local $iNull = $aMain_Pos[0] + $iBorder + 250
                ; Only one Y value needed as we do not want any vertical movement
                Local $iY = $aMain_Pos[1] + $iBorder + $iBar

                ; Get current separator position
                Local $stWinPos = DllStructCreate("uint;uint;int;int;int;int;uint", $lParam)
                Local $iLeft = DllStructGetData($stWinPos, 3)
                Local $iTop = DllStructGetData($stWinPos, 4)

                ; Adjust as necessary to remain within the limits we set
                If $iLeft < $iX_Min Then $iLeft = $iX_Min
                If $iLeft > $iX_Max Then $iLeft = $iX_Max
                DllStructSetData($stWinPos, 3, $iLeft)
                If $iTop <> $iY Then DllStructSetData($stWinPos, 4, $iY)

                ; Now resize the other GUIs as necessary
                WinMove($hGUI_Left, "", $aMain_Pos[0] + $iBorder, $aMain_Pos[1] + $iBorder + $iBar, 250 - ($iNull - $iLeft), 500)
                WinMove($hGUI_Right, "", $iLeft + 2, $aMain_Pos[1] + $iBorder + $iBar, $aMain_Pos[0] + $iBorder + 500 - ($iLeft + 2), 500)

            EndIf

    EndSwitch

EndFunc

Any better? ;)

M23

Edit: When you reply please use the "Add Reply" button at the top and bottom of the page rather then the "Reply" button in the post itself. That way you do not get the contents of the previous post quoted in your reply and the whole thread becomes easier to read. :)

Edited by Melba23

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

M23

Ok,

Open looks great. The black line does not leave the gui at any time now so that is good. If I click the line and drag left the left list shrinks and the right one expands but it is a preset amount. Meaning it does not matter how far I drag the mouse it always moves a set amount. Then if I click anywhere - on the Gui, on the line, on Titlebar - the panels reverse so that the right one is smaller and the left one is larger. This is also a preset difference that does not depend on mouse movements. Now I can move it back and forth by alternating between drag left and click. Drag right does nothing. The black line never moves except for a slight bit to the left after several cycles of back and forth.

Interestingly, if I move the GUI at all (like to another screen) while it is open the behavior changes. It generally breaks everything. Clicking once makes the GUI Change but not always the same way and then clicking twice causes the black line to disappear.

If you are not seeing these things it may be something specific about my computer. Possible reasons:

I am using a x64 bit version of Win7 if that changes anything.

Is it possible that I am missing one of the includes? I am just copying this code into SciTE and pressing GO.

Anything else it could be?

cj

PS. I mostly try to include some of the previous post when other people are responding. I always edit it down some so that it is not so ridiculously long. But here since it is just two people posting it is definitely unnecessary.

Edited by CMJ
Link to comment
Share on other sites

I personaly more like this approach:

#include <GUIConstants.au3>
#include <WindowsConstants.au3>
#include <TreeViewConstants.au3>
#include <StaticConstants.au3>
#include <GuiStatusbar.au3>

;===============================================================================
; FileName:            splitterdemo.au3
; Description:      Splitter Bar demo
;
; Requirement:      Beta;!!! with this version beta is not required
; Author(s):        eltorro (Steve Podhajecki <gehossafats@netmdc.com>) modified by Tresa
; Note(s):            This is just a proof of concept at the moment.
;                    This could be tweaked into a udf with a little more work
;                    The basic principle is to create a pic box or label and drag it
;                    then resize the controls.
;                    I bowwored some filler for the tree and list from the help files.
;===============================================================================
;$WM_SIZE =0x0005
Global $Form1Height = 448
Global $Form1Width = 622
Global $splitWidth = 5
Global $leftVSplit = 144
Global $topHSplit = 320
Global $topMargin = 6
Global $leftMargin = 4
Global $rigthMargin = 4
Global $bottomMargin = 6
Global $statusBarHeight

$Form1 = GUICreate("Splitter Demo", $Form1Width, $Form1Height, 192, 125, _
    BitOR($WS_SIZEBOX, $WS_MAXIMIZEBOX, $WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_CLIPCHILDREN))

$TreeView1 = GUICtrlCreateTreeView($leftMargin, $topMargin, $leftVSplit - $leftMargin, $topHSplit - $topMargin, BitOR($TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS), $WS_EX_CLIENTEDGE)
$generalitem = GUICtrlCreateTreeViewItem("General", $TreeView1)
GUICtrlSetColor(-1, 0x0000C0)
$displayitem = GUICtrlCreateTreeViewItem("Display", $TreeView1)
GUICtrlSetColor(-1, 0x0000C0)
$aboutitem = GUICtrlCreateTreeViewItem("About", $generalitem)
$compitem = GUICtrlCreateTreeViewItem("Computer", $generalitem)
$useritem = GUICtrlCreateTreeViewItem("User", $generalitem)
$resitem = GUICtrlCreateTreeViewItem("Resolution", $displayitem)
$otheritem = GUICtrlCreateTreeViewItem("Other", $displayitem)
GUICtrlSetState($generalitem, BitOR($GUI_EXPAND, $GUI_DEFBUTTON)) ; Expand the "General"-item and paint in bold
GUICtrlSetState($displayitem, BitOR($GUI_EXPAND, $GUI_DEFBUTTON)) ; Expand the "Display"-item and paint in bold


$ListView1 = GUICtrlCreateListView("col1  |col2|col3  ", $leftVSplit + $splitWidth, $topMargin, $Form1Width - $rigthMargin - ($leftVSplit + $splitWidth), $topHSplit - $topMargin, -1, $WS_EX_CLIENTEDGE)
$item1 = GUICtrlCreateListViewItem("item2|col22|col23", $ListView1)
$item2 = GUICtrlCreateListViewItem("item1|col12|col13", $ListView1)
$item3 = GUICtrlCreateListViewItem("item3|col32|col33", $ListView1)
GUICtrlSetState(-1, $GUI_DROPACCEPTED) ; to allow drag and dropping
GUISetState()
GUICtrlSetData($item2, "ITEM1")
GUICtrlSetData($item3, "||COL33")

;horizontal divider.
$Pic2 = GUICtrlCreatePic("", $leftMargin, $topHSplit, $Form1Width - $leftMargin - $rigthMargin, $splitWidth, $SS_NOTIFY);!!! BitOR($SS_NOTIFY, $SS_ETCHEDFRAME), $WS_EX_CLIENTEDGE)
GUICtrlSetCursor($Pic2, 11)

;vertical divider
$Pic1 = GUICtrlCreateLabel("", $leftVSplit, $topMargin, $splitWidth, $topHSplit - $topMargin, $SS_NOTIFY)
GUICtrlSetCursor($Pic1, 13)
GUICtrlSetState(-1, $GUI_HIDE)

;statusBar
Local $a[3] = [150, 350, -1]
Local $b[3] = ["Ready.", "", ""], $DragCtrl = ""
$Status1 = _GUICtrlStatusBar_Create($Form1, $a, $b)
Local $a_rect = _GUICtrlStatusBar_GetRect($Status1, 1)
$statusBarHeight = ($a_rect[3] - $a_rect[1])

$Edit1 = GUICtrlCreateEdit("", $leftMargin, _
    $topHSplit + $splitWidth, $Form1Width - $leftMargin - $rigthMargin, $Form1Height - $bottomMargin - $statusBarHeight - $topHSplit - $splitWidth, _
    -1, $WS_EX_CLIENTEDGE)
GUICtrlSetData($Edit1, "Drag the bars between the controls and they will resize." & @CRLF & _
        "Resize the screen and see what happens." & @CRLF & _
        "The Status bar show True the left mouse button is down and over a splitter.")

Opt("MouseCoordMode", 2)

GUISetState(@SW_SHOW)
Dim $precedingMsg, $stopTime
ResizeControls()
GUIRegisterMsg($WM_SIZE, "RESIZE_CONTROLS")

While 1
    $nMsg = GUIGetMsg()
    
    Switch $nMsg
        Case $GUI_EVENT_PRIMARYDOWN
            _GUICtrlStatusBar_SetText($Status1, "Primary Down", 0)
        Case $Pic1
            If $DragCtrl = "" Then _GUICtrlStatusBar_SetText($Status1, "Pic1 Primary Down", 0)
            $DragCtrl = $Pic1
        Case $Pic2
            _GUICtrlStatusBar_SetText($Status1, "Pic2 Primary Down", 0)
            $DragCtrl = $Pic2
        Case $GUI_EVENT_PRIMARYUP
            _GUICtrlStatusBar_SetText($Status1, "Primary Up", 0)
            saveSplitPos()
            _GUICtrlStatusBar_SetText($Status1, "", 1)
            
            Select
                Case $DragCtrl = $Pic1
                    SplitterVert($TreeView1, $ListView1, $Pic1, $Pic2)
                    $DragCtrl = ""
                Case $DragCtrl = $Pic2
                    SplitterHort($TreeView1, $ListView1, $Edit1, $Pic2)
                    $DragCtrl = ""
            EndSelect
        Case $GUI_EVENT_SECONDARYDOWN
            _GUICtrlStatusBar_SetText($Status1, "Secondary Down", 0)
        Case $GUI_EVENT_SECONDARYUP
            _GUICtrlStatusBar_SetText($Status1, "Secondary Up", 0)
        Case $GUI_EVENT_MOUSEMOVE
            $stopTime = TimerInit()
            
            If $DragCtrl <> "" Then
                _GUICtrlStatusBar_SetText($Status1, "Dragging", 1)
                Local $picpos = ControlGetPos("", "", $DragCtrl)
                Local $mousepos = MouseGetPos()
                Local $winpos = WinGetClientSize("")
                If $DragCtrl = $Pic1 Then
                    If $mousepos[0] > 25 And $mousepos[0] < ($winpos[0] - 25) Then GUICtrlSetPos($Pic1, $mousepos[0], $picpos[1], 2)
                EndIf
                If $DragCtrl = $Pic2 Then
                    If $mousepos[1] > 25 And $mousepos[1] < ($winpos[1] - 25) Then GUICtrlSetPos($Pic2, $picpos[0], $mousepos[1], $picpos[2], 2)
                EndIf
            Else
                _GUICtrlStatusBar_SetText($Status1, "Mouse Move", 0)
            EndIf
        Case $GUI_EVENT_RESIZED, $GUI_EVENT_MAXIMIZE, $GUI_EVENT_RESTORE;!!!
            ResizeControls()
            saveSplitPos()
        Case $GUI_EVENT_CLOSE
            ExitLoop
        Case Else
            $idleTime = TimerDiff($stopTime)
            
            If $idleTime > 100 Then
                $stopTime = TimerInit()
                
                If $DragCtrl <> "" Then
                    _GUICtrlStatusBar_SetText($Status1, "Idling", 1)
                Else
                    _GUICtrlStatusBar_SetText($Status1, "Idling", 0)
                EndIf
            EndIf
    EndSwitch
WEnd

Func RESIZE_CONTROLS($hWnd, $nMsg, $wParam, $lParam)
    Local $winpos = WinGetClientSize("")
    Local $Hcoef = ($winpos[0] - $leftMargin - $rigthMargin - $splitWidth) / ($Form1Width - $leftMargin - $rigthMargin - $splitWidth)
    Local $Vcoef = ($winpos[1] - $topMargin - $bottomMargin - $splitWidth - $statusBarHeight) / ($Form1Height - $topMargin - $bottomMargin - $splitWidth - $statusBarHeight)
    
    GUICtrlSetPos($Pic2, $leftMargin, $topMargin + ($topHSplit - $topMargin) * $Vcoef, $winpos[0])
    GUICtrlSetPos($Pic1, $leftMargin + ($leftVSplit - $leftMargin) * $Hcoef - 20, $topMargin, $splitWidth, ($topHSplit - $topMargin) * $Vcoef)
    
    ResizeControls()
    Return $GUI_RUNDEFMSG
EndFunc   ;==>RESIZE_CONTROLS

Func ResizeControls()
    _GUICtrlStatusBar_Resize($Status1)

    SplitterHort($TreeView1, $ListView1, $Edit1, $Pic2)
    SplitterVert($TreeView1, $ListView1, $Pic1, $Pic2)
EndFunc   ;==>ResizeControls

Func SaveSplitPos()
    Local $winpos = WinGetClientSize("")
    $Form1Width = $winpos[0]
    $Form1Height = $winpos[1]
    Local $splitpos1 = ControlGetPos("", "", $Pic1)
    $leftVSplit = $splitpos1[0]
    Local $splitpos2 = ControlGetPos("", "", $Pic2)
    $topHSplit = $splitpos2[1]
EndFunc   ;==>SaveSplitPos

Func SplitterHort($ctrl1, $ctrl2, $ctrl3, $split)
    Local $splitpos = ControlGetPos("", "", $split)
    Local $splitpic1 = ControlGetPos("", "", $Pic1);!!!
    $splitpos[3] = $splitWidth
    GUICtrlSetPos($split, $splitpos[0], $splitpos[1], $splitpos[2], $splitWidth);!!!
    GUICtrlSetState($split, $GUI_HIDE);!!!

    Local $winpos = WinGetClientSize("")

    Local $nh
    $nh = $splitpos[1] - $topMargin;jcd - 9

    GUICtrlSetPos($ctrl1, $leftMargin, $topMargin, $splitpic1[0] - $leftMargin, $nh)
    GUICtrlSetPos($ctrl2, $splitpic1[0] + $splitWidth, $topMargin, $winpos[0] - $rigthMargin - ($splitpic1[0] + $splitWidth), $nh)

    Local $top = $splitpos[1] + $splitWidth
    GUICtrlSetPos($Pic1, $splitpic1[0], $splitpic1[1], $splitpic1[2], $nh);!!!
    
    $nh = $winpos[1] - $top - $bottomMargin - $statusBarHeight; move this up above the status bar

    GUICtrlSetPos($ctrl3, $leftMargin, _
            $top, _
            $winpos[0] - $leftMargin - $rigthMargin, _
            $nh)

    GUICtrlSetState($split, $gui_show);!!!
EndFunc   ;==>SplitterHort

Func SplitterVert($ctrl1, $ctrl2, $split1, $iop)
    GUICtrlSetState($split1, $GUI_HIDE);!!!
    Local $splitpos1 = ControlGetPos("", "", $split1)
    Local $winpos = WinGetClientSize("")
    
    GUICtrlSetPos($split1, $splitpos1[0], $splitpos1[1], $splitWidth, $splitpos1[3]);!!!

    GUICtrlSetPos($ctrl1, $leftMargin, $splitpos1[1], _
            ($splitpos1[0] - $leftMargin), _
            $splitpos1[3])

    GUICtrlSetPos($ctrl2, $splitpos1[0] + $splitWidth, _
            $splitpos1[1], _
            $winpos[0] - $rigthMargin - $splitpos1[0] - $splitWidth, _
            $splitpos1[3])
    
    GUICtrlSetState($split1, $gui_show);!!!
EndFunc   ;==>SplitterVert

It's an old script by eltorro, but it works after few twiks.

 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

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