Jump to content

Click event issue on listview Object - please help


Recommended Posts

Hi,

I start to try to use AutoIt but I have some issue.

I have tried to modify a script found in the forum to my personnal use but I have some issue.

I can not catch the click event on the listview object. I put my script here in case of some of you can explain what is wrong.

Thanks

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <TreeViewConstants.au3>
#include <StaticConstants.au3>
#Include <GuiTreeView.au3>
#Include <adfunctions.au3>
#include <ListViewConstants.au3>
#include <GuiListView.au3>

#region; Define AD Constants

Global Const $ADS_PROPERTY_CLEAR = 1
Global Const $ADS_PROPERTY_APPEND = 3
Global Const $ADS_SCOPE_ONELEVEL = 1
Global Const $ADS_SCOPE_SUBTREE = 2

Global $objConnection = ObjCreate("ADODB.Connection"); Create COM object to AD
$objConnection.ConnectionString = "Provider=ADsDSOObject"
$objConnection.Open ("Active Directory Provider"); Open connection to AD

Global $objRootDSE = ObjGet("LDAP://RootDSE")
Global $strAdsDomainPath = $objRootDSE.Get ("defaultNamingContext"); Retrieve the current AD domain name
Global $strHostServer = $objRootDSE.Get ("dnsHostName"); Retrieve the name of the connected DC
Global $strConfiguration = $objRootDSE.Get ("ConfigurationNamingContext"); Retrieve the Configuration naming context

#endregion


#region; Define Script Constants

Global Const $ADS_SCOPE_DEPTH = 1

#endregion

;**********************************************************************
;               MAIN
;**********************************************************************
Global $hTreeView
Global $ListView
Global $strRootContainer = $strAdsDomainPath

Local $infobutton, $cancelbutton, $msg, $Text

Opt("GUIOnEventMode", 1)
$Forms1 = GUICreate("AD TreeView", 800, 400)
$hTreeView  = CreateADTree ($strRootContainer, 25, 25, 300, 300, BitOr($TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS), $WS_EX_CLIENTEDGE)
$ListView   = GUICtrlCreateListView("Account code|Display Name", 360, 25, 410, 200)
_GUICtrlListView_SetColumnWidth($ListView, 0, 100)
_GUICtrlListView_SetColumnWidth($ListView, 1, $LVSCW_AUTOSIZE_USEHEADER)

$Group1 = GUICtrlCreateGroup("Account Info", 360, 230, 417, 161)
$Label1 = GUICtrlCreateLabel("Account Code", 365, 260, 70, 20)
$Input1 = GUICtrlCreateInput("", 440, 255, 55, 20)
$Label2 = GUICtrlCreateLabel("Display Name", 365, 290, 70, 20)
$Input2 = GUICtrlCreateInput("", 440, 285, 129, 20)

$LabelDate1 = GUICtrlCreateLabel("End date", 530, 260, 70, 20)
$Date1 = GUICtrlCreateDate("2008/08/01 13:49:45", 585, 255, 186, 21)
$Checkbox2 = GUICtrlCreateCheckbox("Disabled", 650, 290, 97, 17)

$infobutton  = GUICtrlCreateButton("Users", 25, 350, 70, 20, 0)
GUICtrlSetOnEvent(-1, "_listOfUsers")

$cancelbutton   = GUICtrlCreateButton("Quit", 125, 350, 70, 20, 0)
GUICtrlSetOnEvent(-1, "_Exit")


GUISetState (@SW_SHOW)
GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")


While 1
    Sleep(100)
WEnd


#region
;**********************************************************************
;               FONCTIONS
;**********************************************************************

#region;mes fonctions

Func _listOfUsers()
    _GUICtrlListView_DeleteAllItems(GUICtrlGetHandle($ListView))
            
            Dim $ou
            if GetItemAdsPath ($hTreeView)="" Then
                $ou = $strAdsDomainPath
            else    
                $ou = GetItemAdsPath ($hTreeView) & "," & $strAdsDomainPath
            EndIf
           ;MsgBox(64, "Information", $ou)
        ;Dim $ou = "ou=trans,ou=europe,DC=chrobinson,DC=com"
            Dim $EXISTINGUSER
            Dim $filter = "objectClass='User' and objectCategory='Person'"
            Dim $searchscope = 2
            Dim $datatoretrieve = "sAMAccountName,displayname"
            Dim $sortby = "sAMAccountName"

            _ADGetObjectsInOU_mode($EXISTINGUSER, $ou, $filter, $searchscope, $datatoretrieve,$sortby)

            If IsArray($EXISTINGUSER) Then
            ;ConsoleWrite("Items in the array: " & UBound($EXISTINGUSER))
                For $i = 0 To UBound($EXISTINGUSER) - 1
                ;ConsoleWrite($EXISTINGUSER[$i][0] & " " & $EXISTINGUSER[$i][1] & @LF)
                    _GUICtrlListView_AddItem($ListView,"")
                    _GUICtrlListView_AddSubItem($ListView, $i - 1, $EXISTINGUSER[$i][0], 0)
                    _GUICtrlListView_AddSubItem($ListView, $i - 1, $EXISTINGUSER[$i][1], 1)
                Next
            Else
            ;ConsoleWrite("Not an Array")
            EndIf
EndFunc

Func _Exit()
    Exit
EndFunc
#EndRegion


#Region; _ADGetObjectsInOU_mode
Func _ADGetObjectsInOU_mode(ByRef $ObjectArray, $ou, $filter = "(name=*)", $searchscope = 2, $datatoretrieve = "sAMAccountName", $sortby = "sAMAccountName")
    Local $objRecordSet
    $objCommand = ObjCreate("ADODB.Command")
    $objCommand.ActiveConnection = $objConnection
    $objCommand.Properties ("Page Size") = 256
    $objCommand.Properties ("Searchscope") = $searchscope
    $objCommand.Properties ("TimeOut") = 20
    
;$strCmdText = "<LDAP://" & $strHostServer & "/" & $ou & ">;" & $filter & ";" & $datatoretrieve & ";subtree"
    $strCmdText = "Select " & $datatoretrieve & " from 'LDAP://" & $ou & "' Where " & $filter & " order by " & $sortby 
    
    $objCommand.CommandText = $strCmdText
    $objRecordSet = $objCommand.Execute

    $recordcount = $objRecordSet.RecordCount
    If $recordcount = 0 Then
        $objCommand = 0
        $objRecordSet = 0
        Return 0
    EndIf
    
    If StringInStr($datatoretrieve, ",") Then

        $dtrArray = StringSplit($datatoretrieve, ",")
        
        Dim $ObjectArray[$recordcount + 1][$dtrArray[0]]
        
        $ObjectArray[0][0] = $recordcount
        $ObjectArray[0][1] = $dtrArray[0]
        
        $count = 1
        $objRecordSet.MoveFirst
        Do
            For $i = 1 To $dtrArray[0]
                $ObjectArray[$count][$i - 1] = $objRecordSet.Fields ($dtrArray[$i]).Value
            Next
            $objRecordSet.MoveNext
            $count += 1
        Until $objRecordSet.EOF
    Else
        Dim $ObjectArray[$recordcount + 1]
        $ObjectArray[0] = UBound($ObjectArray) - 1
        If $ObjectArray[0] = 0 Then
            $ObjectArray = 0
            Return 0
        Else
            $count = 1
            $objRecordSet.MoveFirst
            Do
                $ObjectArray[$count] = $objRecordSet.Fields ($datatoretrieve).Value
                $objRecordSet.MoveNext
                $count += 1
            Until $objRecordSet.EOF
        EndIf
    EndIf
    
    $objCommand = 0
    $objRecordSet = 0
    
    Return 1
    
EndFunc  ;==>_ADGetObjectsInOU_mode

#EndRegion

#region; TreeView Functions


; ---------------------------------------------------------------------
;    Create Treeview  of OrganizationalUnits by queries in Active Directory
; ---------------------------------------------------------------------
Func CreateADTree ($strRootAdsPath, $intLeft, $intTop, $intWidth, $intHeight, $intStyle, $intExStyle )
    Local $LocalTreeview, $RootNode, $strRootName
    Global $hImage, $hFolderImage
    
    $LocalTreeview  = GUICtrlCreateTreeView($intLeft, $intTop, $intWidth, $intHeight, $intStyle, $intExStyle)
    
    $hImage = _GUIImageList_Create(16, 16, 5, 3)
    $hFolderImage = _GUIImageList_AddIcon($hImage, "shell32.dll", 4);Folder Image
    _GUICtrlTreeView_SetNormalImageList($LocalTreeview, $hImage)    
    
    _GUICtrlTreeView_BeginUpdate($LocalTreeview)
    $strRootName = GetObjectInfo ($strRootAdsPath, "Name")
    $RootNode = _GUICtrlTreeView_Add($LocalTreeview, 0, $strRootName, $hFolderImage, $hFolderImage)
    BuildADtreeView ($LocalTreeview, $RootNode, $strRootAdsPath,$ADS_SCOPE_DEPTH)
    _GUICtrlTreeView_EndUpdate($LocalTreeview)
    
    Return $LocalTreeview
EndFunc


; ---------------------------------------------------------------------
; Fonction récursive à N niveaux créant des noeuds à partir de requetes AD
;    $intDepth = number of recursive calls
; ---------------------------------------------------------------------
Func BuildADtreeView ($hTreeView, $hItem, $strAdsContainer,$intDepth)
Local $strOrganizationalUnitsDN, $arrOUsList, $intSizeArray
    Local $strObjectDN, $strObjectName
    Local $ThisItem, $i

    If $intDepth < 1 Then
        Return
    EndIf
    
    $strOrganizationalUnitsDN = QueryAD ($strAdsContainer, $ADS_SCOPE_ONELEVEL,"OrganizationalUnit", "DistinguishedName", "name", "=", "*", "name")
    
    $arrOUsList = StringSplit($strOrganizationalUnitsDN,";")
    $intSizeArray = $arrOUsList[0]
    
    If $strOrganizationalUnitsDN = "" Then
   ;ConsoleWrite("LISTOU > EXIT FUNC "&@LF)
        
    Else
        For $i = 1 To $intSizeArray
            $strObjectDN = $arrOUsList[$i]
            $strObjectName = GetObjectInfo($strObjectDN, "name")
            
       ; Add Item on Treeview
            $ThisItem = _GUICtrlTreeView_AddChild($hTreeView, $hItem, $strObjectName, $hFolderImage, $hFolderImage)
            
       ; Build Sub Containers
            If ($intDepth-1) > 0 Then
                BuildADtreeView ($hTreeView, $ThisItem, $strObjectDN,$intDepth-1)
            EndIf
        Next     
    
    EndIf

EndFunc


; ---------------------------------------------------------------------
; Control clicks on Treeview
; ---------------------------------------------------------------------
Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
    #forceref $hWnd, $iMsg, $iwParam
    Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndTreeview
    $hWndTreeview = $hTreeView
    $hWndListView = $ListView
        If Not IsHWnd($hTreeView) Then $hWndTreeview = GUICtrlGetHandle($hTreeView)
        
        $tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
        $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
        $iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
        $iCode = DllStructGetData($tNMHDR, "Code")
        Switch $hWndFrom
            Case $hWndTreeview
                Switch $iCode
                    Case $NM_CLICK; The user has clicked the left mouse button within the control
                        Local $tPoint, $tTVHEx, $TVhItem, $mX, $mY
                        $tPoint = _WinAPI_GetMousePos(True, $hWndTreeview)
                        $mX = DllStructGetData($tPoint, "X")
                        $mY = DllStructGetData($tPoint, "Y")
                        $tTVHEx = _GUICtrlTreeView_HitTestEx($hWndTreeview, $mX, $mY)
                        $TVhItem = DllStructGetData($tTVHEx, "Item")
                        Switch DllStructGetData($tTVHEx, "Flags")
                            Case $TVHT_ONITEM
                                ConsoleWrite("$NM_CLICK" & @LF & "--> $TVHT_ONITEM Item Handle:" & @TAB & $TVhItem)           

                            Case $TVHT_ONITEMLABEL or $TVHT_ONITEMICON
                                TreeView_RefreshItem ($hTreeView, $TVhItem)

                        EndSwitch     
            ;     Return 1; nonzero to not allow the default processing
                        Return 0; zero to allow the default processing
                EndSwitch
            Case $hWndListView
                Switch $iCode
                    Case $NM_CLICK; The user has clicked the left mouse button within the control
                            msgbox(0,"test","clic on list")
                EndSwitch
                Return 0; zero to allow the default processing
        EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc ;==>WM_NOTIFY


; ---------------------------------------------------------------------
; Refresh : Load Sub Containers (query AD)
; ---------------------------------------------------------------------
Func TreeView_RefreshItem ($hTreeView, $hItem)
    Local $strItemAdsPath, $intNbChildren
    Local $strAdsContainer
    
    $strItemAdsPath = GetItemRecursiveAdsPath ($hTreeView, $hItem)
    $intNbChildren = _GUICtrlTreeView_GetChildCount($hTreeView, $hItem)
    
    If $intNbChildren < 0 Then
        $strAdsContainer = $strItemAdsPath & "," &$strAdsDomainPath
        BuildADtreeView ($hTreeView, $hItem, $strAdsContainer,$ADS_SCOPE_DEPTH)
        
    EndIf
    
EndFunc

; ---------------------------------------------------------------------
; TreeView Function : Get Selected Item's Label
; ---------------------------------------------------------------------
Func GetItemText ($hTreeView)
    Local $hItem, $Text
    
    $hItem = _GUICtrlTreeView_GetSelection ($hTreeView)
;MsgBox(64, "Information", $hItem)
    If $hItem = 0 Then
        $Text = "No item currently selected"
    Else
        $Text = _GUICtrlTreeView_GetText ($hTreeView, $hItem)
    EndIf
    
    Return $Text
EndFunc

; ---------------------------------------------------------------------
; TreeView Function : Get Parent's Label of the Selected Item
; ---------------------------------------------------------------------
Func GetParentItemText ($hTreeView)
    Local $hItem, $Text
    Local $hParentItem
    
    $hItem = _GUICtrlTreeView_GetSelection ($hTreeView)
    
    If $hItem = 0 Then
        $Text = "No item currently selected"
    Else
        $hParentItem = _GUICtrlTreeView_GetParentHandle($hTreeView, $hItem)
   ;MsgBox(64, "Parent", $hParentItem)
        If $hParentItem=0 Then
            $Text = ""
        Else    
            $Text = _GUICtrlTreeView_GetText ($hTreeView, $hParentItem)
        EndIf
    EndIf
    
    Return $Text    
EndFunc


; ---------------------------------------------------------------------
; TreeView Function : Get Selected Item's ADS Path
;       syntax like  OU=Temp,OU=SALES,OU=Company
; ---------------------------------------------------------------------
Func GetItemAdsPath ($hTreeView)
    Local $Text, $hItem, $hParentItem
    
; Get Item ID
    $hItem = _GUICtrlTreeView_GetSelection ($hTreeView)
    If $hItem <> 0 Then
        $Text = GetItemRecursiveAdsPath ($hTreeView, $hItem)
    EndIf
    
    Return $Text
EndFunc

; ---------------------------------------------------------------------
;; TreeView Function : Get Specified Item's ADS Path
;       syntax like  OU=Temp,OU=SALES,OU=Company
; ---------------------------------------------------------------------
Func GetItemRecursiveAdsPath ($hTreeView, $hItem)
    Local $Text, $hParentItem
    
; Get Parent Item ID
    $hParentItem = _GUICtrlTreeView_GetParentHandle($hTreeView, $hItem)
    If $hParentItem=0 Then
        $Text = "OU="&_GUICtrlTreeView_GetText ($hTreeView, $hItem)
    Else    
        $Text = "OU="&_GUICtrlTreeView_GetText ($hTreeView, $hItem) & "," & GetItemRecursiveAdsPath ($hTreeView, $hParentItem)
    EndIf

    Return $Text
EndFunc

#endregion

#region; AD Functions
; ---------------------------------------------------------------------
; Requete AD
;   $intScope = ADS_SCOPE_ONELEVEL or ADS_SCOPE_SUBTREE
;   $strTypeFilter = USER, CONTACT, GROUP, COMPUTER
;   $strAttributeQueried : Attribut retourné (ex: DistinguishedName, Name, CN, etc.)
;   $strAttributeRequested : Critere de recherche (ex: SamAccountName, Name, DisplayName, GivenName, etc.)
;   $strOperator: operation à effectuer (ex: "=", ">", "<>")
;   $strAttributeValue : requete de valeur (ex: "toto" pour le Name)
;           > Recherche possible avec le wildchar (ex: Test*)
;   $strSort : Critère de tri alphabétique (ex: "Name" pour un tri sur le nom)
;           > Mettre à "" pour ne faire aucun tri

; SORTIE: Si plusieurs réponses, séparation par ';' (ex: DN1;DN2;DN3)
; ---------------------------------------------------------------------
Func QueryAD ($strLdapRootPath, $intScope, $strTypeFilter, $strAttributeQueried, $strAttributeRequested, $strOperator, $strAttributeValue, $strSort)
;QueryAD ($strAdsContainer, $ADS_SCOPE_ONELEVEL,"OrganizationalUnit", "DistinguishedName", "name", "=", "*", "name")
    
    Local $objCommand2, $objRecordSet
    Local $strResultQuery, $strResultQueryMultiValued
    Local $arrTemp, $strValue, $CleanAdsPath

    $strResultQuery = ""

    $objCommand2 = ObjCreate("ADODB.Command")
    $objCommand2.ActiveConnection = $objConnection
    
;Escape Special Characters for SQL Query
    $CleanAdsPath = StringReplace($strLdapRootPath,"'","''")
    $CleanAdsPath = StringReplace($CleanAdsPath,"+","\+")

    If StringCompare($strTypeFilter,"COMPUTER")=0 Then
        $objCommand2.CommandText = _
            "Select "& $strAttributeQueried &","&$strSort&" from 'LDAP://" & $CleanAdsPath & _
            "' where objectClass='COMPUTER' and "&$strAttributeRequested&"='"&$strAttributeValue&"'"
    Else
        $objCommand2.CommandText = _
            "Select "& $strAttributeQueried &" from 'LDAP://" & $CleanAdsPath & _
            "' where objectClass='"&$strTypeFilter&"' and "&$strAttributeRequested& $strOperator &"'"&$strAttributeValue&"'"
            ;objectClass='"&$strTypeFilter&"' AND objectClass<>'computer' and "&$strAttributeRequested& $strOperator &"'"&$strAttributeValue&"'"
    EndIf
    
    ConsoleWrite($CleanAdsPath)
        
    $objCommand2.Properties("Page Size") = 1000; Recherche par paquet de 1000 objets
    $objCommand2.Properties("Timeout") = 30
    $objCommand2.Properties("Searchscope") = 1;$intScope
    $objCommand2.Properties("Cache Results") = False
    If $strSort<>"" Then
        $objCommand2.Properties("Sort on") = $strSort
    EndIf
    
    $objRecordSet = $objCommand2.Execute

    If $objRecordSet.EOF <> true Then
        $objRecordSet.MoveFirst
    EndIf

    If NOT $objRecordSet.EOF Then
        If IsArray($objRecordSet.Fields($strAttributeQueried)) Then
            $arrTemp = $objRecordSet.Fields($strAttributeQueried)
            $strResultQueryMultiValued = ""
            For $strValue In $arrTemp
                If $strResultQueryMultiValued="" Then
                    $strResultQueryMultiValued = $strValue
                Else
                    $strResultQueryMultiValued = $strResultQueryMultiValued &"§"& $strValue
                EndIf
            Next
            $strResultQuery = $strResultQueryMultiValued
        Else
            $strResultQuery  = $objRecordSet.Fields($strAttributeQueried).Value
        EndIf
        
        $objRecordSet.MoveNext
        
    EndIf

;MsgBox (1,"Query AD","$strResultQuery : "&$strResultQuery)
    
    While NOT $objRecordSet.EOF
        If IsArray($objRecordSet.Fields($strAttributeQueried)) Then
            $arrTemp = $objRecordSet.Fields($strAttributeQueried)
            $strResultQueryMultiValued = ""
            For $strValue In $arrTemp
                If $strResultQueryMultiValued="" Then
                    $strResultQueryMultiValued = $strValue
                Else
                    $strResultQueryMultiValued = $strResultQueryMultiValued &"§"& $strValue
                EndIf
            Next
            $strResultQuery  = $strResultQuery &";" &$strResultQueryMultiValued
        
        Else
            $strResultQuery  = $strResultQuery &";" &$objRecordSet.Fields($strAttributeQueried).Value
        EndIf
        
        $objRecordSet.MoveNext
    Wend

    $objCommand2 = 0
    $objRecordSet = 0
    
    Return $strResultQuery

EndFunc



; ---------------------------------------------------------------------
; Récupère la valeur d'un attribut d'un objet AD
;   - StrObjectDN = Object DistinguishedName
;   - StrAttribute = Attribut choisi
; ---------------------------------------------------------------------
Func GetObjectInfo ($strObjectDN, $strAttribute)
    Local $objADObject, $strResult

    $objADObject = ObjGet ("LDAP://"&$strObjectDN)
    $objADObject.GetInfo

    $strResult = $objADObject.Get($strAttribute)
    
    Return $strResult
EndFunc



#endregion

#endregion
Link to comment
Share on other sites

Too much code.

Pare that down to a short, basic GUI with only enough functionality to show what you want. Just a basic GUI with a basic ListView, with only a few entries, and only the one click event to handle.

It's very likely that you'll figure out the problem while doing that, and it will be short enough for use to test/debug if not.

:P

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

Too much code.

Pare that down to a short, basic GUI with only enough functionality to show what you want. Just a basic GUI with a basic ListView, with only a few entries, and only the one click event to handle.

It's very likely that you'll figure out the problem while doing that, and it will be short enough for use to test/debug if not.

:P

Sorry, like I am not english I hope I will give you enough explanation. The script below have two controls :

1 treeview and one listview.

I populate the treeview by the active directory tree of my domain (this part his a script I found in this forum). each time I clic on a line, the subtree is populate and appear in the treeview (exactly like the windows explorer tree). => this part works

each time I clic on a line of the treeview, i populate the list view with the elment of the OU selected. => this part works

now I want to display some properties of the element i select in the listview but the click is not catch and the folowing function do nothing

Like the scrip I have found in the forum worked perfectly before, the problem comes from my modification. I am sure the problem is in this function :

; ---------------------------------------------------------------------
; Control clicks on Treeview
; ---------------------------------------------------------------------
Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
    #forceref $hWnd, $iMsg, $iwParam
    Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndTreeview
    $hWndTreeview = $hTreeView
    $hWndListView = $ListView
        If Not IsHWnd($hTreeView) Then $hWndTreeview = GUICtrlGetHandle($hTreeView)
        
        $tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
        $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
        $iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
        $iCode = DllStructGetData($tNMHDR, "Code")
        Switch $hWndFrom
            Case $hWndTreeview
                Switch $iCode
                    Case $NM_CLICK; The user has clicked the left mouse button within the control
                        Local $tPoint, $tTVHEx, $TVhItem, $mX, $mY
                        $tPoint = _WinAPI_GetMousePos(True, $hWndTreeview)
                        $mX = DllStructGetData($tPoint, "X")
                        $mY = DllStructGetData($tPoint, "Y")
                        $tTVHEx = _GUICtrlTreeView_HitTestEx($hWndTreeview, $mX, $mY)
                        $TVhItem = DllStructGetData($tTVHEx, "Item")
                        Switch DllStructGetData($tTVHEx, "Flags")
                            Case $TVHT_ONITEM
                                ConsoleWrite("$NM_CLICK" & @LF & "--> $TVHT_ONITEM Item Handle:" & @TAB & $TVhItem)           
                            Case $TVHT_ONITEMLABEL or $TVHT_ONITEMICON
                                TreeView_RefreshItem ($hTreeView, $TVhItem)
                        EndSwitch     
                        Return 0; zero to allow the default processing
                EndSwitch
            Case $hWndListView
                Switch $iCode
                    Case $NM_CLICK; The user has clicked the left mouse button within the control
                            msgbox(0,"test","clic on list")
                EndSwitch
                Return 0; zero to allow the default processing
        EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc;==>WM_NOTIFY

this part of the function is never execute like he can not find $hWindlistView but $hTreeView and $ListView have been define in Global.:

Case $hWndListView
                Switch $iCode
                    Case $NM_CLICK; The user has clicked the left mouse button within the control
                            msgbox(0,"test","clic on list")
                EndSwitch
                Return 0; zero to allow the default processing

perhaps it is due that

If Not IsHWnd($hTreeView) Then $hWndTreeview = GUICtrlGetHandle($hTreeView)

but I am not sure to understand the reason of this line of code.

thanks

Edited by Farren
Link to comment
Share on other sites

perhaps it is due that

If Not IsHWnd($hTreeView) Then $hWndTreeview = GUICtrlGetHandle($hTreeView)

but I am not sure to understand the reason of this line of code.

thanks

I don't claim to understand the rest of your issue, but the purpose of that line is to allow passing an AutoIt control ID instead of the handle to the control. On detecting that it is not a handle, it uses the Control ID to get the handle.

:P

P.S. What does "#forceref" do?

:P

Edited by PsaltyDS
Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
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...