TreeView和ListView共用ImageList,TreeView图标覆盖问题【已解决】
本帖最后由 imutraveler 于 2016-10-26 23:30 编辑TreeView图标设置了点击和非点击2种状态图标,,但是listView也使用该ImageList的时候,TreeView的图标为什么就不刷新的,而变成了覆盖呢?
下面是有问题的 例子。。。要没问题注释35行, 启用38行,
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GuiListView.au3>
#include <GuiTreeView.au3>
$Form1 = GUICreate("test", 500, 280)
$hImage = _GUIImageList_Create(16, 16, 5, 3)
_GUIImageList_AddIcon($hImage, 'shell32.dll', 110)
_GUIImageList_AddIcon($hImage, 'shell32.dll', 137)
_GUIImageList_AddIcon($hImage, 'shell32.dll', 146)
_GUIImageList_AddIcon($hImage, 'shell32.dll', 66)
$iImage = _GUIImageList_Create(16, 16, 5, 3)
_GUIImageList_AddIcon($iImage, 'shell32.dll', 110)
_GUIImageList_AddIcon($iImage, 'shell32.dll', 137)
_GUIImageList_AddIcon($iImage, 'shell32.dll', 146)
_GUIImageList_AddIcon($iImage, 'shell32.dll', 66)
$TreeView = GUICtrlCreateTreeView(10, 10, 160, 260, BitOR($TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS), $WS_EX_CLIENTEDGE)
_GUICtrlTreeView_SetNormalImageList($TreeView, $hImage)
$Group = _GUICtrlTreeView_Add($TreeView, 0, "分组列表", 0, 0)
_GUICtrlTreeView_AddChild($TreeView, $Group, "测试分组01", 1, 2) ;生成分组列表
_GUICtrlTreeView_AddChild($TreeView, $Group, "测试分组02", 1, 2) ;生成分组列表
_GUICtrlTreeView_AddChild($TreeView, $Group, "测试分组03", 1, 2) ;生成分组列表
_GUICtrlTreeView_AddChild($TreeView, $Group, "测试分组04", 1, 2) ;生成分组列表
_GUICtrlTreeView_AddChild($TreeView, $Group, "测试分组05", 1, 2) ;生成分组列表
_GUICtrlTreeView_Expand($TreeView, $Group) ;展开列表
_GUICtrlTreeView_SelectItemByIndex($TreeView, $Group, 0) ;启动时默认选择第一个分组
$ListView = GUICtrlCreateListView("", 180, 10, 310, 260)
;;;!!!与 TreeView 共用一个 ImageList
_GUICtrlListView_SetImageList($ListView, $hImage, 1)
;;;!!!单独使用一个 ImageList
;~ _GUICtrlListView_SetImageList($ListView, $iImage, 1)
_GUICtrlListView_AddColumn($ListView, "1", 100) ;创建列
_GUICtrlListView_AddColumn($ListView, "2", 80) ;创建列
_GUICtrlListView_AddColumn($ListView, "3", 80) ;创建列
_GUICtrlListView_SetExtendedListViewStyle($ListView, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_GRIDLINES)) ;设置ListView样式
For $i = 1 To 5
_GUICtrlListView_AddItem($ListView, StringFormat("测试[%02d]", $i), 3)
_GUICtrlListView_AddSubItem($ListView, $i-1, "000", 1)
_GUICtrlListView_AddSubItem($ListView, $i-1, "000", 2)
Next
GUISetState(@SW_SHOW)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
EndSwitch
WEnd
本帖最后由 chzj589 于 2016-9-30 09:14 编辑
回复 1# imutraveler
这样是什么问题?我没注释35行
回复 2# chzj589
在XP和 2003上 没问题 , 我试过了!!
你试试 win7和win10 回复 3# imutraveler
我电脑没装win7和win10系统 回复 4# chzj589
{:face (245):}{:face (245):}{:face (245):} 回复 5# imutraveler
AU3在XP系统编辑是最稳定的!
{:face (355):}
页:
[1]