LOULOU Posted January 29, 2005 Share Posted January 29, 2005 I want to make something special in a listviwitem control when I make a doubleclick. Actually the gui doen't do anything when i doubleclick. Is someone can help me Thanks Link to comment Share on other sites More sharing options...
this-is-me Posted January 29, 2005 Share Posted January 29, 2005 (edited) You have to set up a timer to do what you want. Keep some type of time log for when a mouse click is made, and if another is made within about 500ms then call the doubleclick function. EDIT: spelling Edited January 29, 2005 by this-is-me Who else would I be? Link to comment Share on other sites More sharing options...
Holger Posted January 29, 2005 Share Posted January 29, 2005 Here is my small example that I used days ago for testing and rewrote it a little bit expandcollapse popup#include <GUIConstants.au3> GUICreate("test") $msginfo = GUICtrlCreateLabel("",0,0,100,20) $clicktime = GUICtrlCreateLabel("",100,0,100,20) $mouseclick = GUICtrlCreateLabel("normal",100,20,40,20) $listv = GUICtrlCreateListView("Name|Firstname",50,100,250,100) $item1 = GUICtrlCreateListViewItem("Black|Mr.",$listv) $item2 = GUICtrlCreateListViewItem("White|Dr.",$listv) GUISetState() $start = 0 $diff = 0 $doubleclicked = 0 While 1 $msg = GUIGetMsg() Select Case $msg = 0 ContinueLoop Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $GUI_EVENT_PRIMARYDOWN $diff = TimerDiff($start) GUICtrlSetData($clicktime,$diff) ; Read the current mouse-doubleclick-settings from registry $mousespeed = RegRead("HKCU\Control Panel\Mouse","DoubleClickSpeed") If $mousespeed = "" Then $mousespeed = 500 If $diff < $mousespeed And $doubleclicked = 0 Then GUICtrlSetData($mouseclick,"double") $itemclicked = GUICtrlRead($listv) If $itemclicked > 0 Then Msgbox(64,"Item clicked",GUICtrlRead($itemclicked)) EndIf $doubleclicked = 1 Else GUICtrlSetData($mouseclick,"normal") $doubleclicked = 0 EndIf $start = TimerInit() EndSelect GUICtrlSetData($msginfo,$msg) WEnd GUIDelete() Exit So long... Holger Old project:GUI/Tray menu with icons and colors Other old stuff:IconFileScanner, TriState/ThreeState GUI TreeView, GUI ContextMenu created out of a TreeView Link to comment Share on other sites More sharing options...
GaryFrost Posted February 11, 2005 Share Posted February 11, 2005 This works great till you add a menu, the menu works fine as longas the listview is not clicked even one timethe below is modified for the above problem, need help in how to resolve this.Here is my small example that I used days ago for testing and rewrote it a little bit expandcollapse popup#include <GUIConstants.au3> GUICreate("test") $menuFile = GUICtrlCreateMenu ("&File") $menuFileExit = GUICtrlCreateMenuitem ("Exit",$menuFile) $msginfo = GUICtrlCreateLabel("",0,0,100,20) $clicktime = GUICtrlCreateLabel("",100,0,100,20) $mouseclick = GUICtrlCreateLabel("normal",100,20,40,20) $listv = GUICtrlCreateListView("Name|Firstname",50,100,250,100) $item1 = GUICtrlCreateListViewItem("Black|Mr.",$listv) $item2 = GUICtrlCreateListViewItem("White|Dr.",$listv) GUISetState() $start = 0 $diff = 0 $doubleclicked = 0 While 1 $msg = GUIGetMsg() Select Case $msg = 0 ContinueLoop Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $menuFileExit ExitLoop Case $msg = $GUI_EVENT_PRIMARYDOWN $diff = TimerDiff($start) GUICtrlSetData($clicktime,$diff) ; Read the current mouse-doubleclick-settings from registry $mousespeed = RegRead("HKCU\Control Panel\Mouse","DoubleClickSpeed") If $mousespeed = "" Then $mousespeed = 500 If $diff < $mousespeed And $doubleclicked = 0 Then GUICtrlSetData($mouseclick,"double") $itemclicked = GUICtrlRead($listv) If $itemclicked > 0 Then Msgbox(64,"Item clicked",GUICtrlRead($itemclicked)) EndIf $doubleclicked = 1 Else GUICtrlSetData($mouseclick,"normal") $doubleclicked = 0 EndIf $start = TimerInit() EndSelect GUICtrlSetData($msginfo,$msg) WEnd GUIDelete() ExitSo long...Holger<{POST_SNAPBACK}> SciTE for AutoItDirections for Submitting Standard UDFs  Don't argue with an idiot; people watching may not be able to tell the difference.  Link to comment Share on other sites More sharing options...
GaryFrost Posted February 18, 2005 Share Posted February 18, 2005 Didn't get any help on this one, so kept playing with ideas, this works It's not perfect but at least it works This allows to have menus and a primarydown (used for double clicking a item in the listview) expandcollapse popup#include <GUIConstants.au3> $main_window = GUICreate("test",500,500,-1,-1) $menuFile = GUICtrlCreateMenu ("&File") $menuFileExit = GUICtrlCreateMenuitem ("Exit",$menuFile) $msginfo = GUICtrlCreateLabel("",0,0,100,20) $clicktime = GUICtrlCreateLabel("",100,0,100,20) $mouseclick = GUICtrlCreateLabel("normal",100,20,40,20) $exit = GUICtrlCreateButton ("Exit",355,450,120,20) GUICtrlSetState($exit,$GUI_FOCUS) ; the focus is on this button $listv = GUICtrlCreateListView("Name|Firstname",50,100,250,100) $item1 = GUICtrlCreateListViewItem("Black|Mr.",$listv) $item2 = GUICtrlCreateListViewItem("White|Dr.",$listv) GUISetState() $start = 0 $diff = 0 $doubleclicked = 0 While 1 $msg = GUIGetMsg() Select Case $msg = 0 ContinueLoop Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $exit Or $msg = $menuFileExit ExitLoop Case $msg = $GUI_EVENT_PRIMARYDOWN Local $focus = ControlGetFocus(WinGetTitle("")) If($focus == "SysListView321") Then $diff = TimerDiff($start) GUICtrlSetData($clicktime,$diff) ; Read the current mouse-doubleclick-settings from registry $mousespeed = RegRead("HKCU\Control Panel\Mouse","DoubleClickSpeed") If $mousespeed = "" Then $mousespeed = 500 If $diff < $mousespeed And $doubleclicked = 0 Then GUICtrlSetData($mouseclick,"double") $itemclicked = GUICtrlRead($listv) If $itemclicked > 0 Then Msgbox(64,"Item clicked",GUICtrlRead($itemclicked)) EndIf $doubleclicked = 1 Else GUICtrlSetData($mouseclick,"normal") $doubleclicked = 0 EndIf $start = TimerInit() EndIf Case $msg = $GUI_EVENT_PRIMARYUP GUICtrlSetState($exit,$GUI_FOCUS) ; the focus is on this button, take the focus away from the listview EndSelect GUICtrlSetData($msginfo,$msg) WEnd GUIDelete() Exit SciTE for AutoItDirections for Submitting Standard UDFs  Don't argue with an idiot; people watching may not be able to tell the difference.  Link to comment Share on other sites More sharing options...
bshoenhair Posted February 18, 2005 Share Posted February 18, 2005 @gafrost You still have a similar issue, if the listview is clicked once then you click the GUI Form it is still trigered. Link to comment Share on other sites More sharing options...
Ajay Posted November 3, 2005 Share Posted November 3, 2005 Try this. It verifies mouse position. I tried to use this on a list box but the list box grabs the double click. This forces you to triple click when used on a list box. expandcollapse popup#include <GUIConstants.au3> $main_window = GUICreate("test",500,500,-1,-1) $menuFile = GUICtrlCreateMenu ("&File") $menuFileExit = GUICtrlCreateMenuitem ("Exit",$menuFile) $msginfo = GUICtrlCreateLabel("",0,0,100,20) $clicktime = GUICtrlCreateLabel("",100,0,100,20) $mouseclick = GUICtrlCreateLabel("normal",100,20,40,20) $exit = GUICtrlCreateButton ("Exit",355,450,120,20) GUICtrlSetState($exit,$GUI_FOCUS) ; the focus is on this button dim $listLoc[4] $listv = GUICtrlCreateListView("Name|Firstname",50,100,400,100) $item1 = GUICtrlCreateListViewItem("Black|Mr.",$listv) $item2 = GUICtrlCreateListViewItem("White|Dr.",$listv) GUISetState() $start = 0 $diff = 0 $doubleclicked = 0 dim $lastPos[2] While 1 $msg = GUIGetMsg() Select Case $msg = 0 ContinueLoop Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $exit Or $msg = $menuFileExit ExitLoop Case $msg = $GUI_EVENT_PRIMARYDOWN $diff = TimerDiff($start) GUICtrlSetData($clicktime,$diff) ; Read the current mouse-doubleclick-settings from registry $mousespeed = RegRead("HKCU\Control Panel\Mouse","DoubleClickSpeed") If $mousespeed = "" Then $mousespeed = 500 If $diff < $mousespeed And $doubleclicked = 0 and not ValidDoubleClick($lastPos, MouseGetPos(), "SysListView321") Then GUICtrlSetData($mouseclick,"double") $itemclicked = GUICtrlRead($listv) If $itemclicked > 0 Then Msgbox(64,"Item clicked",GUICtrlRead($itemclicked)) EndIf $doubleclicked = 1 Else GUICtrlSetData($mouseclick,"normal") $doubleclicked = 0 $lastPos = MouseGetPos() EndIf $start = TimerInit() EndSelect GUICtrlSetData($msginfo,$msg) WEnd GUIDelete() Exit Func ValidDoubleClick($old, $new, $control) $handle = ControlGetHandle(WinGetTitle(""), "", $control) AutoItSetOption("WinTitleMatchMode", 4) $pos = WinGetPos ($handle, "") AutoItSetOption("WinTitleMatchMode", 1) if $new[0] < $pos[0] or $new[0] > ($pos[0] + $pos[2]) then return 1 if $new[1] < $pos[1] or $new[1] > ($pos[1] + $pos[3]) then return 1 $dx = $old[0] - $new[0] $dy = $old[1] - $new[1] if $dx < -4 or $dx > 4 or $dy < -4 or $dy > 4 then return 1 return 0 EndFunc Link to comment Share on other sites More sharing options...
Ajay Posted November 3, 2005 Share Posted November 3, 2005 Be warned: Still shows double click if you double click on the column headings. I can live with that. Link to comment Share on other sites More sharing options...
ReFran Posted November 3, 2005 Share Posted November 3, 2005 Be warned: Still shows double click if you double click on the column headings. I can live with that.Can be used as a feature. Simple click = Sort ascending, Double click = Sort descending.Maybe less work as to store the last used sort direction. Thanks to all, for the examples, Reinhard Link to comment Share on other sites More sharing options...
Luffy Posted November 13, 2005 Share Posted November 13, 2005 another modification/solution, works very well for me expandcollapse popup... Opt("GUIOnEventMode",1) ... $dbl_oldx=0 $dbl_oldy=0 $dbl_StartTime=0 GUISetOnEvent($GUI_EVENT_PRIMARYDOWN,"mouseClicks") ... Func _DoubleClicked($winhandle,$ControlHandle=0) Local $info= GUIGetCursorInfo ($winhandle) Local $diff = TimerDiff($dbl_startTime) Local $mousespeed = RegRead("HKCU\Control Panel\Mouse","DoubleClickSpeed") If $mousespeed = "" Then $mousespeed = 500 IF $diff < $mousespeed and $dbl_oldx=$info[0] and $dbl_oldy=$info[1] Then $dbl_oldx=0 $dbl_oldy=0 $dbl_StartTime=0 If $ControlHandle=0 Then return $info[4] Else if $ControlHandle=$info[4] Then return True Else return False Endif Endif Else $dbl_oldx=$info[0] $dbl_oldy=$info[1] $dbl_StartTime=TimerInit() Endif EndFunc Func mouseClicks() Select Case _DoubleClicked($GUIHandle,$ListViewHandle) ConsoleWrite(_GUICtrlListViewGetCurSel($ListViewHandle)) EndSelect Endfunc 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