Sign in to follow this  
Followers 0
PartyPooper

Need a proper _GUICtrlListView_RedrawItems example

5 posts in this topic

I did a forum search but didn't find anything useful and the example in the helpfile is next to useless. The following is what's in the helpfile as an explanation of it's use:

#AutoIt3Wrapper_au3check_parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
#include <GuiConstantsEx.au3>
#include <GuiListView.au3>

Opt('MustDeclareVars', 1)

$Debug_LV = False ; Check ClassName being passed to ListView functions, set to True and use a handle to another control to see it work

_Main()

Func _Main()
    Local $hListView
    
    GUICreate("ListView Redraw Items", 400, 300)
    $hListView = GUICtrlCreateListView("", 2, 2, 394, 268)
    GUISetState()

    ; Add column
    _GUICtrlListView_AddColumn($hListView, "Items", 100)

    ; Add items
    _GUICtrlListView_BeginUpdate($hListView)
    For $iI = 1 To 10
        _GUICtrlListView_AddItem($hListView, "Item " & $iI)
    Next
    _GUICtrlListView_EndUpdate($hListView)

    ; Redraw items
    _GUICtrlListView_RedrawItems($hListView, 0, 9)

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

As you can see, you can delete the _GUICtrlListView_RedrawItems($hListView, 0, 9) line with no effect to the execution of the code so obviously, this isn't how it's used.

What I am trying to accomplish is redrawing a listview on a GUI after changing the font size on the fly without having to take the time to re-populate the listview. Any help would be appreciated.

Share this post


Link to post
Share on other sites



I did a forum search but didn't find anything useful and the example in the helpfile is next to useless. The following is what's in the helpfile as an explanation of it's use:

#AutoIt3Wrapper_au3check_parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
#include <GuiConstantsEx.au3>
#include <GuiListView.au3>

Opt('MustDeclareVars', 1)

$Debug_LV = False ; Check ClassName being passed to ListView functions, set to True and use a handle to another control to see it work

_Main()

Func _Main()
    Local $hListView
    
    GUICreate("ListView Redraw Items", 400, 300)
    $hListView = GUICtrlCreateListView("", 2, 2, 394, 268)
    GUISetState()

    ; Add column
    _GUICtrlListView_AddColumn($hListView, "Items", 100)

    ; Add items
    _GUICtrlListView_BeginUpdate($hListView)
    For $iI = 1 To 10
        _GUICtrlListView_AddItem($hListView, "Item " & $iI)
    Next
    _GUICtrlListView_EndUpdate($hListView)

    ; Redraw items
    _GUICtrlListView_RedrawItems($hListView, 0, 9)

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

As you can see, you can delete the _GUICtrlListView_RedrawItems($hListView, 0, 9) line with no effect to the execution of the code so obviously, this isn't how it's used.

What I am trying to accomplish is redrawing a listview on a GUI after changing the font size on the fly without having to take the time to re-populate the listview. Any help would be appreciated.

Can you give an example where the list view is not updated after changing the font size?

Note that the help does point out that _GUICtrlListView_RedrawItems only has it's effect seen at the next WM_PAINT message to the control.


Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

Can you give an example where the list view is not updated after changing the font size?

Note that the help does point out that _GUICtrlListView_RedrawItems only has it's effect seen at the next WM_PAINT message to the control.

I change fonts on a GUI by changing the GUISetFont(size) and then delete and recreate the GUI. Is there a way to do this on-the-fly without having to redraw the GUI?

Yeah, I read the part about WM_PAINT message but the helpfile example fails to give an example of how to use it. It assumes I know what WM_PAINT is and how to call it - I don't (yet).

Share this post


Link to post
Share on other sites
LVM_REDRAWITEMS. As explained there, use _WinAPI_UpdateWindow with the handle of the control.

Share this post


Link to post
Share on other sites

Ahh, thanks.

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