找回密码
 加入
搜索
楼主: nmgwddj

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

 火.. [复制链接]
 楼主| 发表于 2012-2-19 20:56:24 | 显示全部楼层
回复 14# lixiaolong


   看了看代码,是这个意思,但是我无法确定我到底创建了多少个控件,您的例子与我主题中发的地址例子是一样的。

所以我还是想通过上面_GUICtrlListView_SetItemImage的方式来实现
 楼主| 发表于 2012-2-19 21:08:26 | 显示全部楼层
回复 12# afan

能不能只换一行!!这样所有listview列表框的图标都设置没了,搞笑了,而且用_GUIImageList_AddIcon添加的图像列表,图标背景成黑色了!
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>
#include <WindowsConstants.au3>
#Include <GuiListView.au3>
#include <GuiImageList.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', -28)
Next


While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE, $ListBut_2, $Button2
                        Exit
                Case $ListBut_1
                        SetImage()
        EndSwitch
WEnd

Func SetImage()
        $hImage = _GUIImageList_Create()
    _GUIImageList_AddIcon($hImage, @SystemDir & '\shell32.dll', -25)
    _GUICtrlListView_SetImageList($ListView1, $hImage, 1)
        _GUICtrlListView_SetItemImage($ListView1, 1, 3);换第三行
EndFunc
发表于 2012-2-19 21:58:41 | 显示全部楼层
#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
        ConsoleWrite(GUICtrlCreateListViewItem('1 - ' & $i & '|2 - ' & $i & '|3 - ' & $i, $ListView1)&@CRLF)
        GUICtrlSetImage(-1, @SystemDir & '\shell32.dll', -25)
Next

While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE, $ListBut_2, $Button2
                        Exit
                Case $ListBut_1
                        GUICtrlSetImage(GUICtrlRead($ListView1), @SystemDir & '\shell32.dll', -20)
        EndSwitch
WEnd
最简单的解决方案

评分

参与人数 3金钱 +90 贡献 +5 收起 理由
nmgwddj + 40
afan + 20
lixiaolong + 30 + 5 Good!!

查看全部评分

发表于 2012-2-19 22:09:33 | 显示全部楼层
回复 18# 298311657

GUICtrlRead($ListView1),没想到,学习了!!
发表于 2012-2-19 22:15:32 | 显示全部楼层
回复 17# nmgwddj


    既然是 GUICtrlCreateListViewItem() 创建的 Item,用 298311657 写的的设置 Id 图标的方式足矣

评分

参与人数 1金钱 +40 收起 理由
nmgwddj + 40

查看全部评分

 楼主| 发表于 2012-2-19 22:20:42 | 显示全部楼层
我靠!!!竟然如此简单!!给力给力中。
 楼主| 发表于 2012-2-19 22:22:21 | 显示全部楼层
回复 20# afan


    A版您指的 298311657 是什么意思?
发表于 2012-2-19 22:23:04 | 显示全部楼层
回复  afan


    A版您指的 298311657 是什么意思?
nmgwddj 发表于 2012-2-19 22:22



    18#的大虾~
发表于 2012-2-25 17:01:57 | 显示全部楼层
谢谢楼主共享好源码
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-5-14 01:42 , Processed in 0.065516 second(s), 15 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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