找回密码
 加入
搜索
查看: 12129|回复: 23

[GUI管理] 如何修改listview列表框中某一行的图标(已解决)

 火.. [复制链接]
发表于 2012-2-19 18:18:12 | 显示全部楼层 |阅读模式
本帖最后由 nmgwddj 于 2012-2-19 22:21 编辑

如图,通过右键“换图标”按钮,修改其中一行的图标。因为列表信息是通过for循环创建的,无法定位某一行的的控件ID,不知各位有啥想法。看了看udf貌似没有处理这方面的函数。

论坛中看了其他的方法,http://www.autoitx.com/forum.php ... view%2B%CD%BC%B1%EA
我是想不通过控件ID的方式,来修改图标,因为我的确无法定位我到底要创建多少行信息。
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>
#include <WindowsConstants.au3>
#region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 496, 389, 270, 202)
$ListView1 = GUICtrlCreateListView("col1|col2|col3", 16, 16, 466, 302)
$ListViewButton = GUICtrlCreateContextMenu($ListView1)
$ListBut_1 = GUICtrlCreateMenuItem("换图标", $ListViewButton)
$ListBut_2 = GUICtrlCreateMenuItem("Eixt", $ListViewButton)
$Button1 = GUICtrlCreateButton("Button1", 328, 336, 75, 25)
$Button2 = GUICtrlCreateButton("Exit", 408, 336, 75, 25)
GUISetState(@SW_SHOW)
#endregion ### END Koda GUI section ###

For $i = 1 To 10
        GUICtrlCreateListViewItem('1 - ' & $i & '|2 - ' & $i & '|3 - ' & $i, $ListView1)
        GUICtrlSetImage(-1, @SystemDir & '\shell32.dll', -25)
Next


While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE, $ListBut_2, $Button2
                        Exit

        EndSwitch
WEnd

本帖子中包含更多资源

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

×
发表于 2012-2-19 18:25:40 | 显示全部楼层
_GUICtrlListView_GetItemFocused或者_GUICtrlListView_GetItemSelected
不就知道了
 楼主| 发表于 2012-2-19 18:29:42 | 显示全部楼层
回复 2# netegg


    能确定是否高亮,是否被选中,但是我不知道用啥函数给这一行换图标。

比如GUICtrlSetImage,要知道控件ID后才能换
发表于 2012-2-19 19:00:42 | 显示全部楼层
回复 3# nmgwddj

你要的控件id指的是什么,图标的?
 楼主| 发表于 2012-2-19 19:31:23 | 显示全部楼层
回复 4# netegg


   你看,设置图标的时候可以用GUICtrlSetImage,但是第一个参数就是需要控件的ID,列表中有很多行,不知道每一行的控件ID是多少。所以通过GUICtrlSetImage来设置图标就实现不了。

我就是问问大家是否有其他的方法
发表于 2012-2-19 19:55:14 | 显示全部楼层
_GUIImageList_Create
_GUICtrlListView_Create
_GUICtrlListView_SetImageList
 楼主| 发表于 2012-2-19 19:56:31 | 显示全部楼层
我看看,先谢谢您了。
发表于 2012-2-19 20:00:47 | 显示全部楼层
_GUICtrlListView_SetItemImage()
发表于 2012-2-19 20:05:28 | 显示全部楼层
本帖最后由 netegg 于 2012-2-19 20:08 编辑

回复 8# afan

lz要的好像是指定行的图标,后期替换
说实话,我也不是很清楚lz的真正意图何在
而且一直就没弄明白为什么一定要controlid
发表于 2012-2-19 20:11:14 | 显示全部楼层
回复 9# netegg


    后期替换? 不懂意思… _GUICtrlListView_SetItemImage 可以换是肯定的
貌似刚才LZ连自己的头像也换了…
 楼主| 发表于 2012-2-19 20:22:58 | 显示全部楼层
回复 10# afan


    恩,头像换了,之前的不好看

我是在制作一个管理软件,要想系统用户管理界面一样,我把某个用户禁用后,图标是一种状态,启用后又是另外一种状态,通过listview右键菜单的方式禁用和启用。就是在后期改。正如netegg所说。
发表于 2012-2-19 20:26:35 | 显示全部楼层
回复 11# nmgwddj


    不管前期中期后期,都可以换
_GUIImageList_Create
_GUICtrlListView_Create
_GUICtrlListView_SetImageList
+
_GUICtrlListView_SetItemImage
 楼主| 发表于 2012-2-19 20:31:53 | 显示全部楼层
我在看您之前帮我写的启动项管理工具,有类似功能的。
。。手里太忙,还在上班,烦透了,一点都清闲不下来。
发表于 2012-2-19 20:45:44 | 显示全部楼层
回复 1# nmgwddj

这样不行吗?
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>
#include <WindowsConstants.au3>
#include <GuiListView.au3>

#region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 496, 389, 270, 202)
$ListView1 = GUICtrlCreateListView("col1|col2|col3", 16, 16, 466, 302)
$ListViewButton = GUICtrlCreateContextMenu($ListView1)
$ListBut_1 = GUICtrlCreateMenuItem("换图标", $ListViewButton)
$ListBut_2 = GUICtrlCreateMenuItem("Eixt", $ListViewButton)
$Button1 = GUICtrlCreateButton("Button1", 328, 336, 75, 25)
$Button2 = GUICtrlCreateButton("Exit", 408, 336, 75, 25)
GUISetState(@SW_SHOW)
#endregion ### END Koda GUI section ###

Local $ListViewItem[10]

For $i = 0 To 9
        $ListViewItem[$i] = GUICtrlCreateListViewItem('1 - ' & $i & '|2 - ' & $i & '|3 - ' & $i, $ListView1)
        GUICtrlSetImage(-1, @SystemDir & '\shell32.dll', -25)
Next


While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE, $ListBut_2, $Button2
                        Exit
                Case $ListBut_1
                        For $count = 0 To 9
                                $check = _GUICtrlListView_GetItemState($ListView1, $count, $LVIS_SELECTED)
                                If $check Then ExitLoop
                        Next
                        GUICtrlSetImage($ListViewItem[$count], @SystemDir & '\shell32.dll', -20)
        EndSwitch
WEnd

评分

参与人数 1金钱 +20 收起 理由
afan + 20

查看全部评分

 楼主| 发表于 2012-2-19 20:51:16 | 显示全部楼层
回复 14# lixiaolong


    狂到,是这效果,还没看明白你是咋实现的。。。我这人太多了稍等一会看,先谢谢。
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-4-28 21:17 , Processed in 0.084491 second(s), 23 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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