ListView扩展风格$LVN_ITEMACTIVATE的使用方法?
本帖最后由 superflq 于 2009-11-20 16:48 编辑我看说明扩展风格中有一个是
$LVS_EX_TWOCLICKACTIVATE - 双击项目事控件发送 $LVN_ITEMACTIVATE 信息
英文原文是:
$LVS_EX_TWOCLICKACTIVATE - The control sends an $LVN_ITEMACTIVATE message when the user double-clicks an item
我现在想问的是$LVN_ITEMACTIVATE 这个信息怎么使用
比如我想双击弹出MsgBox
PS:论坛里面ListView判断双击的方法已经搜索到了 顶起来,有高手帮忙么 #include <GUIListView.au3>
#include <WindowsConstants.au3>
$hGUI = GUICreate("Test", 400, 300)
$iStyle = bitOR($LVS_EX_FULLROWSELECT, $LVS_EX_TWOCLICKACTIVATE,
$WS_EX_CLIENTEDGE)
$iListView = GUICtrlCreateListView("Col 1|Col 2", 5, 5, 390, 290, $LVS_REPORT, $iStyle)
GUICtrlCreateListViewItem("Item 1|Sub Item 1-1", $iListView)
GUICtrlCreateListViewItem("Item 2|Sub Item 2-1", $iListView)
$hListView = GUICtrlGetHandle($iListView)
GUIRegisterMsg($WM_NOTIFY, "_WM_NOTIFY")
GUISetState()
Do
Until GUIGetMsg() = -3
Func _WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
Local $tNMHDR, $hWndFrom, $iCode
$tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
Switch DllStructGetData($tNMHDR, "hWndFrom")
Case $hListView
Switch DllStructGetData($tNMHDR, "Code")
Case $NM_DBLCLK
Msgbox(0, "$NM_DBLCLK", "Double clicked.")
Case $LVN_ITEMACTIVATE
Msgbox(0, "$LVN_ITEMACTIVATE", "Double clicked.")
EndSwitch
EndSwitch
$tNMHDR = 0
EndFunc ;==>_WM_NOTIFY 本帖最后由 131738 于 2009-11-20 16:29 编辑
回复 2# superflq
不知 pusofalse 以回帖,晚了!!!!!。。。。。。。。。。。。
#AutoIt3Wrapper_au3check_parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
#include <GuiConstantsEx.au3>
#include <GuiListView.au3>
#include <GuiImageList.au3>
#include <WindowsConstants.au3>
Opt('MustDeclareVars', 1)
$Debug_LV = False ; Check ClassName being passed to ListView functions, set to True and use a handle to another control to see it work
Global $hListView,$LVN_BEGINLABELEDIT,$LVN_ENDLABELEDIT,$LVN_GETINFOTIP,$LVN_SETDISPINFO
_Main()
Func _Main()
Local $GUI, $hImage
$GUI = GUICreate("(UDF Created) ListView Create", 400, 300)
$hListView = _GUICtrlListView_Create($GUI, "", 2, 2, 394, 268)
_GUICtrlListView_SetExtendedListViewStyle($hListView, $LVS_EX_TWOCLICKACTIVATE);BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT, $LVS_EX_SUBITEMIMAGES,$LVS_EX_TWOCLICKACTIVATE))
GUISetState()
GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")
; Load images
$hImage = _GUIImageList_Create()
_GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($hListView, 0xFF0000, 16, 16))
_GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($hListView, 0x00FF00, 16, 16))
_GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($hListView, 0x0000FF, 16, 16))
_GUICtrlListView_SetImageList($hListView, $hImage, 1)
; Add columns
_GUICtrlListView_InsertColumn($hListView, 0, "Column 1", 100)
_GUICtrlListView_InsertColumn($hListView, 1, "Column 2", 100)
_GUICtrlListView_InsertColumn($hListView, 2, "Column 3", 100)
; Add items
_GUICtrlListView_AddItem($hListView, "Row 1: Col 1", 0)
_GUICtrlListView_AddSubItem($hListView, 0, "Row 1: Col 2", 1)
_GUICtrlListView_AddSubItem($hListView, 0, "Row 1: Col 3", 2)
_GUICtrlListView_AddItem($hListView, "Row 2: Col 1", 1)
_GUICtrlListView_AddSubItem($hListView, 1, "Row 2: Col 2", 1)
_GUICtrlListView_AddItem($hListView, "Row 3: Col 1", 2)
; Loop until user exits
Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE
GUIDelete()
EndFunc ;==>_Main
Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
#forceref $hWnd, $iMsg, $iwParam
Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView, $tInfo
$hWndListView = $hListView
If Not IsHWnd($hListView) Then $hWndListView = GUICtrlGetHandle($hListView)
$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_ITEMACTIVATE ; 发送激活项目消息
$tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam)
MsgBox(0,0,'双击主项目索引: '& DllStructGetData($tInfo, "Index") )
_DebugPrint("$LVN_ITEMACTIVATE" & @LF & "--> hWndFrom:" & @TAB & $hWndFrom & @LF & _
"-->IDFrom:" & @TAB & $iIDFrom & @LF & _
"-->Code:" & @TAB & $iCode & @LF & _
"-->Index:" & @TAB & DllStructGetData($tInfo, "Index") & @LF & _
"-->SubItem:" & @TAB & DllStructGetData($tInfo, "SubItem") & @LF & _
"-->NewState:" & @TAB & DllStructGetData($tInfo, "NewState") & @LF & _
"-->OldState:" & @TAB & DllStructGetData($tInfo, "OldState") & @LF & _
"-->Changed:" & @TAB & DllStructGetData($tInfo, "Changed") & @LF & _
"-->ActionX:" & @TAB & DllStructGetData($tInfo, "ActionX") & @LF & _
"-->ActionY:" & @TAB & DllStructGetData($tInfo, "ActionY") & @LF & _
"-->lParam:" & @TAB & DllStructGetData($tInfo, "lParam") & @LF & _
"-->KeyFlags:" & @TAB & DllStructGetData($tInfo, "KeyFlags"))
Return 0
EndSwitch
EndSwitch
Return $GUI_RUNDEFMSG
EndFunc ;==>WM_NOTIFY
Func _DebugPrint($s_text, $line = @ScriptLineNumber)
ConsoleWrite( _
"!===========================================================" & @LF & _
"+======================================================" & @LF & _
"-->Line(" & StringFormat("%04d", $line) & "):" & @TAB & $s_text & @LF & _
"+======================================================" & @LF)
EndFunc ;==>_DebugPrint修改的示例脚本,好像不需连续左键点两次,第一点击选中项目,光标变为手形,再单击跳出 MsgBox 提示。。。。。。。
不知 pusofalse 以回帖,晚了!!!!!。。。。。。。。。。。。 Re 4#:
还是131738兄给出的例子详细~ Re 4#:
还是131738兄给出的例子详细~
pusofalse 发表于 2009-11-20 16:33 http://www.autoitx.com/images/common/back.gif
修改示例脚本,见笑了!!研究示例脚本时,没看到你以回帖了!!!:face (33): 谢谢两位大大:face (7): 学习了~看看怎么用{:face (427):}
页:
[1]