Hallo Leute ich hab mal eine Frage:
Weiß jemand wie ich es machen kann, das etwas pasiert, wenn ich einen Doppelklick auf einen Button oder so was in der Gui mache, und nicht wenn ich nur einen mache? Und geht sowas auch bei Einer ListBox wenn ich da auf einen Item doppelt klicke?
Doppelklick
-
- [ offen ]
-
Jam00 -
22. Januar 2009 um 18:19 -
Geschlossen -
Erledigt
-
-
- Offizieller Beitrag
Eine Möglichkeit wäre dieses etwas angestaubte Skript von mir: Doppelklick für (fast) jedes Control
Eine andere Variante ist das Auswerten der Message Doppelklick (für Listview z.B. $NM_DBLCLK über GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") ). Mußt du dir die für das entsprechende Control zuständigen Messagecodes mal raussuchen. -
Danke
Könntest du mir das mit dem ListBox mal genauer Erklären? Das ist nähmlich auch wichtig! -
Müsst ihr für die jeweiligen befehle anpassen wo das auf gehn soll
Spoiler anzeigen
[autoit]#cs ----------------------------------------------------------------------------
[/autoit] [autoit][/autoit] [autoit]AutoIt Version: 3.3.0.0
[/autoit] [autoit][/autoit] [autoit]
Author: myNameScript Function:
[/autoit] [autoit][/autoit] [autoit]
Template AutoIt script.#ce ----------------------------------------------------------------------------
[/autoit] [autoit][/autoit] [autoit]; Script Start - Add your code below here
[/autoit] [autoit][/autoit] [autoit]
#Region ### START Koda GUI section ### Form=H:\Projeckte\CDN Argentur\Programm\New\Form\Terminplanung.kxf
#EndRegion ### END Koda GUI section ###_FillListView()
[/autoit] [autoit][/autoit] [autoit]GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]Func _LeftDblClick($info) ; Inhalt der angeklickten Zeile (alle Spalten) wird in GUI gezeigt
[/autoit] [autoit][/autoit] [autoit]
GUICtrlSetData($dd_datum , _GUICtrlListView_GetItemText(GUICtrlGetHandle($Listview1), $Info[3], 1))
GUICtrlSetData($Input14, _GUICtrlListView_GetItemText(GUICtrlGetHandle($Listview1), $Info[3], 2))
GUICtrlSetData($Input1 , _GUICtrlListView_GetItemText(GUICtrlGetHandle($Listview1), $Info[3], 3))
GUICtrlSetData($Input15 , _GUICtrlListView_GetItemText(GUICtrlGetHandle($Listview1), $Info[3], 4))
GUICtrlSetData($Input2 , _GUICtrlListView_GetItemText(GUICtrlGetHandle($Listview1), $Info[3], 5))
GUICtrlSetData($Input3 , _GUICtrlListView_GetItemText(GUICtrlGetHandle($Listview1), $Info[3], 6))
GUICtrlSetData($Input4 , _GUICtrlListView_GetItemText(GUICtrlGetHandle($Listview1), $Info[3], 7))
GUICtrlSetData($Input5, _GUICtrlListView_GetItemText(GUICtrlGetHandle($Listview1), $Info[3], 8))
GUICtrlSetData($Input6 , _GUICtrlListView_GetItemText(GUICtrlGetHandle($Listview1), $Info[3], 9))
GUICtrlSetData($Input7 , _GUICtrlListView_GetItemText(GUICtrlGetHandle($Listview1), $Info[3], 10))
GUICtrlSetData($Input8 , _GUICtrlListView_GetItemText(GUICtrlGetHandle($Listview1), $Info[3], 11))
GUICtrlSetData($Edit1 , _GUICtrlListView_GetItemText(GUICtrlGetHandle($Listview1), $Info[3], 12))
GUICtrlSetData($Input9 , _GUICtrlListView_GetItemText(GUICtrlGetHandle($Listview1), $Info[3], 13))
GUICtrlSetData($Input10 , _GUICtrlListView_GetItemText(GUICtrlGetHandle($Listview1), $Info[3], 14))
GUICtrlSetData($Input11 , _GUICtrlListView_GetItemText(GUICtrlGetHandle($Listview1), $Info[3], 15))
GUICtrlSetData($Input12 , _GUICtrlListView_GetItemText(GUICtrlGetHandle($Listview1), $Info[3], 16))
GUICtrlSetData($Input13 , _GUICtrlListView_GetItemText(GUICtrlGetHandle($Listview1), $Info[3], 17))
GUICtrlSetData($Edit2 , _GUICtrlListView_GetItemText(GUICtrlGetHandle($Listview1), $Info[3], 18))
GUISetState(@SW_SHOW, $hGui2)
EndFuncFunc WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
[/autoit] [autoit][/autoit] [autoit]
Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView
$hWndListView = $ListView1
If Not IsHWnd($ListView1) Then $hWndListView = GUICtrlGetHandle($ListView1)$tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
[/autoit]
$hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
$iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
$iCode = DllStructGetData($tNMHDR, "Code")
Switch $hWndFrom
Case $hWndListView
Switch $iCode
Case $NM_DBLCLK ; Sent by a list-view control when the user double-clicks an item with the left mouse button
Local $tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam)
Local $aInfo[12] = [$hWndFrom, _
$iIDFrom, _
$iCode, _
DllStructGetData($tInfo, "Index"), _
DllStructGetData($tInfo, "SubItem"), _
DllStructGetData($tInfo, "NewState"), _
DllStructGetData($tInfo, "OldState"), _
DllStructGetData($tInfo, "Changed"), _
DllStructGetData($tInfo, "ActionX"), _
DllStructGetData($tInfo, "ActionY"), _
DllStructGetData($tInfo, "lParam"), _
DllStructGetData($tInfo, "KeyFlags")]
_LeftDblClick($aInfo)
Case $NM_RCLICK ; Sent by a list-view control when the user clicks an item with the right mouse button
Return $GUI_RUNDEFMSG ; allow the default processing
EndSwitch
EndSwitch
Return $GUI_RUNDEFMSG
EndFunc ;==>WM_NOTIFY -
Kann mir keiner Helfen?
-
- Offizieller Beitrag
Es stehen zum Thema Listview mehrere Bsp. in der Hilfe, aus denen das ersichtlich ist.
Ich habe es mal zusammengefaßt:Spoiler anzeigen
[autoit]#include<GUIConstantsEx.au3>
[/autoit] [autoit][/autoit] [autoit]
#include<WindowsConstants.au3>
#include <GUIListView.au3>$gui = GUICreate('test')
[/autoit] [autoit][/autoit] [autoit]
$hListView = GUICtrlCreateListView('Spalte1|Spalte2', 10, 10, 300, 200)
_GUICtrlListView_SetColumnWidth($hListView, 0, 146)
_GUICtrlListView_SetColumnWidth($hListView, 1, $LVSCW_AUTOSIZE_USEHEADER)
For $i = 1 To 10
GUICtrlCreateListViewItem('Zeile ' & $i & ' Spalte 1|Zeile ' & $i & ' Spalte 2', $hListView)
Next
GUISetState()
GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")
Do
$msg = GUIGetMsg()
Until $msg = $GUI_EVENT_CLOSEFunc _LeftDblClick($Info)
[/autoit] [autoit][/autoit] [autoit]
MsgBox(0, 'Text in Spalte', _GUICtrlListView_GetItemText($Info[1], $Info[3], $Info[4]) )
EndFuncFunc WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
[/autoit] [autoit][/autoit] [autoit]
Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView
$hWndListView = $hListView
If Not IsHWnd($hListView) Then $hWndListView = GUICtrlGetHandle($hListView)$tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
[/autoit]
$hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
$iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
$iCode = DllStructGetData($tNMHDR, "Code")
Switch $hWndFrom
Case $hWndListView
Switch $iCode
Case $LVN_COLUMNCLICK ; A column was clicked
Local $tInfo = DllStructCreate($tagNMLISTVIEW, $ilParam)
Local $aInfo[11] = [$hWndFrom, _
$iIDFrom, _
$iCode, _
DllStructGetData($tInfo, "Index"), _
DllStructGetData($tInfo, "SubItem"), _
DllStructGetData($tInfo, "NewState"), _
DllStructGetData($tInfo, "OldState"), _
DllStructGetData($tInfo, "Changed"), _
DllStructGetData($tInfo, "ActionX"), _
DllStructGetData($tInfo, "ActionY"), _
DllStructGetData($tInfo, "Param")]
;~ _ColumnClick($aInfo)
Case $LVN_DELETEITEM ; An item is about to be deleted
Local $tInfo = DllStructCreate($tagNMLISTVIEW, $ilParam)
Local $aInfo[11] = [$hWndFrom, _
$iIDFrom, _
$iCode, _
DllStructGetData($tInfo, "Index"), _
DllStructGetData($tInfo, "SubItem"), _
DllStructGetData($tInfo, "NewState"), _
DllStructGetData($tInfo, "OldState"), _
DllStructGetData($tInfo, "Changed"), _
DllStructGetData($tInfo, "ActionX"), _
DllStructGetData($tInfo, "ActionY"), _
DllStructGetData($tInfo, "Param")]
;~ _ItemDeleted($aInfo)
Case $LVN_HOTTRACK ; Sent by a list-view control when the user moves the mouse over an item
Local $tInfo = DllStructCreate($tagNMLISTVIEW, $ilParam)
Local $aInfo[11] = [$hWndFrom, _
$iIDFrom, _
$iCode, _
DllStructGetData($tInfo, "Index"), _
DllStructGetData($tInfo, "SubItem"), _
DllStructGetData($tInfo, "NewState"), _
DllStructGetData($tInfo, "OldState"), _
DllStructGetData($tInfo, "Changed"), _
DllStructGetData($tInfo, "ActionX"), _
DllStructGetData($tInfo, "ActionY"), _
DllStructGetData($tInfo, "Param")]
Return 0 ; allow the list view to perform its normal track select processing.
;Return 1 ; the item will not be selected.
;~ _HottTrackItem($aInfo)
Case $LVN_KEYDOWN ; A key has been pressed
Local $tInfo = DllStructCreate($tagNMLVKEYDOWN, $ilParam)
Local $aInfo[5] = [$hWndFrom, _
$iIDFrom, _
$iCode, _
DllStructGetData($tInfo, "VKey"), _
DllStructGetData($tInfo, "KeyFlags")]
;~ _KeyDown($aInfo)
Case $NM_CLICK ; Sent by a list-view control when the user clicks an item with the left mouse button
Local $tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam)
Local $aInfo[12] = [$hWndFrom, _
$iIDFrom, _
$iCode, _
DllStructGetData($tInfo, "Index"), _
DllStructGetData($tInfo, "SubItem"), _
DllStructGetData($tInfo, "NewState"), _
DllStructGetData($tInfo, "OldState"), _
DllStructGetData($tInfo, "Changed"), _
DllStructGetData($tInfo, "ActionX"), _
DllStructGetData($tInfo, "ActionY"), _
DllStructGetData($tInfo, "lParam"), _
DllStructGetData($tInfo, "KeyFlags")]
;~ _LeftClick($aInfo)
Case $NM_DBLCLK ; Sent by a list-view control when the user double-clicks an item with the left mouse button
Local $tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam)
Local $aInfo[12] = [$hWndFrom, _
$iIDFrom, _
$iCode, _
DllStructGetData($tInfo, "Index"), _
DllStructGetData($tInfo, "SubItem"), _
DllStructGetData($tInfo, "NewState"), _
DllStructGetData($tInfo, "OldState"), _
DllStructGetData($tInfo, "Changed"), _
DllStructGetData($tInfo, "ActionX"), _
DllStructGetData($tInfo, "ActionY"), _
DllStructGetData($tInfo, "lParam"), _
DllStructGetData($tInfo, "KeyFlags")]
_LeftDblClick($aInfo)
Case $NM_KILLFOCUS ; The control has lost the input focus
Local $aInfo[3] = [$hWndFrom, _
$iIDFrom, _
$iCode]
;~ _LostFocus($aInfo)
Case $NM_RCLICK ; Sent by a list-view control when the user clicks an item with the right mouse button
Local $tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam)
Local $aInfo[12] = [$hWndFrom, _
$iIDFrom, _
$iCode, _
DllStructGetData($tInfo, "Index"), _
DllStructGetData($tInfo, "SubItem"), _
DllStructGetData($tInfo, "NewState"), _
DllStructGetData($tInfo, "OldState"), _
DllStructGetData($tInfo, "Changed"), _
DllStructGetData($tInfo, "ActionX"), _
DllStructGetData($tInfo, "ActionY"), _
DllStructGetData($tInfo, "lParam"), _
DllStructGetData($tInfo, "KeyFlags")]
; Return 1 ; not to allow the default processing
Return 0 ; allow the default processing
;~ _RightClick($aInfo)
Case $NM_RDBLCLK ; Sent by a list-view control when the user double-clicks an item with the right mouse button
Local $tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam)
Local $aInfo[12] = [$hWndFrom, _
$iIDFrom, _
$iCode, _
DllStructGetData($tInfo, "Index"), _
DllStructGetData($tInfo, "SubItem"), _
DllStructGetData($tInfo, "NewState"), _
DllStructGetData($tInfo, "OldState"), _
DllStructGetData($tInfo, "Changed"), _
DllStructGetData($tInfo, "ActionX"), _
DllStructGetData($tInfo, "ActionY"), _
DllStructGetData($tInfo, "lParam"), _
DllStructGetData($tInfo, "KeyFlags")]
;~ _RightDblClick($aInfo)
Case $NM_RETURN ; The control has the input focus and that the user has pressed the ENTER key
Local $aInfo[3] = [$hWndFrom, _
$iIDFrom, _
$iCode]
;~ _InputFocusReturn($aInfo)
Case $NM_SETFOCUS ; The control has received the input focus
Local $aInfo[3] = [$hWndFrom, _
$iIDFrom, _
$iCode]
;~ _SetFocus($aInfo)
EndSwitch
EndSwitch
Return $GUI_RUNDEFMSG
EndFunc ;==>WM_NOTIFY -
ja eben, zu listview, ich brauche aber zu listbox (GuiCtrlCreateList) und nicht zu ListView
-
- Offizieller Beitrag
Und warum guckst du dann nicht in die Hilfe zu ListBox? Steht dort genauso - hier mal ohne die DebugPrint-Aufrufe:
Spoiler anzeigen
[autoit]#include <GUIListBox.au3>
[/autoit] [autoit][/autoit] [autoit]
#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>
#include <Constants.au3>Opt('MustDeclareVars', 1)
[/autoit] [autoit][/autoit] [autoit]$Debug_LB = False ; Check ClassName being passed to ListBox functions, set to True and use a handle to another control to see it work
[/autoit] [autoit][/autoit] [autoit]Global $hListBox
[/autoit] [autoit][/autoit] [autoit]_Main()
[/autoit] [autoit][/autoit] [autoit]Func _Main()
[/autoit] [autoit][/autoit] [autoit]
Local $hGUI; Create GUI
[/autoit] [autoit][/autoit] [autoit]
$hGUI = GUICreate("(UDF Created) List Box Create", 400, 296)
$hListBox = _GUICtrlListBox_Create($hGUI, "String upon creation", 2, 2, 396, 296)
GUISetState()
[/autoit] [autoit][/autoit] [autoit]
GUIRegisterMsg($WM_COMMAND, "WM_COMMAND"); Add files
[/autoit] [autoit][/autoit] [autoit]
_GUICtrlListBox_BeginUpdate($hListBox)
_GUICtrlListBox_ResetContent($hListBox)
_GUICtrlListBox_InitStorage($hListBox, 100, 4096)
_GUICtrlListBox_Dir($hListBox, @WindowsDir & "\win*.exe")
_GUICtrlListBox_AddFile($hListBox, @WindowsDir & "\Notepad.exe")
_GUICtrlListBox_Dir($hListBox, "", $DDL_DRIVES)
_GUICtrlListBox_Dir($hListBox, "", $DDL_DRIVES, False)
_GUICtrlListBox_EndUpdate($hListBox); Loop until user exits
[/autoit] [autoit][/autoit] [autoit]
Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc ;==>_MainFunc _ListDblClick()
[/autoit] [autoit][/autoit] [autoit]
Local $indx = _GUICtrlListBox_GetCurSel($hListBox)
MsgBox(0, 'Doppelklick auf:', _GUICtrlListBox_GetText($hListBox, $indx))
EndFuncFunc WM_COMMAND($hWnd, $iMsg, $iwParam, $ilParam)
[/autoit] [autoit][/autoit] [autoit]
#forceref $hWnd, $iMsg
Local $hWndFrom, $iIDFrom, $iCode, $hWndListBox
If Not IsHWnd($hListBox) Then $hWndListBox = GUICtrlGetHandle($hListBox)
$hWndFrom = $ilParam
$iIDFrom = BitAND($iwParam, 0xFFFF) ; Low Word
$iCode = BitShift($iwParam, 16) ; Hi WordSwitch $hWndFrom
[/autoit]
Case $hListBox, $hWndListBox
Switch $iCode
Case $LBN_DBLCLK ; Sent when the user double-clicks a string in a list box
Return _ListDblClick()
Case $LBN_ERRSPACE ; Sent when a list box cannot allocate enough memory to meet a specific request
;~ Return _ListErrSpace()
Case $LBN_KILLFOCUS ; Sent when a list box loses the keyboard focus
;~ Return _ListKillFocus()
Case $LBN_SELCANCEL ; Sent when the user cancels the selection in a list box
;~ Return _ListSelCancel()
Case $LBN_SELCHANGE ; Sent when the selection in a list box has changed
;~ Return _ListSelChange()
Case $LBN_SETFOCUS ; Sent when a list box receives the keyboard focus
;~ Return _ListSetFocus()
EndSwitch
EndSwitch
Return $GUI_RUNDEFMSG
EndFunc ;==>WM_COMMAND -
Weil ich da nicht kapier wie das gehen soll^^ danke, dann arbeite ich mich da mal druch
-
- Offizieller Beitrag
Noch ein Hinweis:
[autoit]
Wenn die Listbox mit GUICtrlCreateList() erstellt wurde, solltest du sicherheitshalber für die UDF das Handle verwenden. Dann ist gesichert, dass die Func's aus der UDF auch wirksam sind.$ListBox = GUICtrlCreateList()
[/autoit]
$hListBox = GUICtrlGetHandle($ListBox)