找回密码
 加入
搜索
查看: 9928|回复: 39

如何创建一个如此效果的ListView控件?

 火... [复制链接]
发表于 2008-12-2 13:55:00 | 显示全部楼层 |阅读模式
如图:一般创建的ListView控件是这样的:



如何创建一个如下图效果的ListView控件呢?

本帖子中包含更多资源

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

×
发表于 2009-6-16 00:37:18 | 显示全部楼层
同问,帮顶~
发表于 2009-6-16 08:55:31 | 显示全部楼层
顶顶。。。不会。
发表于 2009-7-25 21:03:58 | 显示全部楼层
我也不懂得怎么写,也想写这个东西,毕竟用到
发表于 2009-7-25 21:53:54 | 显示全部楼层
本帖最后由 netegg 于 2009-7-25 21:55 编辑

加个扩展样式 _guictrllistview_create($hListview, bitor($LVS_SMALLICON, $LVS_EX_CHECKBOXES))
发表于 2009-7-25 21:55:32 | 显示全部楼层
加个扩展样式 _guictrllistview_create($hListview, bitor($LVS_SMALLICON, $LVS_EX_CHECKBOXES))
发表于 2009-7-25 22:10:53 | 显示全部楼层
只是多个控件组合在一起而已,熟用_WinAPI_SetParent可以组合出很多有趣的控件。
发表于 2009-7-25 22:32:04 | 显示全部楼层
本帖最后由 lynfr8 于 2009-7-26 00:27 编辑

模仿效果:(红块和绿块可自行更换为图标)
#include <GuiConstantsEx.au3>
#include <GuiListView.au3>
#include <GuiImageList.au3>
#include <Constants.au3>
Opt('MustDeclareVars', 1)
$Debug_LV = False 
Local $hImage, $hListView 
        
        GUICreate("创建带Group分组的ListView演示 By lynfr8", 500, 200)

        $hListView = GUICtrlCreateListView("", 2, 2, 494, 192)
_GUICtrlListView_SetExtendedListViewStyle($hListView, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_CHECKBOXES))
        GUISetState()

        ; Load images
        $hImage = _GUIImageList_Create()
        _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($hListView, 0xFF0000, 16, 16))
        _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($hListView, 0x00FF00, 16, 16))
        _GUICtrlListView_SetImageList($hListView, $hImage, 1)

        ; Add columns
        _GUICtrlListView_AddColumn($hListView, "自动运行项入口", 100)
        _GUICtrlListView_AddColumn($hListView, "发行商名称", 100)
        _GUICtrlListView_AddColumn($hListView, "描述信息", 100)

        ; Add items
        _GUICtrlListView_AddItem($hListView, "ctfmon.exe", 0)
        _GUICtrlListView_AddSubItem($hListView, 0, "Micrsoft Corporation", 1)
        _GUICtrlListView_AddSubItem($hListView, 0, "CTF Loader", 2)
        
        _GUICtrlListView_AddItem($hListView, "UVS11 Preload", 1)
        _GUICtrlListView_AddSubItem($hListView, 1, "InterVideo Digital", 1)
        _GUICtrlListView_AddSubItem($hListView,1,"Ulead VideoStudio", 2)

        ; Build groups
        _GUICtrlListView_EnableGroupView($hListView)
        _GUICtrlListView_InsertGroup($hListView, -1, 1, "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run")
        _GUICtrlListView_InsertGroup($hListView, -1, 2, "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run")
        _GUICtrlListView_SetItemGroupID($hListView, 0, 1)
        _GUICtrlListView_SetItemGroupID($hListView, 1, 2)
        _GUICtrlListView_SetItemGroupID($hListView, 2, 2)

        ; Loop until user exits
        Do
        Until GUIGetMsg() = $GUI_EVENT_CLOSE

        GUIDelete()

本帖子中包含更多资源

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

×
发表于 2009-7-25 22:35:05 | 显示全部楼层
顺便请教一下:
Group部分文字背景(灰色)文字前面的图标该如何解决?
发表于 2009-7-25 22:56:46 | 显示全部楼层
#include <WinAPI.au3>
#include <GUIButton.au3>
#include <GUIListView.au3>
#include <GUIImageList.au3>
#include <WindowsConstants.au3>

$hGUI = GUICreate("Test", 400, 300)

$sColumn = "Test|of|Mutiple Controls"
$iStyle = bitOR($LVS_REPORT, $LVS_SINGLESEL, $LVS_NOSORTHEADER)
$iExStyle = bitOR($LVS_EX_FULLROWSELECT, $WS_EX_CLIENTEDGE)

$iListView = GUICtrlCreateListView($sColumn, 5, 5, 390, 290, $iStyle, $iExStyle)
$hListView = GUICtrlGetHandle(-1)

_GUICtrlListView_SetColumnWidth($hListView, 0, 120)
_GUICtrlListView_SetColumnWidth($hListView, 1, 165)
_GUICtrlListView_SetColumnWidth($hListView, 2, 105)


$hCall = DllCallbackRegister("_ListViewProc", "int", "hWnd;uint;wparam;lparam")
$pCall = DllCallbackGetPtr($hCall)
$hOldC = _WinAPI_SetWindowLong($hListView, -4, $pCall)

GUICtrlCreateIcon("Shell32.dll", 3, 0, 20, 16, 16)
_WinAPI_SetParent(GUICtrlGetHandle(-1), $hListView)
GUICtrlCreateLabel(" HKLM\Software\Microsoft\...", 16, 20, 390, 16)
GUICtrlSetFont(-1, 10, 800, "", "Garamond")
_WinAPI_SetParent(GUICtrlGetHandle(-1), $hListView)

$hImage = _GUIImageList_Create(14, 14, 5, 3)
For $i = 1 to 7
        _GUIImageList_AddIcon($hImage, "Shell32.dll", 130)
Next


GUICtrlCreateCheckBox(" ctfmon.exe", 0, 38, 120, 16)
_GUICtrlButton_SetImageList(-1, $hImage)
_WinAPI_SetParent(GUICtrlGetHandle(-1), $hListView)
GUICtrlCreateInput("Microsoft Corporation", 120, 39, 160, 16, 0, 4)
_WinAPI_SetParent(GUICtrlGetHandle(-1), $hListView)


GUICtrlCreateCheckBox(" AutoIt3.exe", 0, 55, 120, 16)
_GUICtrlButton_SetImageList(-1, $hImage) 
_WinAPI_SetParent(GUICtrlGetHandle(-1), $hListView)

GUICtrlCreateInput(" N/A", 285, 55, 25, 16, 0, 4)
_WinAPI_SetParent(GUICtrlGetHandle(-1), $hListView)

GUICtrlCreateIcon("Shell32.dll", 21, 0, 72, 16, 16)
_WinAPI_SetParent(GUICtrlGetHandle(-1), $hListView)

GUICtrlCreateLabel(" HKLM\Software\Microsoft\...", 16, 72, 390, 16)
GUICtrlSetFont(-1, 10, 800, "", "Garamond")
_WinAPI_SetParent(GUICtrlGetHandle(-1), $hListView)

$hImage = _GUIImageList_Create(14, 14, 5, 3)
For $i = 1 to 7
        _GUIImageList_AddIcon($hImage, "Shell32.dll", 131)
Next

GUICtrlCreateRadio(" KavPFW", 0, 90, 120, 16)
_GUICtrlButton_SetImageList(-1, $hImage)
_WinAPI_SetParent(GUICtrlGetHandle(-1), $hListView)


GUICtrlCreateRadio(" lsass.exe", 122, 90, 120, 16)
_GUICtrlButton_SetImageList(-1, $hImage)
_WinAPI_SetParent(GUICtrlGetHandle(-1), $hListView)

GUICtrlCreateRadio(" csrss.exe", 287, 90, 120, 16)
_GUICtrlButton_SetImageList(-1, $hImage)
_WinAPI_SetParent(GUICtrlGetHandle(-1), $hListView)

GUICtrlCreateInput("Input some text here.", 3, 108, 380, 16)
_WinAPI_SetParent(GUICtrlGetHandle(-1), $hListView)

GUISetState()


Do
Until guiGetMsg() = -3

Func _ListViewProc($hWnd, $iMsg, $wparam, $lparam)
        If $iMsg = $WM_NOTIFY Then Return 1
        Return _WinAPI_CallWindowProc($hOldC, $hWnd, $iMsg, $wparam, $lparam)
EndFunc        ;==>_ListViewProc

评分

参与人数 1金钱 +10 贡献 +5 收起 理由
lynfr8 + 10 + 5 学习了

查看全部评分

发表于 2009-7-25 23:52:21 | 显示全部楼层
#include
#include
#include
#include
#include

$hGUI = GUICreate("Test", 400, 300)

$sColumn = "Test|of|Mutiple Controls"
$iStyle = bitOR($LVS_REPORT, $LVS_SINGLESEL, $LVS_NOSORTHEADER)
...
pusofalse 发表于 2009-7-25 22:56


学习了~谢谢提供这么全的样式~~
发表于 2009-7-28 09:37:35 | 显示全部楼层
路过...路过..路过
发表于 2009-9-6 11:46:00 | 显示全部楼层
这几天频繁用到listview
也做个记号
发表于 2009-9-6 13:32:55 | 显示全部楼层
最近正在学习这个,先记下。
发表于 2009-9-7 12:26:32 | 显示全部楼层
呵呵,学习一下。。
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-5-16 20:09 , Processed in 0.078693 second(s), 21 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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