找回密码
 加入
搜索
查看: 10384|回复: 21

[GUI管理] 如何双击列表中的一个值,这个值就移动到另一个列表。

 火.. [复制链接]
发表于 2011-5-10 17:45:37 | 显示全部楼层 |阅读模式
本帖最后由 ac5474012 于 2011-5-17 14:26 编辑


1.如何双击123,这个123就移动到右边
2.如何让这个123变得厚一点(上下大)
3.如果多选?比如按住ctrl按键可以同时选中123和4567这两个?(这样就可以不用第一个了)



好像很多人对这个问题感兴趣,其实不难实现
才弄好,发现3M已经解决了,
发出来给大家参考
pcbar 发表于 2011-5-12 14:09

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?加入

×
 楼主| 发表于 2011-5-11 11:32:08 | 显示全部楼层
什么?这很难吗?怎么没有人知道呢?
发表于 2011-5-11 17:25:24 | 显示全部楼层
這個問題在論壇里已經有答案了,自己搜索吧!
发表于 2011-5-11 17:39:10 | 显示全部楼层
自己搜索吧!
发表于 2011-5-11 19:19:08 | 显示全部楼层
读取左边的选定的,再判断循环到右边去.
发表于 2011-5-11 21:09:49 | 显示全部楼层
回复 5# 绿色风
和判断关系不大
 楼主| 发表于 2011-5-12 09:52:35 | 显示全部楼层
回复 3# binshiwo

這個問題在論壇里已經有答案了,自己搜索吧!
binshiwo 发表于 2011-5-11 17:25


能给个关键词否?
 楼主| 发表于 2011-5-12 09:55:45 | 显示全部楼层
回复 4# lxz

那求个关键字吧,我搜索“列表”没有找到
 楼主| 发表于 2011-5-12 09:57:57 | 显示全部楼层
读取左边的选定的,再判断循环到右边去.
绿色风 发表于 2011-5-11 19:19


我可以得到选定的值,可以先删除左边的在新建右边的。但现在的问题是我找不到检测双击的方法?
发表于 2011-5-12 10:06:38 | 显示全部楼层
发表于 2011-5-12 11:46:16 | 显示全部楼层
回复 9# ac5474012


    找说是这回事就行了嘛,看你写的要按按钮的...10楼有转向了
发表于 2011-5-12 11:54:57 | 显示全部楼层
1.左键双击移动到另一个LISTVIEW.
2.可CTRL多选.多选后右键移动到另一个LISTVIEW
#include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>
#include <WindowsConstants.au3>
#include <GUIListView.au3>
#include <GuiImageList.au3>
$hGUI = GUICreate("LVN_ITEMCHECKING", 400, 400)

$ListView1 = GUICtrlCreateListView("Test|Val", 10, 10, 380, 180, $LVS_SHOWSELALWAYS, BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT));, Default, BitOR($LVS_EX_CHECKBOXES, 0x200))
$hListView = GUICtrlGetHandle(-1)
$hImage = _GUIImageList_Create(1, 30);30为间距
_GUICtrlListView_SetImageList($ListView1, $hImage, 1)
For $I = 1 To 10
        GUICtrlCreateListViewItem("ITEM-" & $I & "|Val-" & $I, $ListView1)
Next


$ListView2 = GUICtrlCreateListView("Test1|Val1", 10, 190, 380, 180, $LVS_SHOWSELALWAYS);, Default, BitOR($LVS_EX_CHECKBOXES, 0x200))
;GUICtrlCreateListViewItem("Item 1", $iListView)
;GUICtrlCreateListViewItem("Item 2", $iListView)

GUISetState()

GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")

While GUIGetMsg() <> -3
WEnd
GUIDelete($hGUI)

Func WM_NOTIFY($hWndGUI, $MsgID, $WParam, $LParam)

        Local $tagNMHDR, $Event, $hWndFrom, $IDFrom
        Local $tagNMHDR = DllStructCreate("int;int;int", $LParam)
        If @error Then Return $GUI_RUNDEFMSG
        $IDFrom = DllStructGetData($tagNMHDR, 2)
        $Event = DllStructGetData($tagNMHDR, 3)
        $tagNMHDR = 0
        Switch $IDFrom;选择产生事件的控件

                Case $ListView1

                        Switch $Event; 选择产生的事件
                                Case $NM_CLICK ; 左击
;~                                      ...
                                Case $NM_DBLCLK ; 双击
                                        $Index = _GUICtrlListView_GetSelectedIndices($ListView1)
                                        If $Index = "" Then; 这里用以判断是否选定了ListViewItem
                                                Return
                                        EndIf
                                        _GUICtrlListView_AddItem($ListView2, _GUICtrlListView_GetItemText($ListView1, Number($Index), 0))
                                        _GUICtrlListView_AddSubItem($ListView2, _GUICtrlListView_GetItemCount($ListView2) - 1, _GUICtrlListView_GetItemText($ListView1, Number($Index), 1), 1)
                                        _GUICtrlListView_DeleteItem($ListView1, Number($Index))
                                Case $NM_RCLICK ; 右击
                                        $Index = _GUICtrlListView_GetSelectedIndices($ListView1, True)
                                        If $Index[0] = 0 Then Return
                                        For $I = 1 To $Index[0]
                                                _GUICtrlListView_AddItem(GUICtrlGetHandle($ListView2), _GUICtrlListView_GetItemText($ListView1, Number($Index[$I]), 0))
                                                _GUICtrlListView_AddSubItem($ListView2, _GUICtrlListView_GetItemCount($ListView2) - 1, _GUICtrlListView_GetItemText($ListView1, Number($Index[$I]), 1), 1)
                                        Next
                                        For $I = $Index[0] To 1 Step -1
                                                _GUICtrlListView_DeleteItem($ListView1, Number($Index[$I]))
                                        Next
                        EndSwitch
                Case $ListView2
                        Switch $Event; 选择产生的事件
                                Case $NM_CLICK ; 左击
;~                                      ...
                                Case $NM_DBLCLK ; 双击
                                        $Index = _GUICtrlListView_GetSelectedIndices($ListView2)
                                        If $Index = "" Then; 这里用以判断是否选定了ListViewItem
                                                Return
                                        EndIf
                                        _GUICtrlListView_AddItem($ListView1, _GUICtrlListView_GetItemText($ListView2, Number($Index), 0))
                                        _GUICtrlListView_AddSubItem($ListView1, _GUICtrlListView_GetItemCount($ListView1) - 1, _GUICtrlListView_GetItemText($ListView2, Number($Index), 1), 1)
                                        _GUICtrlListView_DeleteItem(GUICtrlGetHandle($ListView2), Number($Index))
                                Case $NM_RCLICK ; 右击
                                        $Index = _GUICtrlListView_GetSelectedIndices($ListView2, True)
                                        If $Index[0] = 0 Then Return
                                        For $I = 1 To $Index[0]
                                                _GUICtrlListView_AddItem(GUICtrlGetHandle($ListView1), _GUICtrlListView_GetItemText($ListView2, Number($Index[$I]), 0))
                                                _GUICtrlListView_AddSubItem($ListView1, _GUICtrlListView_GetItemCount($ListView1) - 1, _GUICtrlListView_GetItemText($ListView2, Number($Index[$I]), 1), 1)
                                        Next
                                        For $I = $Index[0] To 1 Step -1
                                                _GUICtrlListView_DeleteItem(GUICtrlGetHandle($ListView2), Number($Index[$I]))
                                        Next
                        EndSwitch
        EndSwitch

        Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_NOTIFY

评分

参与人数 1金钱 +10 收起 理由
netegg + 10

查看全部评分

发表于 2011-5-12 14:09:47 | 显示全部楼层
好像很多人对这个问题感兴趣,其实不难实现
才弄好,发现3M已经解决了,
发出来给大家参考
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <GUIListBox.au3>
#include <WindowsConstants.au3>
#include <array.au3>

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("test", 373, 274, 192, 124)
$List1 = _GUICtrlListBox_Create($Form1, "", 16, 48, 113, 201, BitOR($LBS_NOTIFY, $WS_VSCROLL, $WS_BORDER ))
$List2 = _GUICtrlListBox_Create($Form1, "", 232, 48, 113, 201, BitOR($LBS_NOTIFY, $WS_VSCROLL, $WS_BORDER))
$Button1 = GUICtrlCreateButton(">>", 152, 64, 65, 25)
$Button2 = GUICtrlCreateButton("<<", 152, 126, 65, 25)
$Button3 = GUICtrlCreateButton("undo", 152, 200, 65, 25)

GUIRegisterMsg($WM_COMMAND, "WM_COMMAND")

GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
updatel1()
While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
                Case $Button1
                        u1()
                Case $Button2
                        u2()
                Case $Button3
                        
        EndSwitch
WEnd

Func updatel1()
        Local $l1[10]
        For $i = 1 To 10
                $l1[$i - 1] = "软件 " & $i
        Next
        _GUICtrlListBox_BeginUpdate($List1)
        For $i = 1 To UBound($l1)
                _GUICtrlListBox_AddString($List1, $l1[$i - 1])
        Next
        _GUICtrlListBox_EndUpdate($List1)
EndFunc   ;==>updatel1


Func WM_COMMAND($hWnd, $iMsg, $iwParam, $ilParam)
        #forceref $hWnd, $iMsg
        Local $hWndFrom, $iIDFrom, $iCode, $hWndListBox
        ;$hWndListBox= GUICtrlGetHandle($List1)
        $hWndFrom = $ilParam
        $iIDFrom = BitAND($iwParam, 0xFFFF) ; Low Word
        $iCode = BitShift($iwParam, 16) ; Hi Word

        Switch $hWndFrom
                Case $List1;
                        Switch $iCode
                                Case $LBN_DBLCLK ; Sent when the user double-clicks a string in a list box
                                        u1()
                        EndSwitch
                Case $List2
                        Switch $iCode
                                Case $LBN_DBLCLK ; Sent when the user double-clicks a string in a list box
                                        u2()
                        EndSwitch
                        
        EndSwitch

        Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_COMMAND

Func u1()
        $n = _GUICtrlListBox_GetCurSel($List1)
        If $n = -1 Then Return
        $txt = _GUICtrlListBox_GetText($List1, $n)
        _GUICtrlListBox_AddString($List2, $txt)
        _GUICtrlListBox_DeleteString($List1, $n)
EndFunc   ;==>u1

Func u2()
        $n = _GUICtrlListBox_GetCurSel($List2)
        If $n = -1 Then Return
        $txt = _GUICtrlListBox_GetText($List2, $n)
        _GUICtrlListBox_AddString($List1, $txt)
        _GUICtrlListBox_DeleteString($List2, $n)
EndFunc   ;==>u2

评分

参与人数 1金钱 +30 收起 理由
3mile + 30 学习了

查看全部评分

发表于 2011-5-12 14:12:01 | 显示全部楼层
为什么我的代码不是彩色的??
发表于 2011-5-12 14:19:08 | 显示全部楼层
回复 14# pcbar
向前辈学习.
前辈用的是"[CODE][/CODE]"吧?
如果用"
"就是彩色代码框.

评分

参与人数 1金钱 +30 收起 理由
pcbar + 30 原来是这样 3Q

查看全部评分

您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-5-12 00:12 , Processed in 0.084676 second(s), 25 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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