mLipok Posted May 12 Posted May 12 Here's an example, but it doesn't work well expandcollapse popup#include <GUIConstantsEx.au3> #include <GuiImageList.au3> #include <GuiListView.au3> Global Const $LVNI_SAMEGROUPONLY = 0x0080 Example() Func Example() GUICreate("ListView Enable Group View", 400, 300) Local $idListview = GUICtrlCreateListView("", 2, 2, 394, 268) Local $hLV = GUICtrlGetHandle($idListview) GUISetState(@SW_SHOW) ; Add columns _GUICtrlListView_InsertColumn($idListview, 0, "Column 1", 150) _GUICtrlListView_InsertColumn($idListview, 1, "Column 2", 100) _GUICtrlListView_InsertColumn($idListview, 2, "Column 3", 100) ; Add items _GUICtrlListView_AddItem($idListview, "Item 0 Row 1: Col 1") _GUICtrlListView_AddSubItem($idListview, 0, "Row 1: Col 2", 1) _GUICtrlListView_AddSubItem($idListview, 0, "Row 1: Col 3", 2) _GUICtrlListView_AddItem($idListview, "Item 1 Row 2: Col 1") _GUICtrlListView_AddSubItem($idListview, 1, "Row 2: Col 2", 1) _GUICtrlListView_AddItem($idListview, "Item 2 Row 3: Col 1") _GUICtrlListView_AddItem($idListview, "Item 3 Row 4: Col 1") _GUICtrlListView_AddItem($idListview, "Item 4 Row 5: Col 1") _GUICtrlListView_AddItem($idListview, "Item 5 Row 6: Col 1") ; Build groups _GUICtrlListView_EnableGroupView($idListview) _GUICtrlListView_InsertGroup($idListview, -1, 101, "Group 101") _GUICtrlListView_InsertGroup($idListview, -1, 202, "Group 202") _GUICtrlListView_SetItemGroupID($idListview, 0, 101) _GUICtrlListView_SetItemGroupID($idListview, 1, 101) _GUICtrlListView_SetItemGroupID($idListview, 2, 202) _GUICtrlListView_SetItemGroupID($idListview, 3, 202) _GUICtrlListView_SetItemGroupID($idListview, 4, 202) _GUICtrlListView_SetItemGroupID($idListview, 5, 202) _GetGroupAllItems($hLV, 101) _GetGroupAllItems($hLV, 202) ; Loop until the user exits. Do Until GUIGetMsg() = $GUI_EVENT_CLOSE GUIDelete() EndFunc ;==>Example Func _GetGroupAllItems($hLV, $iGroupID) Local $iFirstItem = _GetGroupFirstItem($hLV, $iGroupID) Local $iNextItem = $iFirstItem ConsoleWrite("> iGroupID = " & $iGroupID & " $iFirstItem = " & $iFirstItem & @CRLF) Do $iNextItem = _GetGroupNextItem($hLV, $iNextItem) ConsoleWrite("- $iNextItem = " & $iNextItem & @CRLF) Until $iNextItem = -1 EndFunc ;==>_GetGroupAllItems Func _GetGroupNextItem($hLV, $iItemIndex) Local $iFound = _SendMessage( _ $hLV, _ $LVM_GETNEXTITEM, _ $iItemIndex, _ $LVNI_SAMEGROUPONLY) Return $iFound EndFunc ;==>_GetGroupNextItem Func _GetGroupFirstItem($hLV, $iGroupID) Local $tag = _ "dword cbSize;" & _ "dword mask;" & _ "ptr pszHeader;" & _ "int cchHeader;" & _ "int iGroupId;" & _ "dword stateMask;" & _ "dword state;" & _ "uint uAlign;" & _ "int cItems;" & _ "int iFirstItem" Local $t = DllStructCreate($tag) DllStructSetData($t, "cbSize", DllStructGetSize($t)) ; IMPORTANT: request iFirstItem DllStructSetData($t, "mask", $LVGF_ITEMS) _SendMessage($hLV, $LVM_GETGROUPINFO, $iGroupID, DllStructGetPtr($t)) Return DllStructGetData($t, "iFirstItem") EndFunc ;==>_GetGroupFirstItem I get: Quote > iGroupID = 101 $iFirstItem = 0 - $iNextItem = 1 - $iNextItem = 2 - $iNextItem = 3 - $iNextItem = 4 - $iNextItem = 5 - $iNextItem = -1 > iGroupID = 202 $iFirstItem = 0 - $iNextItem = 1 - $iNextItem = 2 - $iNextItem = 3 - $iNextItem = 4 - $iNextItem = 5 - $iNextItem = -1 but it should gives: Quote > iGroupID = 101 $iFirstItem = 0 - $iNextItem = 1 - $iNextItem = -1 > iGroupID = 202 $iFirstItem = 2 - $iNextItem = 3 - $iNextItem = 4 - $iNextItem = 5 - $iNextItem = -1 any concept why _GetGroupFirstItem() nad _GetGroupNextItem() both doesn't work well ? Signature beginning:* Please remember: "AutoIt"..... * Wondering who uses AutoIt and what it can be used for ? * Forum Rules ** ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Code * for other useful stuff click the following button: Spoiler Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST API * ErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 * My contribution to others projects or UDF based on others projects: * _sql.au3 UDF * POP3.au3 UDF * RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF * SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane * Useful links: * Forum Rules * Forum etiquette * Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * Wiki: * Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX IE Related: * How to use IE.au3 UDF with AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskScheduler * IE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related: * How to get reference to PDF object embeded in IE * IE on Windows 11 * I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions * EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *I also encourage you to check awesome @trancexx code: * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuff * OnHungApp handler * Avoid "AutoIt Error" message box in unknown errors * HTML editor * winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/ "Homo sum; humani nil a me alienum puto" - Publius Terentius Afer"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming" , be and \\//_. Anticipating Errors : "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty." Signature last update: 2023-04-24
mLipok Posted 15 hours ago Author Posted 15 hours ago Thanks to @Nine code from here: ListView + ImageList for GroupHeader ( LVSIL_GROUPHEADER ) here is my modified code: expandcollapse popup;~ https://www.autoitscript.com/forum/topic/213683-listview-imagelist-for-groupheader-lvsil_groupheader ; From Nine (base code of mLipok) #include <GUIConstantsEx.au3> #include <GuiListView.au3> #include <GuiImageList.au3> ;~ Global Const $LVNI_SAMEGROUPONLY = 0x0080 ;~ Global Const $LVSIL_GROUPHEADER = 3 Global Const $tagLVGROUPEx = _ "uint cbSize;" & _ "uint mask;" & _ "ptr pszHeader;" & _ "int cchHeader;" & _ "ptr pszFooter;" & _ "int cchFooter;" & _ "int iGroupId;" & _ "uint stateMask;" & _ "uint state;" & _ "uint uAlign;" & _ "ptr pszSubtitle;" & _ "uint cchSubtitle;" & _ "ptr pszTask;" & _ "uint cchTask;" & _ "ptr pszDescriptionTop;" & _ "uint cchDescriptionTop;" & _ "ptr pszDescriptionBottom;" & _ "uint cchDescriptionBottom;" & _ "int iTitleImage;" & _ "int iExtendedImage;" & _ "int iFirstItem;" & _ "uint cItems;" & _ "ptr pszSubsetTitle;" & _ "uint cchSubsetTitle" Global $tInfo = DllStructCreate("dword cbSize;dword dwMajorVersion;dword dwMinorVersion;dword dwBuildNumber;dword dwPlatformID;dword dwFlags;uint64 ullVersion;") $tInfo.cbSize = DllStructGetSize($tInfo) DllCall("ComCtl32.dll", "long", "DllGetVersion", "struct*", $tInfo) If $tInfo.dwMajorVersion < 6 Then Exit ConsoleWrite("You need version 6 or higher" & @CRLF) Example() Func Example() Local $hGUI = GUICreate("GroupHeaderImageList", 500, 300) #forceref $hGUI Local $idListView = GUICtrlCreateListView("Name|Value", 10, 10, 480, 250) Local $hListView = GUICtrlGetHandle($idListView) _GUICtrlListView_EnableGroupView($hListView) _GUICtrlListView_InsertGroup($hListView, -1, 101, 'Group A') Local $iItem0 = _GUICtrlListView_AddItem($hListView, "Item 0") _GUICtrlListView_AddSubItem($hListView, $iItem0, "123", 1) _GUICtrlListView_SetItemGroupID($hListView, $iItem0, 101) Local $iItem1 = _GUICtrlListView_AddItem($hListView, "Item 1") _GUICtrlListView_AddSubItem($hListView, $iItem1, "234", 1) _GUICtrlListView_SetItemGroupID($hListView, $iItem1, 101) #Region ; Nine code Local $hImageList = _GUIImageList_Create(16, 16, 5, 3) _GUIImageList_AddIcon($hImageList, @SystemDir & "\shell32.dll", 110) _SendMessage($hListView, $LVM_SETIMAGELIST, $LVSIL_GROUPHEADER, $hImageList) Local $sHeader = "Group B" Local $tText = DllStructCreate("wchar[" & StringLen($sHeader) + 1 & "]") DllStructSetData($tText, 1, $sHeader) Local $tGroup_template = DllStructCreate($tagLVGROUPEx) Local $tGroup = $tGroup_template $tGroup.cbSize = DllStructGetSize($tGroup) $tGroup.mask = BitOR($LVGF_HEADER, $LVGF_GROUPID, $LVGF_TITLEIMAGE) $tGroup.pszHeader = DllStructGetPtr($tText) $tGroup.cchHeader = StringLen($sHeader) $tGroup.iGroupId = 102 $tGroup.iTitleImage = 0 _SendMessage($hListView, $LVM_INSERTGROUP, -1, DllStructGetPtr($tGroup)) Local $iItem2 = _GUICtrlListView_AddItem($hListView, "Item 2") _GUICtrlListView_AddSubItem($hListView, $iItem2, "456", 1) _GUICtrlListView_SetItemGroupID($hListView, $iItem2, 102) ConsoleWrite("- $iItem2=" & $iItem2 & @CRLF) Local $iItem3 = _GUICtrlListView_AddItem($hListView, "Item 3") _GUICtrlListView_AddSubItem($hListView, $iItem3, "567", 1) _GUICtrlListView_SetItemGroupID($hListView, $iItem3, 102) ConsoleWrite("- $iItem3=" & $iItem3 & @CRLF) Local $iItem4 = _GUICtrlListView_AddItem($hListView, "Item 4") _GUICtrlListView_AddSubItem($hListView, $iItem4, "678", 1) _GUICtrlListView_SetItemGroupID($hListView, $iItem4, 102) ConsoleWrite("- $iItem4=" & $iItem4 & @CRLF) #EndRegion ; Nine code _GUICtrlListView_InsertGroup($hListView, -1, 103, 'Group C') Local $iItem5 = _GUICtrlListView_AddItem($hListView, "Item 5") _GUICtrlListView_AddSubItem($hListView, $iItem5, "9a", 1) _GUICtrlListView_SetItemGroupID($hListView, $iItem5, 103) Local $iItem6 = _GUICtrlListView_AddItem($hListView, "Item 6") _GUICtrlListView_AddSubItem($hListView, $iItem6, "9b", 1) _GUICtrlListView_SetItemGroupID($hListView, $iItem6, 103) ConsoleWrite("_GetGroupFirstItem() = " & _GetGroupFirstItem($hListView, 102) & @CRLF) ConsoleWrite("_GetGroupItemsCount() = " & _GetGroupItemsCount($hListView, 102) & @CRLF) _GetGroupAllItems($hListView, 102) GUISetState() While GUIGetMsg() <> $GUI_EVENT_CLOSE WEnd EndFunc ;==>Example Func _GetGroupAllItems($hListView, $iGroupID) Local $iFirstItem = _GetGroupFirstItem($hListView, $iGroupID) ConsoleWrite("+ $iFirstItem=" & $iFirstItem & @CRLF) ;~ For $IDX = $iFirstItem To $iFirstItem Local $iCheckItem = $iFirstItem, $iNextItem While 1 $iNextItem = _GetGroupNextItem($hListView, $iCheckItem) ;~ $iNextItem = _GUICtrlListView_GetNextItem_mod($hListView, $iCheckItem, 2, 16) ConsoleWrite("+ $iNextItem=" & $iNextItem & @CRLF) If $iNextItem = -1 Then ExitLoop $iCheckItem = $iNextItem Sleep(10) WEnd EndFunc ;==>_GetGroupAllItems Func _GetGroupNextItem($hListView, $iItemIndex) Local $iGroup = _GUICtrlListView_GetGroupIndexByItemIndex($hListView, $iItemIndex, $iGroup) ; https://learn.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-lvitemindex Local Const $tagLVITEMINDEX = "int iItem;int iGroup" Local $tIndex = DllStructCreate($tagLVITEMINDEX) $tIndex.iItem = $iItemIndex $tIndex.iGroup = $iGroup ConsoleWrite("- $iGroup=" & $iGroup & @CRLF) _SendMessage( _ $hListView, _ $LVM_GETNEXTITEMINDEX, _ DllStructGetPtr($tIndex), _ $LVNI_SAMEGROUPONLY) Return $tIndex.iItem EndFunc ;==>_GetGroupNextItem Func _GetGroupFirstItem($hListView, $iGroupID) Local $t = DllStructCreate($tagLVGROUPEx) $t.cbSize = DllStructGetSize($t) ; IMPORTANT: request iFirstItem $t.mask = $LVGF_ITEMS _SendMessage($hListView, $LVM_GETGROUPINFO, $iGroupID, DllStructGetPtr($t)) Return $t.iFirstItem EndFunc ;==>_GetGroupFirstItem Func _GetGroupItemsCount($hListView, $iGroupID) Local $t = DllStructCreate($tagLVGROUPEx) $t.cbSize = DllStructGetSize($t) ; IMPORTANT: request BOTH fields $t.mask = $LVGF_ITEMS _SendMessage($hListView, $LVM_GETGROUPINFO, $iGroupID, DllStructGetPtr($t)) Return $t.cItems EndFunc ;==>_GetGroupItemsCount Func _GUICtrlListView_GetNextItem_mod($hWnd, $iStart = -1, $iSearch = 0, $iState = 8) Local $aSearch[5] = [$LVNI_ALL, $LVNI_ABOVE, $LVNI_BELOW, $LVNI_TOLEFT, $LVNI_TORIGHT] Local $iFlags = $aSearch[$iSearch] If BitAND($iState, 1) <> 0 Then $iFlags = BitOR($iFlags, $LVNI_CUT) If BitAND($iState, 2) <> 0 Then $iFlags = BitOR($iFlags, $LVNI_DROPHILITED) If BitAND($iState, 4) <> 0 Then $iFlags = BitOR($iFlags, $LVNI_FOCUSED) If BitAND($iState, 8) <> 0 Then $iFlags = BitOR($iFlags, $LVNI_SELECTED) If BitAND($iState, 16) <> 0 Then $iFlags = BitOR($iFlags, $LVNI_SAMEGROUPONLY) If IsHWnd($hWnd) Then Return _SendMessage($hWnd, $LVM_GETNEXTITEM, $iStart, $iFlags) Else Return GUICtrlSendMsg($hWnd, $LVM_GETNEXTITEM, $iStart, $iFlags) EndIf EndFunc ;==>_GUICtrlListView_GetNextItem_mod Func _GUICtrlListView_GetGroupIndexByItemIndex($hWnd, $iItem) ;https://www.autoitscript.com/forum/topic/213679-listview-get-igroupid-and-igroup-for-listviewitem/#findComment-1552392 Local $iGroupID = _GUICtrlListView_GetItemGroupID($hWnd, $iItem) Return _GUICtrlListView_GetGroupIndexByGroupID($hWnd, $iGroupID) EndFunc ;==>_GUICtrlListView_GetGroupIndexByItemIndex Func _GUICtrlListView_GetGroupIndexByGroupID($hWnd, $iGroupID) ;https://www.autoitscript.com/forum/topic/213679-listview-get-igroupid-and-igroup-for-listviewitem/#findComment-1552392 Local $iMaxIndex = _GUICtrlListView_GetGroupCount($hWnd) - 1 Local $aInfo For $i = 0 To $iMaxIndex $aInfo = _GUICtrlListView_GetGroupInfoByIndex($hWnd, $i) If $aInfo[2] = $iGroupID Then Return $i Next Return SetError(1, 0, -1) EndFunc ;==>_GUICtrlListView_GetGroupIndexByGroupID This both function works: _GetGroupItemsCount() and _GetGroupFirstItem() but I still have problems with: Func _GetGroupNextItem($hListView, $iItemIndex) Local $iGroup = _GUICtrlListView_GetGroupIndexByItemIndex($hListView, $iItemIndex, $iGroup) ; https://learn.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-lvitemindex Local Const $tagLVITEMINDEX = "int iItem;int iGroup" Local $tIndex = DllStructCreate($tagLVITEMINDEX) $tIndex.iItem = $iItemIndex $tIndex.iGroup = $iGroup ConsoleWrite("- $iGroup=" & $iGroup & @CRLF) _SendMessage( _ $hListView, _ $LVM_GETNEXTITEMINDEX, _ DllStructGetPtr($tIndex), _ $LVNI_SAMEGROUPONLY) Return $tIndex.iItem EndFunc ;==>_GetGroupNextItem Signature beginning:* Please remember: "AutoIt"..... * Wondering who uses AutoIt and what it can be used for ? * Forum Rules ** ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Code * for other useful stuff click the following button: Spoiler Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST API * ErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 * My contribution to others projects or UDF based on others projects: * _sql.au3 UDF * POP3.au3 UDF * RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF * SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane * Useful links: * Forum Rules * Forum etiquette * Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * Wiki: * Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX IE Related: * How to use IE.au3 UDF with AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskScheduler * IE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related: * How to get reference to PDF object embeded in IE * IE on Windows 11 * I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions * EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *I also encourage you to check awesome @trancexx code: * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuff * OnHungApp handler * Avoid "AutoIt Error" message box in unknown errors * HTML editor * winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/ "Homo sum; humani nil a me alienum puto" - Publius Terentius Afer"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming" , be and \\//_. Anticipating Errors : "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty." Signature last update: 2023-04-24
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now