找回密码
 加入
搜索
查看: 2456|回复: 11

[网络通信] 【已解决】为何无法复制左侧的图标到右侧listview里面

[复制链接]
发表于 2019-3-12 22:47:28 | 显示全部楼层 |阅读模式
本帖最后由 xyhqqaa 于 2019-3-14 15:24 编辑



求助大佬们,想实现把左侧的图标复制到右侧,但是图标一直无法复制过去~~求懂的大佬指教下!!
               #include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>
#include <WindowsConstants.au3>
#include <GuiListView.au3>
#include <GuiImageList.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 716, 367, 192, 124)
$ListView1 = GUICtrlCreateListView("", 16, 24, 322, 334)
GUICtrlSetStyle($ListView1 , $LVS_ICON)
$ListView2 = GUICtrlCreateListView("", 344, 24, 370, 334)
GUICtrlSetStyle($ListView2 , $LVS_ICON)

$hImage = _GUIImageList_Create(16, 16, 5, 3)
        _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 13)
        _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 14)
        _GUICtrlListView_SetImageList($ListView1, $hImage, 0)
        _GUICtrlListView_SetImageList($ListView2, $hImage, 0)
        ; Add columns
        _GUICtrlListView_AddColumn($ListView1, "", 120)
        ; Add columns
        _GUICtrlListView_AddColumn($ListView2, "", 120)
        ; Add items
        _GUICtrlListView_AddItem($ListView1, "Row 1", 0)
        _GUICtrlListView_AddItem($ListView1, "Row 2", 1)

$ListView1context = GUICtrlCreateContextMenu($ListView1)
$MenuItem1 = GUICtrlCreateMenuItem("右键添加到右侧", $ListView1context)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
                        
                        
                Case $MenuItem1
                        _GUICtrlListView_CopyItems($ListView1, $ListView2)

        EndSwitch
WEnd







本帖子中包含更多资源

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

×
 楼主| 发表于 2019-3-13 23:47:44 | 显示全部楼层
  没有一个回复。。。。
 楼主| 发表于 2019-3-13 23:48:45 | 显示全部楼层
那我还是想想其他方式,谢谢大家
发表于 2019-3-14 02:00:49 | 显示全部楼层
大圖標 小圖標問題  

問題出在
        _GUICtrlListView_SetImageList($ListView1, $hImage, 0)
        _GUICtrlListView_SetImageList($ListView2, $hImage, 0)

右手邊的應該是 1  小圖標才對
发表于 2019-3-14 02:02:50 | 显示全部楼层
xyhqqaa 发表于 2019-3-13 23:48
那我还是想想其他方式,谢谢大家
#include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>
#include <WindowsConstants.au3>
#include <GuiListView.au3>
#include <GuiImageList.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 716, 367, 192, 124)
$ListView1 = GUICtrlCreateListView("", 16, 24, 322, 334)
GUICtrlSetStyle($ListView1 , $LVS_ICON)
$ListView2 = GUICtrlCreateListView("", 344, 24, 370, 334)
GUICtrlSetStyle($ListView1 , $LVS_ICON)

$hImage = _GUIImageList_Create(16, 16, 5, 3)
        _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 13)
        _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 14)
        _GUICtrlListView_SetImageList($ListView1, $hImage, 0)
        _GUICtrlListView_SetImageList($ListView2, $hImage, 1)
        ; Add columns
        _GUICtrlListView_AddColumn($ListView1, "", 120)
        ; Add columns
        _GUICtrlListView_AddColumn($ListView2, "", 120)
        ; Add items
        _GUICtrlListView_AddItem($ListView1, "Row 1", 0)
        _GUICtrlListView_AddItem($ListView1, "Row 2", 1)

$ListView1context = GUICtrlCreateContextMenu($ListView1)
$MenuItem1 = GUICtrlCreateMenuItem("右?添加到右?", $ListView1context)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
                        
                        
                Case $MenuItem1
                        _GUICtrlListView_CopyItems($ListView1, $ListView2)

        EndSwitch
WEnd

评分

参与人数 1金钱 +10 收起 理由
xyhqqaa + 10 赞一个!

查看全部评分

 楼主| 发表于 2019-3-14 10:30:19 | 显示全部楼层

感谢大佬百忙间的回复。不过这样的效果跟我预想的实际还是有差异。之前有查看过例子,小图标可以复制过去,大图标就直接丢失。感恩~~这个我想想其他方法。感恩
发表于 2019-3-14 10:57:01 | 显示全部楼层
确定第11行不是 GUICtrlSetStyle($ListView2 , $LVS_ICON) ?
 楼主| 发表于 2019-3-14 11:56:42 | 显示全部楼层
afan 发表于 2019-3-14 10:57
确定第11行不是 GUICtrlSetStyle($ListView2 , $LVS_ICON) ?

哥,是我失误。。。。。确实是。。。。我临时修改测试。。。。失误。。。海涵~~
发表于 2019-3-14 14:14:22 | 显示全部楼层
xyhqqaa 发表于 2019-3-14 11:56
哥,是我失误。。。。。确实是。。。。我临时修改测试。。。。失误。。。海涵~~

不是海涵不海涵,改了不就ok了? 不测试下?  _ _|
 楼主| 发表于 2019-3-14 15:23:59 | 显示全部楼层
afan 发表于 2019-3-14 14:14
不是海涵不海涵,改了不就ok了? 不测试下?  _ _|

感谢afan哥。。我找到原因了。至于GUICtrlSetStyle($ListView1 , $LVS_ICON)这个,是我精简源码拷贝过来用来发论坛方便大家查看,没注意修改导致,不过这个不是影响结果的原因。不过根据您的提醒,我仔细看了下,是因为_GUICtrlListView_SetImageList($ListView2, $hImage, 0),默认小图标模式。我把他更改为大图标后就可以了。。。感恩~~是我马虎了~~不好意思。谢谢afan哥


#include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>
#include <WindowsConstants.au3>
#include <GuiListView.au3>
#include <GuiImageList.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 716, 367, 192, 124)
$ListView1 = GUICtrlCreateListView("", 16, 24, 322, 334)
GUICtrlSetStyle($ListView1 , $LVS_ICON)
$ListView2 = GUICtrlCreateListView("", 344, 24, 370, 334)
GUICtrlSetStyle($ListView2 , $LVS_ICON)
$hImage = _GUIImageList_Create(16, 16, 5, 3)
        _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 13)
        _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 14)
        _GUICtrlListView_SetImageList($ListView1, $hImage, 0)
       ; _GUICtrlListView_SetImageList($ListView2, $hImage, 0)
        _GUICtrlListView_SetImageList($ListView2, $hImage, 1)
        ; Add columns
        _GUICtrlListView_AddColumn($ListView1, "", 120)
        ; Add columns
        _GUICtrlListView_AddColumn($ListView2, "", 120)
        ; Add items
        _GUICtrlListView_AddItem($ListView1, "Row 1", 0)
        _GUICtrlListView_AddItem($ListView1, "Row 2", 0)
$ListView1context = GUICtrlCreateContextMenu($ListView1)
$MenuItem1 = GUICtrlCreateMenuItem("右?添加到右?", $ListView1context)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
                Case $MenuItem1
                        _GUICtrlListView_CopyItems($ListView1, $ListView2)
        EndSwitch
WEnd



发表于 2019-3-14 15:43:31 | 显示全部楼层

本帖子中包含更多资源

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

×
 楼主| 发表于 2019-3-14 17:29:05 | 显示全部楼层

  测试成功,主要为了实现将个别模块添加到常用页面,实现方便查看~~~感谢大家。困扰了好几天,还是自己太马虎了。。感谢感谢~~~

本帖子中包含更多资源

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

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

本版积分规则

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

GMT+8, 2024-4-27 04:52 , Processed in 0.084385 second(s), 21 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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