找回密码
 加入
搜索
查看: 10441|回复: 14

[图形处理] 【已解决】ListView焦点及复制删除问题,相反方向无效,求助!

  [复制链接]
发表于 2014-8-31 13:15:59 | 显示全部楼层 |阅读模式
本帖最后由 touch_xu 于 2014-9-1 20:44 编辑

1.以下代码,左内容可以移到右边,右边不能移到左边(右边为内容不清除),为什么,没有理由啊!
2.如何让左侧每一行默认选中,即使删除了,下一行仍然处于选中状态,找到了相关函数都无效,谢谢!
#include <Access.au3>
#include <ComboConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <GUIConstants.au3>
#include <GUIListView.au3>
#include <Array.au3>
#include <GuiEdit.au3>


Opt("GUIOnEventMode", 1)

$FrmConfirm = GUICreate("Confirm", 505, 385, -1, -1)
GUISetOnEvent($GUI_EVENT_CLOSE, "_GUI")
$LstPass = GUICtrlCreateListView("NO|LOC|     Symptom     ", 5, 60, 220, 270)
_GUICtrlListView_SetItemSelected($LstPass,1,True,True)
GUICtrlCreateListViewItem("01|C1|ABC", $LstPass)
GUICtrlCreateListViewItem("03|C3|FEG", $LstPass)
GUICtrlCreateListViewItem("04|D3|DEF", $LstPass)

$LstFail = GUICtrlCreateListView("NO|LOC|     Symptom     ", 280, 60, 220, 270)
$BtnConfirm = GUICtrlCreateButton("Finish", 150, 340, 200, 32)
GUICtrlSetOnEvent(-1, "_GUI")

$Right = GUICtrlCreateButton("->", 230, 140, 46, 50)
GUICtrlSetOnEvent(-1, "_GUI")

$Left = GUICtrlCreateButton("<-", 230, 220, 46, 50)
GUICtrlSetOnEvent(-1, "_GUI")

GUISetState(@SW_SHOW, $FrmConfirm)


While 1
        Sleep(10)
        
WEnd

Func _GUI()

        Switch @GUI_CtrlId

                Case $BtnConfirm, $GUI_EVENT_CLOSE
                        Exit
                Case $Right
                        _GUICtrlListView_CopyItems($LstPass, $LstFail, True)
                Case $Left
                        _GUICtrlListView_CopyItems($LstFail, $LstPass, True)
                        
        EndSwitch
EndFunc   ;==>_GUI

本帖子中包含更多资源

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

×
发表于 2014-8-31 17:34:49 | 显示全部楼层
给你一半代码 剩下的你看懂了肯定能写出来的
Case $Right
        $nCnt = _GUICtrlListView_GetItemCount($LstPass)
        For $i = 0 To $nCnt - 1
                If _GUICtrlListView_GetItemState($LstPass, $i, $LVIS_SELECTED ) Then
                        $nItem = $i
                        ExitLoop
                EndIf
        Next
        _GUICtrlListView_CopyItems($LstPass, $LstFail, True)
        $nCnt -= 1
        If $nCnt>0 Then
                If $nItem<$nCnt Then
                        _GUICtrlListView_SetItemSelected($LstPass, $nItem, True, True)
                Else
                        _GUICtrlListView_SetItemSelected($LstPass, $nCnt-1, True, True)
                EndIf
        EndIf
发表于 2014-9-1 14:00:24 | 显示全部楼层
回复 1# touch_xu

#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <GuiImageList.au3>
#include <WindowsConstants.au3>

Opt("GUIOnEventMode", 1)
Global $FrmConfirm, $LstPass, $LstFail, $BtnConfirm, $Right, $Left, $Button, $nItem, $nItem1

_GUIa()
While 1
        Sleep(10)

WEnd
Func _GUIa()
        Local $exStyles = BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT, $LVS_EX_CHECKBOXES, $LVS_EX_SUBITEMIMAGES)
        $FrmConfirm = GUICreate("Confirm", 505, 385, -1, -1)
        GUISetOnEvent($GUI_EVENT_CLOSE, "_GUI")
        $LstPass = GUICtrlGetHandle(GUICtrlCreateListView("", 5, 60, 220, 270, BitOR($LVS_REPORT, $LVS_SHOWSELALWAYS), $WS_EX_CLIENTEDGE))
        _GUICtrlListView_SetExtendedListViewStyle($LstPass, $exStyles)

        $LstFail = GUICtrlGetHandle(GUICtrlCreateListView("", 280, 60, 220, 270, BitOR($LVS_REPORT, $LVS_SHOWSELALWAYS), $WS_EX_CLIENTEDGE))
        _GUICtrlListView_SetExtendedListViewStyle($LstFail, $exStyles)

        $BtnConfirm = GUICtrlCreateButton("Finish", 150, 340, 200, 32)
        GUICtrlSetOnEvent(-1, "_GUI")

        $Right = GUICtrlCreateButton("->", 230, 140, 46, 50)
        GUICtrlSetOnEvent(-1, "_GUI")

        $Left = GUICtrlCreateButton("<-", 230, 220, 46, 50)
        GUICtrlSetOnEvent(-1, "_GUI")

        GUISetState(@SW_SHOW, $FrmConfirm)
        ; 添加列
        _GUICtrlListView_AddColumn($LstPass, "NO", 70)
        _GUICtrlListView_AddColumn($LstPass, "LOC", 70)
        _GUICtrlListView_AddColumn($LstPass, "Symptom", 70)

        ; 添加列
        _GUICtrlListView_AddColumn($LstFail, "NO", 70)
        _GUICtrlListView_AddColumn($LstFail, "LOC", 70)
        _GUICtrlListView_AddColumn($LstFail, "Symptom", 70)

        ; 添加项目
        _GUICtrlListView_AddItem($LstPass, "01", 0)
        _GUICtrlListView_AddSubItem($LstPass, 0, "Cl", 1, 1)
        _GUICtrlListView_AddSubItem($LstPass, 0, "ABC", 2, 2)
        _GUICtrlListView_AddItem($LstPass, "03", 1)
        _GUICtrlListView_AddSubItem($LstPass, 1, "C3", 1, 2)
        _GUICtrlListView_AddSubItem($LstPass, 1, "FEG", 2, 2)
        _GUICtrlListView_AddItem($LstPass, "04", 2)
        _GUICtrlListView_AddSubItem($LstPass, 2, "D3", 1, 2)
        _GUICtrlListView_AddSubItem($LstPass, 2, "DEF", 2, 3)

EndFunc   ;==>_GUIa

Func _GUI()

        Switch @GUI_CtrlId

                Case $BtnConfirm, $GUI_EVENT_CLOSE
                        Exit
                Case $Right
                        _GUICtrlListView_CopyItems($LstPass, $LstFail, True)
                Case $Left
                        _GUICtrlListView_CopyItems($LstFail, $LstPass, True)

        EndSwitch
EndFunc   ;==>_GUI
发表于 2014-9-1 16:08:36 | 显示全部楼层
无需判断吧~直接设置就好吧
Func _GUI()
        Switch @GUI_CtrlId
                Case $BtnConfirm, $GUI_EVENT_CLOSE
                        Exit
                Case $Right
                        _GUICtrlListView_CopyItems($LstPass, $LstFail, True)
                        _GUICtrlListView_SetItemSelected($LstPass,0, True, True)
                Case $Left
                        _GUICtrlListView_CopyItems($LstFail, $LstPass, True)
                        _GUICtrlListView_SetItemSelected($LstPass,0, True, True)
        EndSwitch
EndFunc   ;==>_GUI
 楼主| 发表于 2014-9-1 20:25:35 | 显示全部楼层
给你一半代码 剩下的你看懂了肯定能写出来的
Case $Right
        $nCnt = _GUICtrlListView_GetItemCount($LstP ...
veket_linux 发表于 2014-8-31 17:34



    左到右是没有问题的,一行就搞定 _GUICtrlListView_CopyItems($LstPass, $LstFail, True)
关键是右到左,谢谢!
 楼主| 发表于 2014-9-1 20:25:41 | 显示全部楼层
给你一半代码 剩下的你看懂了肯定能写出来的
Case $Right
        $nCnt = _GUICtrlListView_GetItemCount($LstP ...
veket_linux 发表于 2014-8-31 17:34



    左到右是没有问题的,一行就搞定 _GUICtrlListView_CopyItems($LstPass, $LstFail, True)
关键是右到左,谢谢!
 楼主| 发表于 2014-9-1 20:25:42 | 显示全部楼层
给你一半代码 剩下的你看懂了肯定能写出来的
Case $Right
        $nCnt = _GUICtrlListView_GetItemCount($LstP ...
veket_linux 发表于 2014-8-31 17:34



    左到右是没有问题的,一行就搞定 _GUICtrlListView_CopyItems($LstPass, $LstFail, True)
关键是右到左,谢谢!
 楼主| 发表于 2014-9-1 20:25:51 | 显示全部楼层
回复 1# touch_xu


        左到右是没有问题的,一行就搞定 _GUICtrlListView_CopyItems($LstPass, $LstFail, True)
关键是右到左,谢谢!
 楼主| 发表于 2014-9-1 20:25:53 | 显示全部楼层
回复 1# touch_xu


        左到右是没有问题的,一行就搞定 _GUICtrlListView_CopyItems($LstPass, $LstFail, True)
关键是右到左,谢谢!
 楼主| 发表于 2014-9-1 20:26:02 | 显示全部楼层
回复 1# touch_xu


        左到右是没有问题的,一行就搞定 _GUICtrlListView_CopyItems($LstPass, $LstFail, True)
关键是右到左,谢谢!
 楼主| 发表于 2014-9-1 20:26:03 | 显示全部楼层
回复 1# touch_xu


        左到右是没有问题的,一行就搞定 _GUICtrlListView_CopyItems($LstPass, $LstFail, True)
关键是右到左,谢谢!
 楼主| 发表于 2014-9-1 20:27:42 | 显示全部楼层
回复 3# chzj589


    感谢感谢,正解,再次感谢!
 楼主| 发表于 2014-9-1 20:29:03 | 显示全部楼层
回复 4# haijie1223


    感谢帮助,刚才测试过了不行,和我的代码一样,仍然感谢!
 楼主| 发表于 2014-9-1 20:40:59 | 显示全部楼层
本帖最后由 touch_xu 于 2014-9-1 20:45 编辑

感谢大家,已经解决了,下面是我的最终代码,谢谢!
#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <GuiImageList.au3>
#include <WindowsConstants.au3>

Opt("GUIOnEventMode", 1)
Global $FrmConfirm, $LstPass, $LstFail, $BtnConfirm, $Right, $Left, $Button, $nItem, $nItem1

;Local $exStyles = BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT, $LVS_EX_CHECKBOXES, $LVS_EX_SUBITEMIMAGES)
Local $exStyles = BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT,  $LVS_EX_SUBITEMIMAGES)
$FrmConfirm = GUICreate("Confirm", 505, 385, -1, -1)
GUISetOnEvent($GUI_EVENT_CLOSE, "_GUI")
$LstPass = GUICtrlGetHandle(GUICtrlCreateListView("", 5, 60, 220, 270, BitOR($LVS_REPORT, $LVS_SHOWSELALWAYS), $WS_EX_CLIENTEDGE))
_GUICtrlListView_SetExtendedListViewStyle($LstPass, $exStyles)

$LstFail = GUICtrlGetHandle(GUICtrlCreateListView("", 280, 60, 220, 270, BitOR($LVS_REPORT, $LVS_SHOWSELALWAYS), $WS_EX_CLIENTEDGE))
_GUICtrlListView_SetExtendedListViewStyle($LstFail, $exStyles)

$BtnConfirm = GUICtrlCreateButton("Finish", 150, 340, 200, 32)
GUICtrlSetOnEvent(-1, "_GUI")

$Right = GUICtrlCreateButton("->", 230, 140, 46, 50)
GUICtrlSetOnEvent(-1, "_GUI")

$Left = GUICtrlCreateButton("<-", 230, 220, 46, 50)
GUICtrlSetOnEvent(-1, "_GUI")

GUISetState(@SW_SHOW, $FrmConfirm)
; 添加列
_GUICtrlListView_AddColumn($LstPass, "NO", 40)
_GUICtrlListView_AddColumn($LstPass, "LOC", 40)
_GUICtrlListView_AddColumn($LstPass, "Symptom", 140)

; 添加列
_GUICtrlListView_AddColumn($LstFail, "NO", 40)
_GUICtrlListView_AddColumn($LstFail, "LOC", 40)
_GUICtrlListView_AddColumn($LstFail, "Symptom", 140)

; 添加项目
_GUICtrlListView_AddItem($LstPass, "01", 0)
_GUICtrlListView_AddSubItem($LstPass, 0, "Cl", 1, 1)
_GUICtrlListView_AddSubItem($LstPass, 0, "ABC", 2, 2)
_GUICtrlListView_AddItem($LstPass, "03", 1)
_GUICtrlListView_AddSubItem($LstPass, 1, "C3", 1, 2)
_GUICtrlListView_AddSubItem($LstPass, 1, "FEG", 2, 2)
_GUICtrlListView_AddItem($LstPass, "04", 2)
_GUICtrlListView_AddSubItem($LstPass, 2, "D3", 1, 2)
_GUICtrlListView_AddSubItem($LstPass, 2, "DEF", 2, 3)
_GUICtrlListView_SetItemSelected($LstPass, 0, True, True)

While 1
        Sleep(10)

WEnd

Func _GUI()

        Switch @GUI_CtrlId

                Case $BtnConfirm, $GUI_EVENT_CLOSE
                        Exit
                Case $Right
                        _GUICtrlListView_CopyItems($LstPass, $LstFail, True)
                        _GUICtrlListView_SetItemSelected($LstPass, 0, True, True)


                Case $Left
                        _GUICtrlListView_CopyItems($LstFail, $LstPass, True)
                        _GUICtrlListView_SetItemSelected($LstPass, 0, True, True)


        EndSwitch
EndFunc   ;==>_GUI
发表于 2014-9-1 21:49:38 | 显示全部楼层
回复 14# touch_xu


移动后,不能删除原项目, 明显是该UDF函数不支持GUICtrlCreateListViewItem建立的项目啊.
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-12-29 09:40 , Processed in 0.079178 second(s), 23 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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