【已解决】为何无法复制左侧的图标到右侧listview里面
本帖最后由 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
{:face (368):}没有一个回复。。。。 那我还是想想其他方式,谢谢大家{:face (370):} 大圖標 小圖標問題
問題出在
_GUICtrlListView_SetImageList($ListView1, $hImage, 0)
_GUICtrlListView_SetImageList($ListView2, $hImage, 0)
右手邊的應該是 1小圖標才對 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
kk_lee69 发表于 2019-3-14 02:02
感谢大佬百忙间的回复。不过这样的效果跟我预想的实际还是有差异。之前有查看过例子,小图标可以复制过去,大图标就直接丢失。感恩~~这个我想想其他方法。感恩{:face (88):} 确定第11行不是 GUICtrlSetStyle($ListView2 , $LVS_ICON) ? afan 发表于 2019-3-14 10:57
确定第11行不是 GUICtrlSetStyle($ListView2 , $LVS_ICON) ?
哥,是我失误。。。。。确实是。。。。我临时修改测试。。。。失误。。。海涵~~ xyhqqaa 发表于 2019-3-14 11:56
哥,是我失误。。。。。确实是。。。。我临时修改测试。。。。失误。。。海涵~~
不是海涵不海涵,改了不就ok了? 不测试下?_ _| 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
chzj589 发表于 2019-3-14 15:43
测试成功,主要为了实现将个别模块添加到常用页面,实现方便查看~~~感谢大家。困扰了好几天,还是自己太马虎了。。感谢感谢~~~
页:
[1]