|
发表于 2012-5-29 13:07:56
|
显示全部楼层
本帖最后由 netegg 于 2012-5-29 13:26 编辑
[au3]#include <GuiListView.au3>
#include <WindowsConstants.au3>
#include <Editconstants.au3>
#include <GUIEdit.au3>
Global $msg,$hWnd,$hListview,$hEdit,$aHit,$aPos,$hDC,$hBrush
$msg = GUIGetMsg()
$hWnd = GUICreate('')
$hListview = _GUICtrlListView_Create($hWnd, "", 6, 6, 708, 370, BitOR($LVS_EDITLABELS, $LVS_REPORT))
_GUICtrlListView_SetExtendedListViewStyle($hListview, $LVS_EX_GRIDLINES)
For $i = 0 To 4
_GUICtrlListView_InsertColumn($hListview, 0, "row" & $i, 100)
Next
For $i = 0 To 4
_GUICtrlListView_AddItem($hListview, 'item' & $i, $i)
For $j = 1 To 4
_GUICtrlListView_AddSubItem($hListview, $i, 'subitem' & $j, $j)
Next
Next
GUIRegisterMsg($WM_NOTIFY, 'WM_NOTIFY')
GUIRegisterMsg($WM_COMMAND, 'WM_COMMAND')
GUISetState(@SW_SHOW)
Do
Until GUIGetMsg()= -3
Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
Local $tNMHDR, $hWndFrom, $iCode
$tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
$hWndFrom = DllStructGetData($tNMHDR, "hWndFrom")
$iCode = DllStructGetData($tNMHDR, "Code")
Switch $iCode
Case $NM_RCLICK ;右键单击
$aHit = _GUICtrlListView_SubItemHitTest($hListview)
Local $aRect = _GUICtrlListView_GetSubItemRect($hListview, $aHit[0], $aHit[1])
Local $aPos = ControlGetPos($hWnd, "", $hListview)
Local $text = _GUICtrlListView_GetItemText($hListview, $aHit[0], $aHit[1])
$hEdit = _GUICtrlEdit_Create($hWnd, $text, $aPos[0] + $aRect[0], $aPos[1] + $aRect[1],stringlen($text)*7, 17, BitOR($WS_CHILD, $WS_VISIBLE, $ES_AUTOHSCROLL, $ES_RIGHT))
_GUICtrlEdit_SetSel($hEdit, 0, -1)
_WinAPI_SetFocus($hEdit)
$hDC = _WinAPI_GetWindowDC($hEdit)
$hBrush = _WinAPI_CreateSolidBrush(0x0000FF)
Local $stRect = DllStructCreate("int;int;int;int")
DllStructSetData($stRect, 1, 0)
DllStructSetData($stRect, 2, 0)
DllStructSetData($stRect, 3, stringlen($text)*7)
DllStructSetData($stRect, 4, 17)
DllCall("user32.dll", "int", "FrameRect", "hwnd", $hDC, "ptr", DllStructGetPtr($stRect), "hwnd", $hBrush)
EndSwitch
EndFunc ;==>FrameRect
Func WM_COMMAND($hWnd, $msg, $wParam, $lParam)
Local $iCode = BitShift($wParam, 16)
Switch $lParam
Case $hEdit
Switch $iCode
Case $EN_KILLFOCUS
Local $iText = _GUICtrlEdit_GetText($hEdit)
_GUICtrlListView_SetItemText($hListview, $aHit[0], $iText, 4)
_WinAPI_DeleteObject($hBrush)
_WinAPI_ReleaseDC($hEdit, $hDC)
_WinAPI_DestroyWindow($hEdit)
_GUICtrlEdit_Destroy($hEdit)
$Item = -1
$SubItem = 0
EndSwitch
EndSwitch
Return $GUI_RUNDEFMSG
EndFunc ;==>WM_COMMAND
[/au3]只是提供个参考,操作自己写吧 |
评分
-
查看全部评分
|