tatane Posted June 7, 2018 Share Posted June 7, 2018 (edited) Hi, I'm trying to generate a Dir/Files treeview and I've got a problem handling the left click and left double click on items. I handle the 2 clicks In my WM_NOTIFY function but the NM_CLICK is also triggered when I double click. Is there a way to trigger NM_DBLCLK without triggering NM_CLICK ? I've 2 different processings attached to the clicks so I dont want the one for the single click be triggered when it should be the one for the double click. Thanks. Edited June 7, 2018 by tatane Link to comment Share on other sites More sharing options...
spudw2k Posted June 7, 2018 Share Posted June 7, 2018 Doing some brief google-ing, this seems to be a standard Windows behavior. You can't get a double-click event without two clicks. Essentially, a double-click is two clicks within a period of time set; I know this is not saying anything un-obvious, but think about it...how can you have the latter without the prior? You might want to consider a different approach. More details on what you are trying to accomplish will give us a bigger picture and may give us more ideas. Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX Builder Misc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retrieve SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose Array Projects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalc Cool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF Link to comment Share on other sites More sharing options...
tatane Posted June 7, 2018 Author Share Posted June 7, 2018 I understand. It's logical indeed. I can't easily put a snippet because it's a tcp client/server programm. Basically, I'm getting files & folders tree from a remote computer. So when I simple click on a folder item in my left treeview (server console), I send a request to the client to get the list of files and folders. I get them back and fill my left treeview with it. The problem is that I use double click to send a different request to expand the selected folder in the left tree so it will send one request for the single click and a second (the one I need) for the double click. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted June 7, 2018 Moderators Share Posted June 7, 2018 tatane, When you detect a single click set a flag and start an Adlib check for a suitable time later (it must be a longer interval than the Windows limit for double clicks). If you then get a double click and the flag is set for a single, clear the flag and action the doubleclick code. When the Adlib fires if the flag is set, action the single click code. I have to go out shortly - I will try and produce something to show this in action when I return this afternoon. M23 Xandy 1 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
tatane Posted June 7, 2018 Author Share Posted June 7, 2018 (edited) Ok thanks, I will try your solution and if I'm not able to do it, I'll wait your "something" I think I produce your solution (example) : expandcollapse popupGlobal $iTreeView_Flag = false Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $lParam) Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR Local $hWndDirTree = $DirTree If Not IsHWnd($DirTree) Then $hWndDirTree = GUICtrlGetHandle($DirTree) $tNMHDR = DllStructCreate($tagNMHDR, $lParam) $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) $iIDFrom = DllStructGetData($tNMHDR, "IDFrom") $iCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom Case $hWndDirTree Switch $iCode Case $NM_DBLCLK If $iTreeView_Flag Then $iTreeView_Flag = False AdlibUnRegister("checkclick") ; _TreeView_DBLCLK($hWndDirTree) EndIf Case $NM_CLICK $iTreeView_Flag = True AdlibRegister("checkclick", 550) EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc Func checkclick() If $iTreeView_Flag Then ConsoleWrite('simple clic' & @CRLF) AdlibUnRegister("checkclick") ; _TreeView_CLICK($DirTree) EndIf EndFunc Edited June 7, 2018 by tatane Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted June 7, 2018 Moderators Share Posted June 7, 2018 tatane, Looks good to me. You can determine the currently set doubleclick delay using: RegRead("HKCU\Control Panel\Mouse","DoubleClickSpeed" M23 Xandy 1 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
tatane Posted June 7, 2018 Author Share Posted June 7, 2018 I found 500ms on msdn. But getting the value from registry is better. Thanks Melba. Link to comment Share on other sites More sharing options...
Andreik Posted June 7, 2018 Share Posted June 7, 2018 Actually you don't need any kind of flag, you can do it with a simple adlib. expandcollapse popup#include <GUIConstantsEx.au3> #include <GuiTreeView.au3> #include <WindowsConstants.au3> Global $hTreeView, $iDoubleClickSpeed = DllCall('user32.dll','uint','GetDoubleClickTime')[0] $hMain = GUICreate('Example') $hTreeView = GUICtrlCreateTreeView(10,10,380,380) For $i = 1 To 10 GUICtrlCreateTreeViewItem('Item ' & $i,$hTreeView) Next GUISetState(@SW_SHOW, $hMain) GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") Do Sleep(10) Until GUIGetMsg() = -3 Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndTreeview $hWndTreeview = GUICtrlGetHandle($hTreeView) $tNMHDR = DllStructCreate($tagNMHDR, $lParam) $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) $iIDFrom = DllStructGetData($tNMHDR, "IDFrom") $iCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom Case $hWndTreeview Switch $iCode Case $NM_CLICK AdlibRegister('LeftClickEvent',$iDoubleClickSpeed) Return 0 Case $NM_DBLCLK DoubleLeftClickEvent() Return 0 EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc Func LeftClickEvent() AdlibUnRegister('LeftClickEvent') ConsoleWrite('Left click' & @CRLF) EndFunc Func DoubleLeftClickEvent() AdlibUnRegister('LeftClickEvent') ConsoleWrite('Double left click' & @CRLF) EndFunc spudw2k 1 Link to comment Share on other sites More sharing options...
tatane Posted June 7, 2018 Author Share Posted June 7, 2018 Yep it works. Thank you. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now