找回密码
 加入
搜索
查看: 7057|回复: 15

[AU3基础] 为何设置ListView的行高不起作用

 火.. [复制链接]
发表于 2016-2-2 20:42:04 | 显示全部楼层 |阅读模式
本帖最后由 dnvplj 于 2016-2-2 20:47 编辑

代码是本论坛上的,时间长了忘了是那位朋友的了,真是对不起。
请问各位朋友,加了图标后,为何设置ListView的行高不起作用,谢谢。
#include <GuiConstantsEx.au3>
#include <GuiListView.au3>
#include <GuiImageList.au3>
#include <WinAPI.au3>
#include <WindowsConstants.au3>

Global $from1, $ListView1
$Form1 = GUICreate("我的列表", 360, 320)
$hImage = _GUIImageList_Create(16, 16, 5, 3)
$ListView1 = GUICtrlCreateListView("列a|列b|列c|列d|列e", 8, 8, 361, 150)
GUICtrlSendMsg($ListView1, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_GRIDLINES, $LVS_EX_GRIDLINES)
Global $gu_ico = _GUIImageList_Create(1, 22)
_GUICtrlListView_SetImageList($ListView1, $gu_ico, 1)
$Button_1 = GUICtrlCreateButton("修改12的图标", 10, 180)
$Button_2 = GUICtrlCreateButton("修改14的图标", 10, 230)

Dim $list[5]

For $i = 0 To 4
        $list[$i] = GUICtrlCreateListViewItem($i & "|1" & $i & "|2" & $i & "|3" & $i & "|4" & $i, $ListView1)
        GUICtrlSetImage(-1, "shell32.dll", 175)
Next

GUISetState(@SW_SHOW)
While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit

                Case $Button_1
                        
                        For $i = 0 To 4
                                $con = ControlListView($from1, "", $ListView1, "FindItem", "13", 1)
                                GUICtrlSetImage($list[$i], "shell32.dll", 13)

                        Next

        EndSwitch
WEnd
发表于 2016-2-3 09:19:21 | 显示全部楼层
看了下帮助凡是带图标没用GUICtrlCreateListViewItem增加项目,不知道是不是他影响了~
#include <GuiConstantsEx.au3>
#include <GuiListView.au3>
#include <GuiImageList.au3>
#include <WinAPI.au3>
#include <WindowsConstants.au3>

Global $from1, $ListView1
$Form1 = GUICreate("我的列表", 360, 320)
$hImage = _GUIImageList_Create(16, 16, 5, 3)
$ListView1 = GUICtrlCreateListView("列a|列b|列c|列d|列e", 8, 8, 361, 150)
GUICtrlSendMsg($ListView1, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_GRIDLINES, $LVS_EX_GRIDLINES)
_GUICtrlListView_SetImageList($ListView1, $hImage, 1)
$Button_1 = GUICtrlCreateButton("修改12的图标", 10, 180)
$Button_2 = GUICtrlCreateButton("修改14的图标", 10, 230)

For $i = 0 To 4
            _GUICtrlListView_AddItem($ListView1, $i)
                _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 175)
                For $j = 0 To 4
                        _GUICtrlListView_AddSubItem($ListView1, $i, $j & $i, $j)
                Next        
Next

GUISetState(@SW_SHOW)

While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
                                        Case $Button_1
                                                _GUIImageList_SetIconSize($hImage, 32, 32)    
                                                For $i = 0 To 4
                                                        _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 13)        
                                                Next
                                                _GUICtrlListView_SetImageList($ListView1, $hImage, 1)
        EndSwitch
WEnd
 楼主| 发表于 2016-2-3 11:27:34 | 显示全部楼层
回复 2# 繁星
谢谢楼上朋友的回复,如果取消“  21.  GUICtrlSetImage(-1, "shell32.dll", 175)”这项设置行高就起作用,否则,不能,也不知为什么?
 楼主| 发表于 2016-2-4 10:16:34 | 显示全部楼层
为何下面这两行代码前2位数相同,就换不了图标呢。
$hImage = _GUIImageList_Create(22, 22, 5, 3)
_GUIImageList_SetIconSize($hImage, 22,22)
发表于 2016-2-4 18:16:04 | 显示全部楼层
_GUIImageList_SetIconSize之后需要_GUICtrlListView_SetImageList才会更改图标,
前两位代表宽高,我理解为数值不同时和相同的区别在于,不同时重新设置大小图片控件的伸缩会导致重载重新分配图标,
数值相同时,实际已经更改了图标,但因为大小相同,所以没有重新重载分配图标,所以看着还是以前的,
 楼主| 发表于 2016-2-4 18:43:53 | 显示全部楼层
本帖最后由 dnvplj 于 2016-2-4 19:07 编辑

回复 5# 繁星
这个问题明白了,行高的问题还没有解决。
发表于 2016-2-5 13:59:33 | 显示全部楼层
回复 6# dnvplj


    贴行高问题代码
 楼主| 发表于 2016-2-5 15:01:43 | 显示全部楼层
回复 7# 繁星
一楼的第9行和12行就是
发表于 2016-2-5 22:17:38 | 显示全部楼层
呵呵,学习了
发表于 2016-2-13 12:44:14 | 显示全部楼层
呵呵,学习了
发表于 2016-2-14 19:20:46 | 显示全部楼层
 楼主| 发表于 2016-2-15 07:53:49 | 显示全部楼层
请后来的朋友注意,帖子还没有解决。
发表于 2016-2-21 18:45:28 | 显示全部楼层
学习一下。
发表于 2016-2-28 01:34:01 | 显示全部楼层
学习一下。
发表于 2016-2-28 02:09:06 | 显示全部楼层
学习一下.最近了也在研究listview
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-4-25 13:04 , Processed in 0.083945 second(s), 23 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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