Jump to content

How to use $LVS_EX_CHECKBOXES Listview extended style


Recommended Posts

I wanted to see if I could get some more information as to how I could go about utilizing the extended list view style $LVS_EX_CHECKBOXES.  When it is used to create a listview control, one would think that it could be used to select the a list view item, but it doesn't do that.  It doesn't appear much of anything.  So I am curious as to how I could go about to expand this functionality.  For example, is there a notification that fires off when a list view item is checked that I can capture and code some action in response?  What would that code look like?  Any input would be appreciated.

Link to comment
Share on other sites

Usually I get the Listview row count then loop through and use _GUICtrlListView_GetItemChecked to determine if an item is checked or not.  You can add the indexes into a temporary array or apply actions based on whether the function returns true or not.

Link to comment
Share on other sites

2 minutes ago, Subz said:

Usually I get the Listview row count then loop through and use _GUICtrlListView_GetItemChecked to determine if an item is checked or not.  You can add the indexes into a temporary array or apply actions based on whether the function returns true or not.

So, to your knowledge, there is no windows message or notification that is generated by the control that can be captured with GUIRegisterMsg?

Link to comment
Share on other sites

  • 4 weeks later...

As Subz said, I use this simplified test: If "State changed" And NewState <> OldState Then ...

 

GUIRegisterMsg($WM_NOTIFY, "WM_Notify_Events")

Func WM_Notify_Events($hWndGUI, $MsgID, $wParam, $lParam)
    #forceref $hWndGUI, $MsgID, $wParam
    Local $tagNMHDR, $event

    $tagNMHDR = DllStructCreate("int;int;int", $lParam)
    $event = DllStructGetData($tagNMHDR, 3)

    If $hWndGUI = $Form1 And $wParam = $ListView1 Then
        ; https://docs.microsoft.com/cs-cz/windows/win32/controls/lvn-itemchanged
        If $event = $LVN_ITEMCHANGED Then
            $NMLISTVIEW = DllStructCreate($tagNMLISTVIEW, $lParam)
            If BitAND(DllStructGetData($NMLISTVIEW, "Changed"), $LVIF_STATE) = $LVIF_STATE And _
                DllStructGetData($NMLISTVIEW, "NewState") <> DllStructGetData($NMLISTVIEW, "OldState") Then MyFunction()
        EndIf
    EndIf

    Return $GUI_RUNDEFMSG
EndFunc

 

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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...