PDA

Показать полную графическую версию : [решено] Двойной щелчок мышью в GUICtrlListView


AzazeLHAck
16-01-2011, 19:46
Здравствуйте!
Скажите, может существует какой-нибудь скрипт для того, чтобы скажем:
При двойной щелчке по одному из "Item" в "ListView", запускался MsgBox..?

madmasles
16-01-2011, 20:24
#include (http://www.autoitscript.com/autoit3/docs/keywords.htm##include) <GUIConstantsEx.au3>
#include (http://www.autoitscript.com/autoit3/docs/keywords.htm##include) <GUIListView.au3>
#include (http://www.autoitscript.com/autoit3/docs/keywords.htm##include) <WindowsConstants.au3>

Global (http://www.autoitscript.com/autoit3/docs/keywords.htm#Global) $hListView, $iLast_LV_Index, $Form1

$Form1 = GUICreate (http://www.autoitscript.com/autoit3/docs/functions/GUICreate.htm)('ListView', 400, 300)
$hListView = _GUICtrlListView_Create (http://dundats.mvps.org/help/html/libfunctions/_guictrllistview_create.htm)($Form1, '', 32, 16, 340, 260)
_GUICtrlListView_InsertColumn (http://dundats.mvps.org/help/html/libfunctions/_guictrllistview_insertcolumn.htm)($hListView, 0, 'Column 1', 100)
_GUICtrlListView_AddItem (http://dundats.mvps.org/help/html/libfunctions/_guictrllistview_additem.htm)($hListView, 'Row 1: Col 1', 0)
_GUICtrlListView_AddItem (http://dundats.mvps.org/help/html/libfunctions/_guictrllistview_additem.htm)($hListView, 'Row 2: Col 1', 1)
_GUICtrlListView_AddItem (http://dundats.mvps.org/help/html/libfunctions/_guictrllistview_additem.htm)($hListView, 'Row 3: Col 1', 2)
GUISetState (http://www.autoitscript.com/autoit3/docs/functions/GUISetState.htm)()
GUIRegisterMsg (http://www.autoitscript.com/autoit3/docs/functions/GUIRegisterMsg.htm)($WM_NOTIFY, 'WM_NOTIFY')

While (http://www.autoitscript.com/autoit3/docs/keywords.htm#While) 1
$nMsg = GUIGetMsg (http://www.autoitscript.com/autoit3/docs/functions/GUIGetMsg.htm)()
Switch (http://www.autoitscript.com/autoit3/docs/keywords.htm#Switch) $nMsg
Case (http://www.autoitscript.com/autoit3/docs/keywords.htm#Case) $GUI_EVENT_CLOSE
Exit (http://www.autoitscript.com/autoit3/docs/keywords.htm#Exit)

EndSwitch (http://www.autoitscript.com/autoit3/docs/keywords.htm#EndSwitch)
WEnd (http://www.autoitscript.com/autoit3/docs/keywords.htm#WEnd)

Func (http://www.autoitscript.com/autoit3/docs/keywords.htm#Func) WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
Local (http://www.autoitscript.com/autoit3/docs/keywords.htm#Local) $hWndFrom, $iCode, $tNMHDR, $hWndListView, $tInfo

$hWndListView = $hListView
If (http://www.autoitscript.com/autoit3/docs/keywords.htm#If) Not (http://www.autoitscript.com/autoit3/docs/keywords.htm#Not) IsHWnd (http://www.autoitscript.com/autoit3/docs/functions/IsHWnd.htm)($hListView) Then (http://www.autoitscript.com/autoit3/docs/keywords.htm#Then) $hWndListView = GUICtrlGetHandle (http://www.autoitscript.com/autoit3/docs/functions/GUICtrlGetHandle.htm)($hListView)

$tNMHDR = DllStructCreate (http://www.autoitscript.com/autoit3/docs/functions/DllStructCreate.htm)($tagNMHDR, $ilParam)
$hWndFrom = HWnd (http://www.autoitscript.com/autoit3/docs/functions/HWnd.htm)(DllStructGetData (http://www.autoitscript.com/autoit3/docs/functions/DllStructGetData.htm)($tNMHDR, 'hWndFrom'))
$iCode = DllStructGetData (http://www.autoitscript.com/autoit3/docs/functions/DllStructGetData.htm)($tNMHDR, 'Code')

Switch (http://www.autoitscript.com/autoit3/docs/keywords.htm#Switch) $hWndFrom
Case (http://www.autoitscript.com/autoit3/docs/keywords.htm#Case) $hWndListView
Switch (http://www.autoitscript.com/autoit3/docs/keywords.htm#Switch) $iCode
Case (http://www.autoitscript.com/autoit3/docs/keywords.htm#Case) $NM_DBLCLK ;двойной клик левой кнопки мыши
$tInfo = DllStructCreate (http://www.autoitscript.com/autoit3/docs/functions/DllStructCreate.htm)($tagNMITEMACTIVATE, $ilParam)
$iIndex = DllStructGetData (http://www.autoitscript.com/autoit3/docs/functions/DllStructGetData.htm)($tInfo, 'Index')
If (http://www.autoitscript.com/autoit3/docs/keywords.htm#If) $iIndex <> -1 Then (http://www.autoitscript.com/autoit3/docs/keywords.htm#Then)
$iLast_LV_Index = $iIndex
ToolTip (http://www.autoitscript.com/autoit3/docs/functions/ToolTip.htm)(_GUICtrlListView_GetItemText (http://dundats.mvps.org/help/html/libfunctions/_guictrllistview_getitemtext.htm)($hListView, $iLast_LV_Index), 0, 0)
EndIf (http://www.autoitscript.com/autoit3/docs/keywords.htm#EndIf)
Case (http://www.autoitscript.com/autoit3/docs/keywords.htm#Case) $NM_RCLICK ;один клик правой кнопки мыши
ToolTip (http://www.autoitscript.com/autoit3/docs/functions/ToolTip.htm)('')
EndSwitch (http://www.autoitscript.com/autoit3/docs/keywords.htm#EndSwitch)
EndSwitch (http://www.autoitscript.com/autoit3/docs/keywords.htm#EndSwitch)

Return (http://www.autoitscript.com/autoit3/docs/keywords.htm#Return) $GUI_RUNDEFMSG
EndFunc (http://www.autoitscript.com/autoit3/docs/keywords.htm#EndFunc) ;==>WM_NOTIFY

Или так:#include (http://www.autoitscript.com/autoit3/docs/keywords.htm##include) <GUIConstantsEx.au3>
#include (http://www.autoitscript.com/autoit3/docs/keywords.htm##include) <StructureConstants.au3>
#include (http://www.autoitscript.com/autoit3/docs/keywords.htm##include) <WindowsConstants.au3>

Global (http://www.autoitscript.com/autoit3/docs/keywords.htm#Global) $hListView, $Form1

$Form1 = GUICreate (http://www.autoitscript.com/autoit3/docs/functions/GUICreate.htm)('ListView', 400, 300)
$hListView = GUICtrlCreateListView (http://www.autoitscript.com/autoit3/docs/functions/GUICtrlCreateListView.htm)('col1 |col2|col3 ', 32, 16, 340, 260)
For (http://www.autoitscript.com/autoit3/docs/keywords.htm#For) $i = 1 To (http://www.autoitscript.com/autoit3/docs/keywords.htm#To) 10
GUICtrlCreateListViewItem (http://www.autoitscript.com/autoit3/docs/functions/GUICtrlCreateListViewItem.htm)('item' & $i & '|col2' & $i & '|col3' & $i, $hListView)
Next (http://www.autoitscript.com/autoit3/docs/keywords.htm#Next)
GUISetState (http://www.autoitscript.com/autoit3/docs/functions/GUISetState.htm)()
GUIRegisterMsg (http://www.autoitscript.com/autoit3/docs/functions/GUIRegisterMsg.htm)($WM_NOTIFY, 'WM_NOTIFY')

While (http://www.autoitscript.com/autoit3/docs/keywords.htm#While) 1
$nMsg = GUIGetMsg (http://www.autoitscript.com/autoit3/docs/functions/GUIGetMsg.htm)()
Switch (http://www.autoitscript.com/autoit3/docs/keywords.htm#Switch) $nMsg
Case (http://www.autoitscript.com/autoit3/docs/keywords.htm#Case) $GUI_EVENT_CLOSE
Exit (http://www.autoitscript.com/autoit3/docs/keywords.htm#Exit)

EndSwitch (http://www.autoitscript.com/autoit3/docs/keywords.htm#EndSwitch)
WEnd (http://www.autoitscript.com/autoit3/docs/keywords.htm#WEnd)

Func (http://www.autoitscript.com/autoit3/docs/keywords.htm#Func) WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
Local (http://www.autoitscript.com/autoit3/docs/keywords.htm#Local) $hWndFrom, $iCode, $tNMHDR, $hWndListView, $tInfo

$hWndListView = $hListView
If (http://www.autoitscript.com/autoit3/docs/keywords.htm#If) Not (http://www.autoitscript.com/autoit3/docs/keywords.htm#Not) IsHWnd (http://www.autoitscript.com/autoit3/docs/functions/IsHWnd.htm)($hListView) Then (http://www.autoitscript.com/autoit3/docs/keywords.htm#Then) $hWndListView = GUICtrlGetHandle (http://www.autoitscript.com/autoit3/docs/functions/GUICtrlGetHandle.htm)($hListView)

$tNMHDR = DllStructCreate (http://www.autoitscript.com/autoit3/docs/functions/DllStructCreate.htm)($tagNMHDR, $ilParam)
$hWndFrom = HWnd (http://www.autoitscript.com/autoit3/docs/functions/HWnd.htm)(DllStructGetData (http://www.autoitscript.com/autoit3/docs/functions/DllStructGetData.htm)($tNMHDR, 'hWndFrom'))
$iCode = DllStructGetData (http://www.autoitscript.com/autoit3/docs/functions/DllStructGetData.htm)($tNMHDR, 'Code')

Switch (http://www.autoitscript.com/autoit3/docs/keywords.htm#Switch) $hWndFrom
Case (http://www.autoitscript.com/autoit3/docs/keywords.htm#Case) $hWndListView
Switch (http://www.autoitscript.com/autoit3/docs/keywords.htm#Switch) $iCode
Case (http://www.autoitscript.com/autoit3/docs/keywords.htm#Case) $NM_DBLCLK ;двойной клик левой кнопки мыши
ToolTip (http://www.autoitscript.com/autoit3/docs/functions/ToolTip.htm)(GUICtrlRead (http://www.autoitscript.com/autoit3/docs/functions/GUICtrlRead.htm)(GUICtrlRead (http://www.autoitscript.com/autoit3/docs/functions/GUICtrlRead.htm)($hListView)), 0, 0)
Case (http://www.autoitscript.com/autoit3/docs/keywords.htm#Case) $NM_RCLICK ;один клик правой кнопки мыши
ToolTip (http://www.autoitscript.com/autoit3/docs/functions/ToolTip.htm)('')
EndSwitch (http://www.autoitscript.com/autoit3/docs/keywords.htm#EndSwitch)
EndSwitch (http://www.autoitscript.com/autoit3/docs/keywords.htm#EndSwitch)

Return (http://www.autoitscript.com/autoit3/docs/keywords.htm#Return) $GUI_RUNDEFMSG
EndFunc (http://www.autoitscript.com/autoit3/docs/keywords.htm#EndFunc) ;==>WM_NOTIFY

AzazeLHAck
17-01-2011, 00:58
Я уже разобрался в первом способе, пойдёт :) Спасибо! :) Тема решена!




© OSzone.net 2001-2012