Function Reference


_GUICtrlListView_ApproximateViewWidth

Calculates the approximate width required to display a given number of items

#include <GuiListView.au3>
_GUICtrlListView_ApproximateViewWidth ( $hWnd [, $iCount = -1 [, $iCX = -1 [, $iCY = -1]]] )

Parameters

$hWnd Control ID/Handle to the control
$iCount [optional] Number of items to be displayed in the control.
If this parameter is set to -1 the message uses the total number of items in the control
$iCX [optional] Proposed X dimension of the control, in pixels.
This parameter can be set to -1 to allow the message to use the current width value.
$iCY [optional] Proposed Y dimension of the control, in pixels.
This parameter can be set to -1 to allow the message to use the current height value.

Return Value

Return the Approximate width, in pixels, needed to display the items.

Remarks

Setting the size of the control based on the dimensions provided by this message can optimize redraw and reduce flicker.

Related

_GUICtrlListView_ApproximateViewHeight, _GUICtrlListView_ApproximateViewRect

Example

#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <MsgBoxConstants.au3>
#include <WinAPISysWin.au3>

Example()

Func Example()
        Local $iX, $idListview

        GUICreate("ListView Approximate View Width", 400, 300)
        $idListview = GUICtrlCreateListView("", 2, 2, 394, 268)
        GUISetState(@SW_SHOW)

        ; Add column
        _GUICtrlListView_InsertColumn($idListview, 0, "Column 1", 100)

        ; Add items
        For $iI = 0 To 9
                _GUICtrlListView_AddItem($idListview, "Row " & $iI)
        Next

        MsgBox($MB_SYSTEMMODAL, "Information", "Approximate View Width")
        ; Resize view width
        $iX = _GUICtrlListView_ApproximateViewWidth($idListview)
        _WinAPI_SetWindowPos(GUICtrlGetHandle($idListview), 0, 2, 2, $iX, 268, $SWP_NOZORDER)

        ; Loop until the user exits.
        Do
        Until GUIGetMsg() = $GUI_EVENT_CLOSE
        GUIDelete()
EndFunc   ;==>Example