找回密码
 加入
搜索
查看: 2890|回复: 7

[GUI管理] Listview中的文本能不能被选定

  [复制链接]
发表于 2012-5-28 16:48:34 | 显示全部楼层 |阅读模式
RT,就像Excel表格中一样鼠标选定文本并可以复制?
发表于 2012-5-28 17:17:11 | 显示全部楼层
用_GUICtrlListView_SetItemFocused()、 _GUICtrlListView_GetItemText()这二个试试吧。仅获取的话就用二个也行。
发表于 2012-5-28 18:29:30 | 显示全部楼层
看看listview子项原地编辑的写法
发表于 2012-5-29 12:07:32 | 显示全部楼层
原来我理解错了。看这个问题对我而言难度是太高了,只能等待能人出现让我来学习了。
发表于 2012-5-29 12:57:04 | 显示全部楼层
只能等待能人出现让我来学习了
发表于 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]只是提供个参考,操作自己写吧

评分

参与人数 1金钱 +30 贡献 +5 收起 理由
xms77 + 30 + 5 感谢蛋哥,我学习一下

查看全部评分

 楼主| 发表于 2012-5-29 21:52:07 | 显示全部楼层
回复 6# netegg
感谢蛋哥,我学习一下,目前为止对注册消息还不是很懂,不知道有没有比较详细的资料?
发表于 2012-5-30 06:34:51 | 显示全部楼层
回复 7# xms77
auto这方面的资料不是很多,看看各控件的create函数,里面大体讲了些,还有官网上有不少,剩下的估计要看自己的了
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-5-18 23:18 , Processed in 0.087334 second(s), 27 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表