如何创建一个如此效果的ListView控件?
如图:一般创建的ListView控件是这样的:如何创建一个如下图效果的ListView控件呢?
同问,帮顶~ 顶顶。。。不会。 我也不懂得怎么写,也想写这个东西,毕竟用到 本帖最后由 netegg 于 2009-7-25 21:55 编辑
加个扩展样式 _guictrllistview_create($hListview, bitor($LVS_SMALLICON, $LVS_EX_CHECKBOXES)) 加个扩展样式 _guictrllistview_create($hListview, bitor($LVS_SMALLICON, $LVS_EX_CHECKBOXES)) 只是多个控件组合在一起而已,熟用_WinAPI_SetParent可以组合出很多有趣的控件。 本帖最后由 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()
顺便请教一下:
Group部分的文字背景(灰色)和文字前面的图标该如何解决? #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 #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 http://www.autoitx.com/images/common/back.gif
学习了~谢谢提供这么全的样式~~ 路过...路过..路过 这几天频繁用到listview
也做个记号 最近正在学习这个,先记下。 呵呵,学习一下。。