Listview中的文本能不能被选定
RT,就像Excel表格中一样鼠标选定文本并可以复制? 用_GUICtrlListView_SetItemFocused()、 _GUICtrlListView_GetItemText()这二个试试吧。仅获取的话就用二个也行。 看看listview子项原地编辑的写法 原来我理解错了。看这个问题对我而言难度是太高了,只能等待能人出现让我来学习了。 只能等待能人出现让我来学习了 本帖最后由 netegg 于 2012-5-29 13:26 编辑#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,$aHit)
Local $aPos = ControlGetPos($hWnd, "", $hListview)
Local $text = _GUICtrlListView_GetItemText($hListview, $aHit, $aHit)
$hEdit = _GUICtrlEdit_Create($hWnd, $text, $aPos + $aRect, $aPos + $aRect,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, $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
只是提供个参考,操作自己写吧 回复 6# netegg
感谢蛋哥,我学习一下,目前为止对注册消息还不是很懂,不知道有没有比较详细的资料? 回复 7# xms77
auto这方面的资料不是很多,看看各控件的create函数,里面大体讲了些,还有官网上有不少,剩下的估计要看自己的了
页:
[1]