Function Reference


_GUICtrlListView_ApproximateViewRect

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

#include <GuiListView.au3>
_GUICtrlListView_ApproximateViewRect ( $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

Returns an array with the following format:
[0] - Approximate width, in pixels, needed to display the items
[1] - Approximate height, 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_ApproximateViewWidth

Example

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

Example()

Func Example()
    Local $aXY, $idListview

    GUICreate("ListView Approximate View Rect", 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 Rect")
    ; Resize view
    $aXY = _GUICtrlListView_ApproximateViewRect($idListview)
    _WinAPI_SetWindowPos(GUICtrlGetHandle($idListview), 0, 2, 2, $aXY[0], $aXY[1], $SWP_NOZORDER)
    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example