Показать полную графическую версию : [решено] отловить двойной клик по GuiCtrlCreateList
morgan1991
04-04-2009, 20:33
Здравствуйте!
Вобщем такой вопросик возник.
Как из этого:
#include <GuiConstantsEx.au3>
#include <AVIConstants.au3>
#include <TreeViewConstants.au3>
; GUI
GuiCreate("Sample GUI", 400, 400)
; LIST
$ggg = GuiCtrlCreateList("", 5, 190, 100, 90)
GuiCtrlSetData(-1, "a.Sample|b.List|c.Control|d.Here", "b.List")
GuiCtrlSetData(-1, "")
GuiCtrlSetData(-1, "аенгеаг.Sample|b.List", "b.List")
; GUI MESSAGE LOOP
GuiSetState()
While 1
$msg = GuiGetMsg()
If $msg = $GUI_EVENT_CLOSE Then Exit
If $msg = $ggg Then
$gggg = GUICtrlRead($ggg)
MsgBox(0, "", $gggg)
EndIf
WEnd
сделать так чтобы отлавливалось не одинарное нажатие а двойное? И так же чтобы выводилось?
#include <GuiConstantsEx.au3>
#include <AVIConstants.au3>
#include <TreeViewConstants.au3>
#include <Constants.au3>
#include <GUIListBox.au3>
#include <WindowsConstants.au3>
; GUI
GuiCreate("Sample GUI", 400, 400)
; LIST
Global $ggg = GuiCtrlCreateList("", 5, 190, 100, 90)
GuiCtrlSetData(-1, "a.Sample|b.List|c.Control|d.Here", "b.List")
GuiCtrlSetData(-1, "")
GuiCtrlSetData(-1, "аенгеаг.Sample|b.List", "b.List")
GUIRegisterMsg($WM_COMMAND, "WM_COMMAND")
; GUI MESSAGE LOOP
GuiSetState()
While 1
$msg = GuiGetMsg()
If $msg = $GUI_EVENT_CLOSE Then Exit
;~ If $msg = $ggg Then
;~ $gggg = GUICtrlRead($ggg)
;~ MsgBox(0, "", $gggg)
;~ EndIf
WEnd
Func WM_COMMAND($hWnd, $iMsg, $iwParam, $ilParam)
#forceref $hWnd, $iMsg
Local $hWndFrom, $iIDFrom, $iCode, $hWndListBox
If Not IsHWnd($ggg) Then $hWndListBox = GUICtrlGetHandle($ggg)
$hWndFrom = $ilParam
$iIDFrom = BitAND($iwParam, 0xFFFF) ; Low Word
$iCode = BitShift($iwParam, 16) ; Hi Word
Switch $hWndFrom
Case $hWndListBox
Switch $iCode
Case $LBN_DBLCLK ; Sent when the user double-clicks a string in a list box
_DebugPrint("$LBN_DBLCLK" & @LF & "--> hWndFrom:" & @TAB & $hWndFrom & @LF & _
"-->IDFrom:" & @TAB & $iIDFrom & @LF & _
"-->Code:" & @TAB & $iCode)
; no return value
MsgBox(64, "--> hWndFrom:" & $hWndFrom, "$LBN_DBLCLK")
Case $LBN_ERRSPACE ; Sent when a list box cannot allocate enough memory to meet a specific request
_DebugPrint("$LBN_ERRSPACE" & @LF & "--> hWndFrom:" & @TAB & $hWndFrom & @LF & _
"-->IDFrom:" & @TAB & $iIDFrom & @LF & _
"-->Code:" & @TAB & $iCode)
; no return value
Case $LBN_KILLFOCUS ; Sent when a list box loses the keyboard focus
_DebugPrint("$LBN_KILLFOCUS" & @LF & "--> hWndFrom:" & @TAB & $hWndFrom & @LF & _
"-->IDFrom:" & @TAB & $iIDFrom & @LF & _
"-->Code:" & @TAB & $iCode)
; no return value
Case $LBN_SELCANCEL ; Sent when the user cancels the selection in a list box
_DebugPrint("$LBN_SELCANCEL" & @LF & "--> hWndFrom:" & @TAB & $hWndFrom & @LF & _
"-->IDFrom:" & @TAB & $iIDFrom & @LF & _
"-->Code:" & @TAB & $iCode)
; no return value
Case $LBN_SELCHANGE ; Sent when the selection in a list box has changed
_DebugPrint("$LBN_SELCHANGE" & @LF & "--> hWndFrom:" & @TAB & $hWndFrom & @LF & _
"-->IDFrom:" & @TAB & $iIDFrom & @LF & _
"-->Code:" & @TAB & $iCode)
; no return value
Case $LBN_SETFOCUS ; Sent when a list box receives the keyboard focus
_DebugPrint("$LBN_SETFOCUS" & @LF & "--> hWndFrom:" & @TAB & $hWndFrom & @LF & _
"-->IDFrom:" & @TAB & $iIDFrom & @LF & _
"-->Code:" & @TAB & $iCode)
; no return value
EndSwitch
EndSwitch
; Proceed the default Autoit3 internal message commands.
; You also can complete let the line out.
; !!! But only 'Return' (without any value) will not proceed
; the default Autoit3-message in the future !!!
Return $GUI_RUNDEFMSG
EndFunc ;==>WM_COMMAND
Func _DebugPrint($s_text)
$s_text = StringReplace($s_text, @LF, @LF & "-->")
ConsoleWrite("!===========================================================" & @LF & _
"+===========================================================" & @LF & _
"-->" & $s_text & @LF & _
"+===========================================================" & @LF)
EndFunc ;==>_DebugPrint
справка по UDF - очень полезная штука )
morgan1991
04-04-2009, 21:09
Спасибо,
справка по UDF - очень полезная штука ) »
я о таких командах даже не слышал:
IsHWnd
BitAND
BitShift
А что такое UDF?
я о таких командах даже не слышал:
Справка AutoIt > Указатель функций > Преобразование переменных > IsHWnd
- Проверка переменной на принадлежность к типу HWND (т.е. то, что в переменной это хэндл (указатель) на окно или же нет)
Справка AutoIt > Указатель функций > Арифметические функции > BitAND
- Выполнить побитовое логическое умножение AND (для вычисления значений, хороший пример на WinGetState)
Справка AutoIt > Указатель функций > Арифметические функции > BitShift
- Выполнить битовый сдвиг числа (для вычисления значений)
Английская справка Online:
IsHWnd (http://www.autoitscript.com/autoit3/docs/functions/IsHWnd.htm)
BitAND (http://www.autoitscript.com/autoit3/docs/functions/BitAND.htm)
BitShift (http://www.autoitscript.com/autoit3/docs/functions/BitShift.htm)
Справка по UDF:
<папка установки AutoIt>\UDFs.chm (название файла немного может отличатся)
Все стандартные функции есть в русской справке.
Но необходимо сверяться с английской, т.к. русская справка не по последней версии AutoIt,
со времинем запоминаются отличия, их не много.
Либо сразу "общаться" только с английской.
В справке по UDF (Справка пользовательских функций) содержит не стандартный
функции - они все находятся в Include файлах (<папка установки AutoIt>\Include\).
Маленькая часть UDF есть в русской справке:
Справка AutoIt > Указатель библиотечных функций
morgan1991
04-04-2009, 23:17
Скажите ещё пожалуйста как можно удалить элемент из GuiCtrlCreateList?
как можно удалить элемент из GuiCtrlCreateList? »
См. _GUICtrlListBox_DeleteString функцию в справке.
morgan1991
04-04-2009, 23:57
См. _GUICtrlListBox_DeleteString функцию в справке. »
не я имел ввиду удалить выделенную ячейку.
я имел ввиду удалить выделенную ячейку »
Неужели так сложно заглянуть в справку и посмотреть пример на эту функцию? :)
Просто вместо индекса поставить выделенную строку:
#include <GuiConstantsEx.au3>
#include <GUIListBox.au3>
;
; Create GUI
GUICreate("List Box Delete String", 400, 300)
$hListBox = GUICtrlCreateList("", 2, 2, 396, 270)
$DeleteString_Button = GUICtrlCreateButton("Delete Selected", 2, 275, 120, 20)
GUISetState()
; Add strings
_GUICtrlListBox_BeginUpdate($hListBox)
For $iI = 1 To 9
_GUICtrlListBox_AddString($hListBox, StringFormat("%d : List box string", $iI))
Next
_GUICtrlListBox_EndUpdate($hListBox)
; Loop until user exits
While 1
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
Exit
Case $DeleteString_Button
$iSelected_Index = _GUICtrlListBox_GetCurSel($hListBox)
; Delete selected string
_GUICtrlListBox_DeleteString($hListBox, $iSelected_Index)
; Select current string
$iSelected = _GUICtrlListBox_SetCurSel($hListBox, $iSelected_Index)
If $iSelected = -1 Then _GUICtrlListBox_SetCurSel($hListBox, $iSelected_Index-1)
EndSwitch
WEnd
morgan1991
05-04-2009, 00:19
В английской справке сложно чтолибо найти, лично я нашол только это:
$temp = GUICtrlRead($hWnd)
_GUICtrlListBox_DeleteString($hWnd, _GUICtrlListBox_SelectString($hWnd, $temp))
В английской справке сложно чтолибо найти »
В скрипте набираем нужную функцию, ставим на неё курсор, нажимаем F1, и видим справку для этой функции.
morgan1991
28-04-2009, 23:21
Скажите пожалуйста, а как отловить тот же двойной клик только по GUICtrlCreateListView?
как отловить тот же двойной клик только по GUICtrlCreateListView? »
#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GuiListView.au3>
;
Global $iDouble_Click_Event = 0
$hGUI = GUICreate("(Internal) ListView Get Item Text", 400, 300)
$nListView = GUICtrlCreateListView("Items", 2, 2, 394, 268)
GUICtrlCreateListViewItem("Item 1", $nListView)
GUICtrlCreateListViewItem("Item 2", $nListView)
GUICtrlCreateListViewItem("Item 3", $nListView)
_GUICtrlListView_SetColumnWidth($nListView, 0, 100)
GUISetState()
GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")
While GUIGetMsg() <> $GUI_EVENT_CLOSE
If $iDouble_Click_Event Then
$iDouble_Click_Event = 0
MsgBox(64, 'Title', 'Double click (main m.button) event recieved.')
EndIf
WEnd
Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView
$hWndListView = $nListView
If Not IsHWnd($nListView) Then $hWndListView = GUICtrlGetHandle($nListView)
$tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
$hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
$iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
$iCode = DllStructGetData($tNMHDR, "Code")
Switch $hWndFrom
Case $hWndListView
Switch $iCode
Case $LVN_BEGINDRAG; A drag-and-drop operation involving the left mouse button is being initiated
Case $LVN_BEGINLABELEDIT; Start of label editing for an item
Return False; Allow the user to edit the label
;Return True; Prevent the user from editing the label
Case $LVN_BEGINSCROLL; A scrolling operation starts, Minium OS WinXP
Case $LVN_COLUMNCLICK; A column was clicked
Case $LVN_DELETEALLITEMS; All items in the control are about to be deleted
Return True; To suppress subsequent $LVN_DELETEITEM messages
;Return False; To receive subsequent $LVN_DELETEITEM messages
Case $LVN_DELETEITEM; An item is about to be deleted
Case $LVN_ENDLABELEDIT; The end of label editing for an item
; If Text is not empty, return True to set the item's label to the edited text, return false to reject it
; If Text is empty the return value is ignored
Return True
Case $LVN_ENDSCROLL; A scrolling operation ends, Minium OS WinXP
Case $LVN_GETDISPINFO; Provide information needed to display or sort a list-view item
Case $LVN_GETINFOTIP; Sent by a large icon view list-view control that has the $LVS_EX_INFOTIP extended style
Case $LVN_HOTTRACK; Sent by a list-view control when the user moves the mouse over an item
Return 0; allow the list view to perform its normal track select processing.
;Return 1; the item will not be selected.
Case $LVN_INSERTITEM; A new item was inserted
Case $LVN_ITEMACTIVATE; Sent by a list-view control when the user activates an item
Return 1
Case $LVN_ITEMCHANGED; An item has changed
Case $LVN_ITEMCHANGING; An item is changing
;Return True; prevent the change
;Return False; allow the change
Case $LVN_KEYDOWN; A key has been pressed
Case $LVN_MARQUEEBEGIN; A bounding box (marquee) selection has begun
Return 0; accept the message
;Return 1; quit the bounding box selection
Case $LVN_SETDISPINFO; Update the information it maintains for an item
Case $NM_CLICK; Sent by a list-view control when the user clicks an item with the left mouse button
Case $NM_DBLCLK; Sent by a list-view control when the user double-clicks an item with the left mouse button
_DebugPrint("Double click (main m.button) event recieved.")
$iDouble_Click_Event = 1
Case $NM_HOVER; Sent by a list-view control when the mouse hovers over an item
Return 0; process the hover normally
;Return 1; prevent the hover from being processed
Case $NM_KILLFOCUS; The control has lost the input focus
Case $NM_RCLICK; Sent by a list-view control when the user clicks an item with the right mouse button
;Return 1; not to allow the default processing
;Return 0; allow the default processing
Case $NM_RDBLCLK; Sent by a list-view control when the user double-clicks an item with the right mouse button
_DebugPrint("Double click (secondary m.button) event recieved.")
Case $NM_RETURN; The control has the input focus and that the user has pressed the ENTER key
Case $NM_SETFOCUS; The control has received the input focus
EndSwitch
EndSwitch
Return $GUI_RUNDEFMSG
EndFunc
Func _DebugPrint($s_text, $line = @ScriptLineNumber)
ConsoleWrite( _
"!===========================================================" & @LF & _
"+======================================================" & @LF & _
"--> Line(" & StringFormat("%04d", $line) & "):" & @TAB & $s_text & @LF & _
"+======================================================" & @LF)
EndFunc
© OSzone.net 2001-2012
vBulletin v3.6.4, Copyright ©2000-2025, Jelsoft Enterprises Ltd.