#include <GUIListView.au3>
Global $hListView1, $aItem, $iCombo
Global $sDefCombo1 = '11|22', $sDefCombo2 = 'abc|ZZZ'
_GUICreate()
While GUIGetMsg() <> -3
WEnd
Func _GUICreate()
Local $hGUI = GUICreate('')
Dim $iCombo = GUICtrlCreateCombo('', -100, -100)
Local $ListView1 = GUICtrlCreateListView('编号|可双击下拉1 |xxx|可双击下拉2 |fff', 2, 30, 396, 250)
Dim $hListView1 = GUICtrlGetHandle(-1)
GUICtrlSetFont(-1, 11, 400, 0, '微软雅黑')
_GUICtrlListView_SetExtendedListViewStyle($ListView1, $LVS_EX_GRIDLINES + $LVS_EX_FULLROWSELECT)
For $ii = 1 To 8
GUICtrlCreateListViewItem(StringFormat('%s|aaa-%s|BBB_%s|333.%s|ddd~%s', $ii, $ii, $ii, $ii, $ii), $ListView1)
Next
GUISetState()
GUIRegisterMsg(0x004E, '_WM_NOTIFY') ;$WM_NOTIFY = 0x004E
EndFunc ;==>_GUICreate
Func _WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
#forceref $hWnd, $iMsg, $iwParam
Local $tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
Local $hWndFrom = HWnd(DllStructGetData($tNMHDR, 'hWndFrom'))
Local $iCode = DllStructGetData($tNMHDR, 'Code')
Switch $hWndFrom
Case $hListView1
Switch $iCode
Case -2 ;$NM_CLICK = -2
If IsArray($aItem) Then
_GUICtrlListView_SetItemText($hListView1, $aItem[0], GUICtrlRead($iCombo), $aItem[1])
GUICtrlSetPos($iCombo, -1000, -100)
Dim $aItem = 0
EndIf
Case -3 ;$NM_DBLCLK = -3
Local $tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam)
Local $iIndex = DllStructGetData($tInfo, 'Index')
Local $iSub = DllStructGetData($tInfo, 'SubItem')
Dim $aItem = 0
If Not StringRegExp($iSub, "^(1|3)$") Then Return 'GUI_RUNDEFMSG'
Local $aRect = _GUICtrlListView_GetSubItemRect($hListView1, $iIndex, $iSub)
Dim $aItem[2] = [$iIndex, $iSub]
Local $sDef = $sDefCombo1
If $iSub = 3 Then $sDef = $sDefCombo2
Local $sData = _GUICtrlListView_GetItemText($hListView1, $iIndex, $iSub)
GUICtrlSetPos($iCombo, $aRect[0] + 4, $aRect[1] + 32, $aRect[2] - $aRect[0])
GUICtrlSetData($iCombo, '|' & $sData & '|' & $sDef, $sData)
GUICtrlSetState($iCombo, 256)
EndSwitch
EndSwitch
Return 'GUI_RUNDEFMSG'
EndFunc ;==>_WM_NOTIFY