Jump to content

Auto Resizing of ListView in GUI Window


MikahS
 Share

Go to solution Solved by Melba23,

Recommended Posts

Hello AutoIt community,

I have a question for you. I have 3 separate ListViews which need to be auto sized to the GUI width / height. I've looked around the forum for a day or two and have tried using the WM_SIZE method, which after playing with it, I've realized that not everyone's screen is the same and hardcoding it could be troublesome.

So, I'm thinking I need to come up with a better way of resizing my ListViews to my GUI. Does anyone have any suggestions on different ways of achieving this goal?

Example script:

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Icon=
#AutoIt3Wrapper_Outfile=
#AutoIt3Wrapper_Res_Comment=
#AutoIt3Wrapper_Res_Description=
#AutoIt3Wrapper_Res_Fileversion=
#AutoIt3Wrapper_Run_Au3Stripper=y
#Au3Stripper_Parameters=/so
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****



#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <EditConstants.au3>
#include <Constants.au3>
#include <GUIListBox.au3>
#include <GuiListView.au3>
#include <Array.au3>
#include <ButtonConstants.au3>
#include <ScrollBarConstants.au3>
#include <Misc.au3>
#include <GuiScrollBars.au3>
;~ #include <GUIListViewEx.au3>

Local $List1, $List2, $List3, $List4, $lp_Buffer = 0
Local $List1Ex, $List2Ex, $List3Ex

GUI()

GUIRegisterMsg($WM_SIZE, "WM_SIZE")

_GUIScrollBars_EnableScrollBar(ControlGetHandle("", "", $List2), $SB_BOTH, $ESB_DISABLE_BOTH)
_GUIScrollBars_EnableScrollBar(ControlGetHandle("", "", $List3), $SB_BOTH, $ESB_DISABLE_BOTH)


While 1
    $msg = GUIGetMsg()
    Switch $msg
        Case $GUI_EVENT_CLOSE
            Quit()
    EndSwitch
WEnd

;END MAIN LINE


Func Quit()
    Exit
EndFunc   ;==>Quit


Func GUI()
    Local $Index, $LV1, $LV2, $LV3
    $GUIhandle = GUICreate("tester", 680, 575, -1, -1, $WS_SIZEBOX + $WS_SYSMENU + $WS_MAXIMIZEBOX + $WS_MINIMIZEBOX) ;creates the parent window
    GUICtrlSetResizing(-1, $GUI_DOCKAUTO) ;;allows resizing of full window
    $List1 = _GUICtrlListView_Create($GUIhandle, "Computer Name", 20, 35, 300, 448, -1, $LVS_EX_DOUBLEBUFFER) ;;$ES_READONLY incase you don't want to be able to select text
;~  $List1Ex = _GUIListViewEx_Init($List1, "")
    _GUICtrlListView_SetExtendedListViewStyle($List1, $LVS_EX_TWOCLICKACTIVATE)
    $List2 = _GUICtrlListView_Create($GUIhandle, "Date/Time", 355, 35, 190, 450, -1, BitOR($LVS_EX_DOUBLEBUFFER, $LVS_EX_FLATSB))
;~  $List1Ex = _GUIListViewEx_Init($List2, "")
    $List3 = _GUICtrlListView_Create($GUIhandle, "Speed", 574, 35, 95, 450, -1, BitOR($LVS_EX_DOUBLEBUFFER, $LVS_EX_FLATSB))
;~  $List1Ex = _GUIListViewEx_Init($List3, "")
    GUICtrlCreateLabel("Additional Info", 20, 489) ;creates the label for $List4
    GUICtrlSetResizing(-1, $GUI_DOCKSIZE)
    $List4 = GUICtrlCreateList("", 20, 512, 635, 40, BitOR($WS_BORDER, $WS_VSCROLL), $ES_READONLY)
    GUICtrlSetResizing($List4, $GUI_DOCKAUTO)
    GUICtrlCreateLabel("Active Connections: ", 525, 487) ;creates the label for the active connections
    GUICtrlSetResizing(-1, $GUI_DOCKSIZE)
    GUISetState(@SW_SHOW) ;shows the GUI window
    For $Index = 0 To 100 Step 1
        $LV1 = _GUICtrlListView_AddItem($List1, " ") ;adds a default value into $List1
        $LV2 = _GUICtrlListView_AddItem($List2, " ") ;adds a default value into $List2
        $LV3 = _GUICtrlListView_AddItem($List3, " ") ;adds a default value into $List3
    Next
EndFunc   ;==>GUI

;===========MAXIMIZE THE WINDOW TO SEE HOW THIS TRULY FUNCTIONS===============;
Func WM_SIZE($hWnd, $msg, $wParam, $lParam)
    $iWidth = BitAND($lParam, 0xFFFF) ; _WinAPI_LoWord
    $iHeight = BitShift($lParam, 16) ; _WinAPI_HiWord
    If $lParam > $lp_Buffer Then
        _WinAPI_MoveWindow($List1, 20, 35, $iWidth - 1200, 900)
    Else
        _WinAPI_MoveWindow($List1, 20, 35, $iWidth - 400, 448)
    EndIf
    $lp_Buffer = $lParam
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_SIZE

Any reply is much appreciated. :)

Edited by MikahS

Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

Link to comment
Share on other sites

  • Moderators

MikahS,

I would create disabled labels behind the ListViews which resize automatically and then resize the ListViews to fit the labels:

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

Local $List1, $List2, $List3, $List4, $lp_Buffer = 0
Local $List1Ex, $List2Ex, $List3Ex

Global $GUIhandle, $cLabel_1, $cLabel_2, $cLabel_3

GUI()

GUIRegisterMsg($WM_SIZE, "WM_SIZE")

_GUIScrollBars_EnableScrollBar(ControlGetHandle("", "", $List2), $SB_BOTH, $ESB_DISABLE_BOTH)
_GUIScrollBars_EnableScrollBar(ControlGetHandle("", "", $List3), $SB_BOTH, $ESB_DISABLE_BOTH)


While 1
    $msg = GUIGetMsg()
    Switch $msg
        Case $GUI_EVENT_CLOSE
            Quit()
    EndSwitch
WEnd

;END MAIN LINE


Func Quit()
    Exit
EndFunc   ;==>Quit


Func GUI()
    Local $Index, $LV1, $LV2, $LV3
    $GUIhandle = GUICreate("tester", 680, 575, -1, -1, $WS_SIZEBOX + $WS_SYSMENU + $WS_MAXIMIZEBOX + $WS_MINIMIZEBOX) ;creates the parent window
    ;GUICtrlSetResizing(-1, $GUI_DOCKAUTO) ;;allows resizing of full window
    $List1 = _GUICtrlListView_Create($GUIhandle, "Computer Name", 20, 35, 300, 448, -1, $LVS_EX_DOUBLEBUFFER) ;;$ES_READONLY incase you don't want to be able to select text
    _GUICtrlListView_SetExtendedListViewStyle($List1, $LVS_EX_TWOCLICKACTIVATE)
    $cLabel_1 = GUICtrlCreateLabel("", 20, 35, 300, 448)
    GUICtrlSetState($cLabel_1, $GUI_DISABLE)
    GUICtrlSetResizing($cLabel_1,$GUI_DOCKAUTO )
    GUICtrlSetBkColor($cLabel_1, $GUI_BKCOLOR_TRANSPARENT)
    $List2 = _GUICtrlListView_Create($GUIhandle, "Date/Time", 355, 35, 190, 450, -1, BitOR($LVS_EX_DOUBLEBUFFER, $LVS_EX_FLATSB))
    $cLabel_2 = GUICtrlCreateLabel("", 355, 35, 190, 450)
    GUICtrlSetState($cLabel_2, $GUI_DISABLE)
    GUICtrlSetResizing($cLabel_2,$GUI_DOCKAUTO )
    GUICtrlSetBkColor($cLabel_2, $GUI_BKCOLOR_TRANSPARENT)
    $List3 = _GUICtrlListView_Create($GUIhandle, "Speed", 574, 35, 95, 450, -1, BitOR($LVS_EX_DOUBLEBUFFER, $LVS_EX_FLATSB))
    $cLabel_3 = GUICtrlCreateLabel("", 574, 35, 95, 450)
    GUICtrlSetState($cLabel_3, $GUI_DISABLE)
    GUICtrlSetResizing($cLabel_3,$GUI_DOCKAUTO )
    GUICtrlSetBkColor($cLabel_3, $GUI_BKCOLOR_TRANSPARENT)

    GUICtrlCreateLabel("Additional Info", 20, 489) ;creates the label for $List4
    GUICtrlSetResizing(-1, $GUI_DOCKSIZE)
    $List4 = GUICtrlCreateList("", 20, 512, 635, 40, BitOR($WS_BORDER, $WS_VSCROLL), $ES_READONLY)
    GUICtrlSetResizing($List4, $GUI_DOCKAUTO)
    GUICtrlCreateLabel("Active Connections: ", 525, 487) ;creates the label for the active connections
    GUICtrlSetResizing(-1, $GUI_DOCKSIZE)
    GUISetState(@SW_SHOW) ;shows the GUI window

    For $Index = 0 To 100 Step 1
        $LV1 = _GUICtrlListView_AddItem($List1, " ") ;adds a default value into $List1
        $LV2 = _GUICtrlListView_AddItem($List2, " ") ;adds a default value into $List2
        $LV3 = _GUICtrlListView_AddItem($List3, " ") ;adds a default value into $List3
    Next
EndFunc   ;==>GUI


Func WM_SIZE($hWnd, $msg, $wParam, $lParam)

    $aRet = ControlGetPos($GUIhandle, "", $cLabel_1)
    WinMove($List1, "", $aRet[0], $aRet[1], $aRet[2], $aRet[3])
    $aRet = ControlGetPos($GUIhandle, "", $cLabel_2)
    WinMove($List2, "", $aRet[0], $aRet[1], $aRet[2], $aRet[3])
    $aRet = ControlGetPos($GUIhandle, "", $cLabel_3)
    WinMove($List3, "", $aRet[0], $aRet[1], $aRet[2], $aRet[3])

    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_SIZE
Any use? :huh:

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

Any use? :huh:

M23

 

 

You are one smart cookie Melba ;)

It works perfectly as expected. Only, one minor detail.

If the window is maximized it will stay the same, and will only change sizes when you are manually resizing the window. Any thoughts?

Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

Link to comment
Share on other sites

  • Moderators

MikahS,

 

You are one smart cookie Melba

Thanks. :blush:

As to the "minor detail" - I suggest looking for the maximize and restore messages and running the same function when they occur. ;)

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

I tried using GUIRegisterMsg($WM_SYSCOMMAND, 'WM_SIZE'). It does the same behavior for maximizing, but tries to expand everything when it is then restored.

I must be missing something.. :geek:

EDIT: Also tried

GUIRegisterMsg(0xF030, "WM_SIZE")
GUIRegisterMsg(0xF020, "WM_SIZE")
GUIRegisterMsg(0xF120, "WM_SIZE")
Edited by MikahS

Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

Link to comment
Share on other sites

  • Moderators
  • Solution

MikahS,

Try this - you need to wait until the window has been maximized/restored before you resize which is why I use a flag in the idle loop: ;)

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

Local $List1, $List2, $List3, $List4, $lp_Buffer = 0
Local $List1Ex, $List2Ex, $List3Ex

Global $GUIhandle, $cLabel_1, $cLabel_2, $cLabel_3

Global $bSysMsg = False

GUI()

GUIRegisterMsg($WM_SIZE, "_WM_SIZE")
GUIRegisterMsg($WM_SYSCOMMAND, "_WM_SYSCOMMAND")

_GUIScrollBars_EnableScrollBar(ControlGetHandle("", "", $List2), $SB_BOTH, $ESB_DISABLE_BOTH)
_GUIScrollBars_EnableScrollBar(ControlGetHandle("", "", $List3), $SB_BOTH, $ESB_DISABLE_BOTH)


While 1
    $msg = GUIGetMsg()
    Switch $msg
        Case $GUI_EVENT_CLOSE
            Quit()
    EndSwitch

    If $bSysMsg Then
        $bSysMsg = False
        _Resize_ListViews()
    EndIf

WEnd

;END MAIN LINE


Func Quit()
    Exit
EndFunc   ;==>Quit


Func GUI()
    Local $Index, $LV1, $LV2, $LV3
    $GUIhandle = GUICreate("tester", 680, 575, -1, -1, $WS_SIZEBOX + $WS_SYSMENU + $WS_MAXIMIZEBOX + $WS_MINIMIZEBOX) ;creates the parent window
    ;GUICtrlSetResizing(-1, $GUI_DOCKAUTO) ;;allows resizing of full window
    $List1 = _GUICtrlListView_Create($GUIhandle, "Computer Name", 20, 35, 300, 448, -1, $LVS_EX_DOUBLEBUFFER) ;;$ES_READONLY incase you don't want to be able to select text
    _GUICtrlListView_SetExtendedListViewStyle($List1, $LVS_EX_TWOCLICKACTIVATE)
    $cLabel_1 = GUICtrlCreateLabel("", 20, 35, 300, 448)
    GUICtrlSetState($cLabel_1, $GUI_DISABLE)
    GUICtrlSetResizing($cLabel_1,$GUI_DOCKAUTO )
    GUICtrlSetBkColor($cLabel_1, $GUI_BKCOLOR_TRANSPARENT)
    $List2 = _GUICtrlListView_Create($GUIhandle, "Date/Time", 355, 35, 190, 450, -1, BitOR($LVS_EX_DOUBLEBUFFER, $LVS_EX_FLATSB))
    $cLabel_2 = GUICtrlCreateLabel("", 355, 35, 190, 450)
    GUICtrlSetState($cLabel_2, $GUI_DISABLE)
    GUICtrlSetResizing($cLabel_2,$GUI_DOCKAUTO )
    GUICtrlSetBkColor($cLabel_2, $GUI_BKCOLOR_TRANSPARENT)
    $List3 = _GUICtrlListView_Create($GUIhandle, "Speed", 574, 35, 95, 450, -1, BitOR($LVS_EX_DOUBLEBUFFER, $LVS_EX_FLATSB))
    $cLabel_3 = GUICtrlCreateLabel("", 574, 35, 95, 450)
    GUICtrlSetState($cLabel_3, $GUI_DISABLE)
    GUICtrlSetResizing($cLabel_3,$GUI_DOCKAUTO )
    GUICtrlSetBkColor($cLabel_3, $GUI_BKCOLOR_TRANSPARENT)

    GUICtrlCreateLabel("Additional Info", 20, 489) ;creates the label for $List4
    GUICtrlSetResizing(-1, $GUI_DOCKSIZE)
    $List4 = GUICtrlCreateList("", 20, 512, 635, 40, BitOR($WS_BORDER, $WS_VSCROLL), $ES_READONLY)
    GUICtrlSetResizing($List4, $GUI_DOCKAUTO)
    GUICtrlCreateLabel("Active Connections: ", 525, 487) ;creates the label for the active connections
    GUICtrlSetResizing(-1, $GUI_DOCKSIZE)
    GUISetState(@SW_SHOW) ;shows the GUI window

    For $Index = 0 To 100 Step 1
        $LV1 = _GUICtrlListView_AddItem($List1, " ") ;adds a default value into $List1
        $LV2 = _GUICtrlListView_AddItem($List2, " ") ;adds a default value into $List2
        $LV3 = _GUICtrlListView_AddItem($List3, " ") ;adds a default value into $List3
    Next
EndFunc   ;==>GUI


Func _WM_SIZE($hWnd, $msg, $wParam, $lParam)
    _Resize_ListViews()
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_SIZE

Func _WM_SYSCOMMAND($hWnd, $msg, $wParam, $lParam)

    Const $SC_MAXIMIZE = 0xF030
    Const $SC_RESTORE = 0xF120

    Switch $wParam
        Case $SC_MAXIMIZE, $SC_RESTORE
            $bSysMsg = True
    EndSwitch

EndFunc

Func _Resize_ListViews()
    $aRet = ControlGetPos($GUIhandle, "", $cLabel_1)
    WinMove($List1, "", $aRet[0], $aRet[1], $aRet[2], $aRet[3])
    $aRet = ControlGetPos($GUIhandle, "", $cLabel_2)
    WinMove($List2, "", $aRet[0], $aRet[1], $aRet[2], $aRet[3])
    $aRet = ControlGetPos($GUIhandle, "", $cLabel_3)
    WinMove($List3, "", $aRet[0], $aRet[1], $aRet[2], $aRet[3])
EndFunc
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

Ah, hit the nail square on the head. ;)

Thank you for all your help Melba!

As always, much appreciated. :D

Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

Link to comment
Share on other sites

  • Moderators

MikahS,

My pleasure as always. :)

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

  • 3 years later...
On 23.10.2014 at 10:32 PM, Melba23 said:

MikahS,

 

Try this - you need to wait until the window has been maximized/restored before you resize which is why I use a flag in the idle loop: ;)

 

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

Local $List1, $List2, $List3, $List4, $lp_Buffer = 0
Local $List1Ex, $List2Ex, $List3Ex

Global $GUIhandle, $cLabel_1, $cLabel_2, $cLabel_3

Global $bSysMsg = False

GUI()

GUIRegisterMsg($WM_SIZE, "_WM_SIZE")
GUIRegisterMsg($WM_SYSCOMMAND, "_WM_SYSCOMMAND")

_GUIScrollBars_EnableScrollBar(ControlGetHandle("", "", $List2), $SB_BOTH, $ESB_DISABLE_BOTH)
_GUIScrollBars_EnableScrollBar(ControlGetHandle("", "", $List3), $SB_BOTH, $ESB_DISABLE_BOTH)


While 1
    $msg = GUIGetMsg()
    Switch $msg
        Case $GUI_EVENT_CLOSE
            Quit()
    EndSwitch

    If $bSysMsg Then
        $bSysMsg = False
        _Resize_ListViews()
    EndIf

WEnd

;END MAIN LINE


Func Quit()
    Exit
EndFunc   ;==>Quit


Func GUI()
    Local $Index, $LV1, $LV2, $LV3
    $GUIhandle = GUICreate("tester", 680, 575, -1, -1, $WS_SIZEBOX + $WS_SYSMENU + $WS_MAXIMIZEBOX + $WS_MINIMIZEBOX) ;creates the parent window
    ;GUICtrlSetResizing(-1, $GUI_DOCKAUTO) ;;allows resizing of full window
    $List1 = _GUICtrlListView_Create($GUIhandle, "Computer Name", 20, 35, 300, 448, -1, $LVS_EX_DOUBLEBUFFER) ;;$ES_READONLY incase you don't want to be able to select text
    _GUICtrlListView_SetExtendedListViewStyle($List1, $LVS_EX_TWOCLICKACTIVATE)
    $cLabel_1 = GUICtrlCreateLabel("", 20, 35, 300, 448)
    GUICtrlSetState($cLabel_1, $GUI_DISABLE)
    GUICtrlSetResizing($cLabel_1,$GUI_DOCKAUTO )
    GUICtrlSetBkColor($cLabel_1, $GUI_BKCOLOR_TRANSPARENT)
    $List2 = _GUICtrlListView_Create($GUIhandle, "Date/Time", 355, 35, 190, 450, -1, BitOR($LVS_EX_DOUBLEBUFFER, $LVS_EX_FLATSB))
    $cLabel_2 = GUICtrlCreateLabel("", 355, 35, 190, 450)
    GUICtrlSetState($cLabel_2, $GUI_DISABLE)
    GUICtrlSetResizing($cLabel_2,$GUI_DOCKAUTO )
    GUICtrlSetBkColor($cLabel_2, $GUI_BKCOLOR_TRANSPARENT)
    $List3 = _GUICtrlListView_Create($GUIhandle, "Speed", 574, 35, 95, 450, -1, BitOR($LVS_EX_DOUBLEBUFFER, $LVS_EX_FLATSB))
    $cLabel_3 = GUICtrlCreateLabel("", 574, 35, 95, 450)
    GUICtrlSetState($cLabel_3, $GUI_DISABLE)
    GUICtrlSetResizing($cLabel_3,$GUI_DOCKAUTO )
    GUICtrlSetBkColor($cLabel_3, $GUI_BKCOLOR_TRANSPARENT)

    GUICtrlCreateLabel("Additional Info", 20, 489) ;creates the label for $List4
    GUICtrlSetResizing(-1, $GUI_DOCKSIZE)
    $List4 = GUICtrlCreateList("", 20, 512, 635, 40, BitOR($WS_BORDER, $WS_VSCROLL), $ES_READONLY)
    GUICtrlSetResizing($List4, $GUI_DOCKAUTO)
    GUICtrlCreateLabel("Active Connections: ", 525, 487) ;creates the label for the active connections
    GUICtrlSetResizing(-1, $GUI_DOCKSIZE)
    GUISetState(@SW_SHOW) ;shows the GUI window

    For $Index = 0 To 100 Step 1
        $LV1 = _GUICtrlListView_AddItem($List1, " ") ;adds a default value into $List1
        $LV2 = _GUICtrlListView_AddItem($List2, " ") ;adds a default value into $List2
        $LV3 = _GUICtrlListView_AddItem($List3, " ") ;adds a default value into $List3
    Next
EndFunc   ;==>GUI


Func _WM_SIZE($hWnd, $msg, $wParam, $lParam)
    _Resize_ListViews()
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_SIZE

Func _WM_SYSCOMMAND($hWnd, $msg, $wParam, $lParam)

    Const $SC_MAXIMIZE = 0xF030
    Const $SC_RESTORE = 0xF120

    Switch $wParam
        Case $SC_MAXIMIZE, $SC_RESTORE
            $bSysMsg = True
    EndSwitch

EndFunc

Func _Resize_ListViews()
    $aRet = ControlGetPos($GUIhandle, "", $cLabel_1)
    WinMove($List1, "", $aRet[0], $aRet[1], $aRet[2], $aRet[3])
    $aRet = ControlGetPos($GUIhandle, "", $cLabel_2)
    WinMove($List2, "", $aRet[0], $aRet[1], $aRet[2], $aRet[3])
    $aRet = ControlGetPos($GUIhandle, "", $cLabel_3)
    WinMove($List3, "", $aRet[0], $aRet[1], $aRet[2], $aRet[3])
EndFunc

M23

Very good, but there is no check for double-click on window title events. Here is the fix:

Func _WM_SYSCOMMAND($hWnd, $msg, $wParam, $lParam)

    Const $SC_MAXIMIZE = 0xF030
    Const $SC_RESTORE = 0xF120
    ;Restore via double-click on title window
    Const $SC_RESTORE2 = 0xF122
    ;Maximize via double-click on title window
    Const $SC_MAXIMIZE2 = 0xF032

    Switch $wParam
        Case $SC_MAXIMIZE, $SC_RESTORE, $SC_RESTORE2, $SC_MAXIMIZE2
            $bSysMsg = True
    EndSwitch
    
EndFunc

 

Link to comment
Share on other sites

  • Moderators

AckerMAN,

Welcome to the AutoIt forums.

Thanks for adding the extra code - I did not even know that you could do that!

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

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

×
×
  • Create New...