Sign in to follow this  
Followers 0
Ixel

_GUICtrlListViewSetCheckState problem

2 posts in this topic

I'm trying to do something similar to what this poster did here...

http://www.autoitscript.com/forum/index.ph...c=11241&hl=

What I want to do is uncheck a box in the Local Area Connection Properties window. I know this is an external SysListView control and that there have been issues of people trying to use the AutoIt ListView include with such controls. Reading the post linked to above makes me think this is feasible.

Here is my part of the code that does it...

$hlist = ControlGetHandle("Local Area Connection Properties", "", "SysListView321")
_GUICtrlListViewSetCheckState($hlist, 4, 0)

Here is the code for _GUICtrlListViewSetCheckState in my include...

Func _GUICtrlListViewSetCheckState($h_listview, $i_index, $i_check = 1)
    Local $struct = "int;int;int;int;int;ptr;int;int;int;int;int;ptr", $p, $ret
    Local $p = DllStructCreate($struct)
    If @error Then Return SetError($LV_ERR,$LV_ERR,$LV_ERR)
    DllStructSetData($p, 1, $LVIF_STATE)
    DllStructSetData($p, 2, $i_index)
    If ($i_check) Then
        DllStructSetData($p, 4, 0x2000)
    Else
        DllStructSetData($p, 4, 0x1000)
    EndIf
    DllStructSetData($p, 5, $LVIS_STATEIMAGEMASK)
    If IsHWnd($h_listview) Then
        Local $a_ret = DllCall("user32.dll", "int", "SendMessage", "hwnd", $h_listview, "int", $LVM_SETITEMSTATE, "int", $i_index, "ptr", DllStructGetPtr($p))
        $ret = $a_ret[0]
    Else
        $ret = GUICtrlSendMsg($h_listview, $LVM_SETITEMSTATE, $i_index, DllStructGetPtr($p))
    EndIf
    Return $ret
EndFunc  ;==>_GUICtrlListViewSetCheckState

Do I need to change the line...

Local $struct = "int;int;int;int;int;ptr;int;int;int;int;int;ptr", $p, $ret

to stop Explorer from crashing, as did Breakdown in his situation I linked to above? I tried using his snippet that stopped the crash, but it didn't work. Any ideas?

Share this post


Link to post
Share on other sites



I'm trying to do something similar to what this poster did here...

http://www.autoitscript.com/forum/index.ph...c=11241&hl=

What I want to do is uncheck a box in the Local Area Connection Properties window. I know this is an external SysListView control and that there have been issues of people trying to use the AutoIt ListView include with such controls. Reading the post linked to above makes me think this is feasible.

Here is my part of the code that does it...

$hlist = ControlGetHandle("Local Area Connection Properties", "", "SysListView321")
_GUICtrlListViewSetCheckState($hlist, 4, 0)

Here is the code for _GUICtrlListViewSetCheckState in my include...

Func _GUICtrlListViewSetCheckState($h_listview, $i_index, $i_check = 1)
    Local $struct = "int;int;int;int;int;ptr;int;int;int;int;int;ptr", $p, $ret
    Local $p = DllStructCreate($struct)
    If @error Then Return SetError($LV_ERR,$LV_ERR,$LV_ERR)
    DllStructSetData($p, 1, $LVIF_STATE)
    DllStructSetData($p, 2, $i_index)
    If ($i_check) Then
        DllStructSetData($p, 4, 0x2000)
    Else
        DllStructSetData($p, 4, 0x1000)
    EndIf
    DllStructSetData($p, 5, $LVIS_STATEIMAGEMASK)
    If IsHWnd($h_listview) Then
        Local $a_ret = DllCall("user32.dll", "int", "SendMessage", "hwnd", $h_listview, "int", $LVM_SETITEMSTATE, "int", $i_index, "ptr", DllStructGetPtr($p))
        $ret = $a_ret[0]
    Else
        $ret = GUICtrlSendMsg($h_listview, $LVM_SETITEMSTATE, $i_index, DllStructGetPtr($p))
    EndIf
    Return $ret
EndFunc ;==>_GUICtrlListViewSetCheckState

Do I need to change the line...

Local $struct = "int;int;int;int;int;ptr;int;int;int;int;int;ptr", $p, $ret

to stop Explorer from crashing, as did Breakdown in his situation I linked to above? I tried using his snippet that stopped the crash, but it didn't work. Any ideas?

Suggest using PaulIA's Auto3Lib for now.

There's fixes in the works for the included UDFs to work with system controls correctly.


SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

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