Sign in to follow this  
Followers 0
MadBoy

Problem with single click and TreeListView

5 posts in this topic

Hello,

I''m using following 2 functions to update Label when something in TreeListView is clicked once. Problem is the Labels get updated but not instantly but they wait till i do another click on another item or same item (double click) which i don't realy want. So i have question why it happens and how can i have it done? I want to have Labels updated when when i click some item once.

Func WM_Notify_Events($hWndGUI, $MsgID, $wParam, $lParam)
    #forceref $hWndGUI, $MsgID, $wParam
    ;ListView Events
    Local Const $NM_FIRST = 0
    Local Const $NM_CLICK = ($NM_FIRST - 2)
    Local Const $NM_DBLCLK = ($NM_FIRST - 3)
    Local $tagNMHDR, $event, $hwndFrom, $code
    $tagNMHDR = DllStructCreate("int;int;int", $lParam) ;NMHDR (hwndFrom, idFrom, code)
    If @error Then Return
    $event = DllStructGetData($tagNMHDR, 3)
    Select
        Case $wParam = $GUI_ServersView
            Select
                Case $event = $NM_CLICK
                    TreeListView_Click()
            EndSelect
    EndSelect
    $tagNMHDR = 0
    $event = 0
    $lParam = 0
EndFunc   ;==>WM_Notify_Events
Func TreeListView_Click()
    If StringInStr(_GUICtrlTreeViewGetTree($GUI_ServersView, "/"), "/", 1) Then
        $show_server = _GUICtrlTreeViewGetTree($GUI_ServersView, "/")
        $show_server = StringSplit($show_server, "/", 1)
        If $show_server[0] >= 2 Then
            $show_server = $show_server[2]
            GUICtrlSetData($GUI_Label[50], $show_server)
            GUICtrlSetData($GUI_Label[51], _HashF_Get($show_server, $SERVER_STATUS))
            GUICtrlSetData($GUI_Label[52], _HashF_Get($show_server, $SERVER_PING) & "ms" )
        EndIf
    EndIf
EndFunc   ;==>TreeListView_Click

Thanks


My little company: Evotec (PL version: Evotec)

Share this post


Link to post
Share on other sites



Hello,

I''m using following 2 functions to update Label when something in TreeListView is clicked once. Problem is the Labels get updated but not instantly but they wait till i do another click on another item or same item (double click) which i don't realy want. So i have question why it happens and how can i have it done? I want to have Labels updated when when i click some item once.

Func WM_Notify_Events($hWndGUI, $MsgID, $wParam, $lParam)
    #forceref $hWndGUI, $MsgID, $wParam
    ;ListView Events
    Local Const $NM_FIRST = 0
    Local Const $NM_CLICK = ($NM_FIRST - 2)
    Local Const $NM_DBLCLK = ($NM_FIRST - 3)
    Local $tagNMHDR, $event, $hwndFrom, $code
    $tagNMHDR = DllStructCreate("int;int;int", $lParam) ;NMHDR (hwndFrom, idFrom, code)
    If @error Then Return
    $event = DllStructGetData($tagNMHDR, 3)
    Select
        Case $wParam = $GUI_ServersView
            Select
                Case $event = $NM_CLICK
                    TreeListView_Click()
            EndSelect
    EndSelect
    $tagNMHDR = 0
    $event = 0
    $lParam = 0
EndFunc   ;==>WM_Notify_Events
Func TreeListView_Click()
    If StringInStr(_GUICtrlTreeViewGetTree($GUI_ServersView, "/"), "/", 1) Then
        $show_server = _GUICtrlTreeViewGetTree($GUI_ServersView, "/")
        $show_server = StringSplit($show_server, "/", 1)
        If $show_server[0] >= 2 Then
            $show_server = $show_server[2]
            GUICtrlSetData($GUI_Label[50], $show_server)
            GUICtrlSetData($GUI_Label[51], _HashF_Get($show_server, $SERVER_STATUS))
            GUICtrlSetData($GUI_Label[52], _HashF_Get($show_server, $SERVER_PING) & "ms" )
        EndIf
    EndIf
EndFunc   ;==>TreeListView_Click

Thanks

You are setting $lParam to 0 on return. This is a pointer to the notification message, so I'm not sure why you're clearing it. AutoIt will run it's default handler after your WM_NOTIFY function returns. I'm not sure if Jon has code to protect against this sort of thing, but even if he does, it's bad practice. :) Not sure if this is the problem, but it won't hurt anything if you fix it.

Auto3Lib: A library of over 1200 functions for AutoIt

Share this post


Link to post
Share on other sites

You are setting $lParam to 0 on return. This is a pointer to the notification message, so I'm not sure why you're clearing it. AutoIt will run it's default handler after your WM_NOTIFY function returns. I'm not sure if Jon has code to protect against this sort of thing, but even if he does, it's bad practice. :) Not sure if this is the problem, but it won't hurt anything if you fix it.

Even if i comment out $lParam = 0 it doesn't change anything. :)


My little company: Evotec (PL version: Evotec)

Share this post


Link to post
Share on other sites

Even if i comment out $lParam = 0 it doesn't change anything. :)

One of the other things to watch out for is doing things that take a long time in your event handler. Per the help file:

Warning: blocking of running user functions which executes window messages with commands such as "Msgbox()" can lead to unexpected behavior, the return to the system should be as fast as possible !!!

With out your full code, it would be hard to tell if this is the problem. You could test this by temporarily replacing the calls to set labels 51/52 with static text. If that doesn't help, then you might want to create a separate (smaller) test script that demonstrates the problem and post it for us to review.

Auto3Lib: A library of over 1200 functions for AutoIt

Share this post


Link to post
Share on other sites

One of the other things to watch out for is doing things that take a long time in your event handler. Per the help file:

With out your full code, it would be hard to tell if this is the problem. You could test this by temporarily replacing the calls to set labels 51/52 with static text. If that doesn't help, then you might want to create a separate (smaller) test script that demonstrates the problem and post it for us to review.

It's not the problem with time the functions take to do.

If StringInStr(_GUICtrlTreeViewGetTree($GUI_ServersView, "/"), "/", 1) Then
        $show_server = _GUICtrlTreeViewGetTree($GUI_ServersView, "/")
        $show_server = StringSplit($show_server, "/", 1)
        If $show_server[0] >= 2 Then
            $show_server = $show_server[2]
            GUICtrlSetData($GUI_Label[50], '1')
            GUICtrlSetData($GUI_Label[51], '2')
            GUICtrlSetData($GUI_Label[52], '3')
            ;GUICtrlSetData($GUI_Label[50], $show_server)
            ;GUICtrlSetData($GUI_Label[51], _HashF_Get ($show_server, $SERVER_STATUS))
            ;GUICtrlSetData($GUI_Label[52], _HashF_Get ($show_server, $SERVER_PING) & "ms")
        EndIf
    EndIf
EndFunc   ;==>TreeListView_Click

And still the behaviour is teh same. Lemme send you the code and you can check it out for yourself :)


My little company: Evotec (PL version: Evotec)

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