Sign in to follow this  
Followers 0
Geert

Resize a treeview and a Listview in a gui

4 posts in this topic

My gui has a treeview and a listview in it, like windows explorer style:

Simple example:

#include <GUIConstants.au3>

GUICreate("My GUI")
; TreeView part
$treeview       = GUICtrlCreateTreeView(6, 6, 100, 150)
$generalitem    = GUICtrlCreateTreeViewitem("General", $treeview)
$displayitem    = GUICtrlCreateTreeViewitem("Display", $treeview)
$aboutitem      = GUICtrlCreateTreeViewitem("About", $generalitem)
$resitem        = GUICtrlCreateTreeViewitem("Resolution", $displayitem)

; ListView part
$listview = GUICtrlCreateListView("col1|col2|col3",108, 6, 210, 149)
GUICtrlCreateListViewItem("line1|data1|more1", $listview)

GUISetState(@SW_SHOW)

do
    $msg = GUIGetMsg()
    
until $msg = $GUI_EVENT_CLOSE

I would like to resize the treeview control and the listview should follow: treesize control bigger, listview gets smaller.

Is this possible without resizing the whole gui?

Share this post


Link to post
Share on other sites



Have you tried GUICtrlSetPos?

Thanks Gary. But how do I resize the TreeView object?

#include <GUIConstants.au3>

GUICreate("My GUI")
; TreeView part
$treeview       = GUICtrlCreateTreeView(6, 6, 100, 150)
GUICtrlSetResizing (-1,$GUI_DOCKLEFT+$GUI_DOCKTOP+$GUI_DOCKBOTTOM)
$generalitem    = GUICtrlCreateTreeViewitem("General", $treeview)
$displayitem    = GUICtrlCreateTreeViewitem("Display", $treeview)
$aboutitem      = GUICtrlCreateTreeViewitem("About", $generalitem)
$resitem        = GUICtrlCreateTreeViewitem("Resolution", $displayitem)

; ListView part
$listview = GUICtrlCreateListView("col1|col2|col3",115, 6, 210, 149)
GUICtrlSetResizing (-1,$GUI_DOCKRIGHT+$GUI_DOCKTOP+$GUI_DOCKBOTTOM)
GUICtrlCreateListViewItem("line1|data1|more1", $listview)

GUISetState(@SW_SHOW)

GUICtrlSetPos($listview,150, 6, 210, 149)

do
    $msg = GUIGetMsg()
   
until $msg = $GUI_EVENT_CLOSE

Share this post


Link to post
Share on other sites

Is this the way to do this?

Quick and dirty try:

#include <GUIConstants.au3>

Dim $MoveMode = False
Dim $MoveArea = False

$MyGUI = GUICreate("My GUI")
; TreeView part
$treeviewleft = 6
$treeviewwidth = 100
$treeview = GUICtrlCreateTreeView($treeviewleft, 6, $treeviewwidth, 150)
$generalitem = GUICtrlCreateTreeViewItem("General", $treeview)
$displayitem = GUICtrlCreateTreeViewItem("Display", $treeview)
$aboutitem = GUICtrlCreateTreeViewItem("About", $generalitem)
$resitem = GUICtrlCreateTreeViewItem("Resolution", $displayitem)

; ListView part
$listview = GUICtrlCreateListView("col1|col2|col3", $treeviewleft + $treeviewwidth + 3, 6, 350 - $treeviewwidth, 149)
GUICtrlCreateListViewItem("line1|data1|more1", $listview)

GUISetState(@SW_SHOW)

Do
    $msg = GUIGetMsg()
    
    $cursorInfo = GUIGetCursorInfo($MyGUI)
    If $cursorInfo[4] = $treeview And $cursorInfo[0] > $treeviewleft + $treeviewwidth - 3 And $MoveMode = False Then
        $MoveArea = True
        If $MoveMode = False Then ToolTip("$MoveArea=True")
        GUISetCursor(13, 1);  13 = SIZEWE
    Else
        $MoveArea = False
        GUISetCursor(2, 1);  2 = ARROW
        If $MoveMode = False Then ToolTip("$MoveArea=False")
    EndIf
    If $MoveArea = True And $cursorInfo[2] = 1 Then
        $MoveMode = True
    EndIf
    If $MoveMode = True Then
        GUISetCursor(13, 1);  13 = SIZEWE
        ToolTip("$cursorInfo[0]=" & $cursorInfo[0])
        $treeviewwidth = $cursorInfo[0] - $treeviewleft
        
        GUICtrlSetPos($treeview, $treeviewleft, 6, $treeviewwidth + 2, 150); resize treeview
        
        GUICtrlSetPos($listview, $treeviewleft + $treeviewwidth + 3, 6, 350 - $treeviewwidth, 149); resize listview
    EndIf
    If $MoveMode = True And $cursorInfo[2] = 0 Then
        $MoveMode = False
        ToolTip("")
        GUISetCursor(2, 1);  2 = ARROW
    EndIf
Until $msg = $GUI_EVENT_CLOSE

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