WildByDesign Posted October 28 Posted October 28 I am working on a WM_NOTIFY custom draw for ListViews that specifically only targets group headers ($LVCDI_GROUP) for dark theme. I have learned (the hard way) just how busy custom draw handling can get for a ListView control. So I have had to do as much as possible to Return early and also implement some caching mechanisms. But, as always, I am lousy when it comes to Maps. I have a caching map set up but it only works for a single ListView control. And since this will be going into GUIDarkTheme UDF, from the perspective of a UDF, there could be multiple ListView controls that I need to support. Could someone please help me get a Map cache going for multiple ListView controls? Thank you. Here is what the initial Map check looks like: Local $aData If MapExists($mGroupInfo, $iGroupID) Then ; Window found in Map -> get $aData $aData = $mGroupInfo[$iGroupID] $sText = $aData[0] $iAlign = $aData[1] $iGroupID = $aData[2] ;ConsoleWrite("$sText (from cache): " & $sText & @CRLF) ;ConsoleWrite("$iAlign (from cache): " & $iAlign & @CRLF) ;ConsoleWrite("$iGroupID (from cache): " & $iGroupID & @CRLF) Else ; Window not found in Map -> AUTOMATIC FIRST TIME INITIALIZATION Dim $aData[4] $aData[0] = 0 ; placeholder for $sText $aData[1] = 0 ; placeholder for $iAlign $aData[2] = 0 ; placeholder for $iGroupID EndIf On first run, it goes through the following code to collect the information needed to cache: Local $iGroupCount = _GUICtrlListView_GetGroupCount($hWndFrom) Local $aGroup If $bFirstRun And $iGroupCount > 0 Then For $i = 0 To $iGroupCount - 1 $aGroup = _GUICtrlListView_GetGroupInfoByIndex($hWndFrom, $i) $aData[0] = $aGroup[0] ; Text $aData[1] = $aGroup[1] ; Alignment $aData[2] = $aGroup[2] ; GroupID $mGroupInfo[$aGroup[2]] = $aData ; add $aData back to map Next $bFirstRun = False EndIf And here is the full working script: expandcollapse popup#include <WindowsConstants.au3> #include <ColorConstants.au3> #include <GUIConstants.au3> #include <GuiListView.au3> #include <WinAPI.au3> #include <WinAPITheme.au3> Global Const $DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2 = Ptr(-4) DllCall("User32.dll", "bool", "SetProcessDpiAwarenessContext", "int_ptr", $DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2) Global Const $ETO_CLIPPED = 0x0004 Global $__DM_g_hDefaultFont = 0 Global $__DM_g_iDpiRatio = 1 Global $g_hMDL2Font = _WinAPI_CreateFont(12, 0, 0, 0, $FW_NORMAL, False, False, False, $DEFAULT_CHARSET, $OUT_DEFAULT_PRECIS, $CLIP_DEFAULT_PRECIS, $DEFAULT_QUALITY, $DEFAULT_PITCH, "Segoe MDL2 Assets") Global $__DM_g_iCtrlBkColor = 0x383838 Global $__DM_g_hPenBtnBor = _WinAPI_CreatePen($PS_SOLID, 1, _WinAPI_SwitchColor(0x5D5D5D)) OnAutoItExitRegister("_CleanUp") Example() Func Example() ; Get DPI ratio from hidden AutoIt window before GUICreate $__DM_g_iDpiRatio = Round(__DM_WinAPI_GetDPIForWindow(_GetHwndFromPID(@AutoItPID)) / 96, 2) If @error Then $__DM_g_iDpiRatio = 1 Local $hGUI = GUICreate("ListView Group Header CustomDraw", 370 * $__DM_g_iDpiRatio, 240 * $__DM_g_iDpiRatio) GUISetBkColor(0x202020) ;GUISetFont(12) $__DM_g_hDefaultFont = _PM_GetDefaultFont($__DM_g_iDpiRatio * 96) Local $iStyle = BitOR($GUI_SS_DEFAULT_LISTVIEW, $LVS_NOCOLUMNHEADER) Local $iExStyle = BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_DOUBLEBUFFER, $LVS_EX_CHECKBOXES) Local $idListview = GUICtrlCreateListView("", 10 * $__DM_g_iDpiRatio, 10 * $__DM_g_iDpiRatio, 350 * $__DM_g_iDpiRatio, 220 * $__DM_g_iDpiRatio, $iStyle, $iExStyle) GUICtrlSetBkColor(-1, 0x383838) GUICtrlSetColor(-1, 0xFFFFFF) _GUICtrlListView_AddColumn($idListview, "Column 1", 300) _GUICtrlListView_AddItem($idListview, "custom-userProfileMinimal", 0) _GUICtrlListView_AddItem($idListview, "custom-volumeRootMinimal", 1) _GUICtrlListView_AddItem($idListview, "lpacAppExperience", 2) _GUICtrlListView_AddItem($idListview, "lpacWebPlatform", 3) _GUICtrlListView_AddItem($idListview, "registryRead", 4) _GUICtrlListView_AddItem($idListview, "runFullTrust", 5) _GUICtrlListView_EnableGroupView($idListview, True) _GUICtrlListView_InsertGroup($idListview, -1, 1, "Group 1") _GUICtrlListView_InsertGroup($idListview, -1, 2, "Group 2") _GUICtrlListView_InsertGroup($idListview, -1, 3, "Group 3") _GUICtrlListView_SetItemGroupID($idListview, 0, 1) _GUICtrlListView_SetItemGroupID($idListview, 1, 1) _GUICtrlListView_SetItemGroupID($idListview, 2, 2) _GUICtrlListView_SetItemGroupID($idListview, 3, 2) _GUICtrlListView_SetItemGroupID($idListview, 4, 3) _GUICtrlListView_SetItemGroupID($idListview, 5, 3) _GUICtrlListView_SetColumnWidth($idListview, 0, $LVSCW_AUTOSIZE_USEHEADER) _GUICtrlListView_SetGroupInfo($idListview, 1, "Custom Capabilities", 0, BitOR($LVGS_COLLAPSED, $LVGS_COLLAPSIBLE)) _GUICtrlListView_SetGroupInfo($idListview, 2, "LPAC Capabilities", 0, BitOR($LVGS_COLLAPSED, $LVGS_COLLAPSIBLE)) _GUICtrlListView_SetGroupInfo($idListview, 3, "Common Capabilities", 0, BitOR($LVGS_COLLAPSED, $LVGS_COLLAPSIBLE)) _WinAPI_SetWindowTheme(GUICtrlGetHandle($idListview), "DarkMode_Explorer") _SendMessage(GUICtrlGetHandle($idListview), $WM_CHANGEUISTATE, 65537, 0) _WinAPI_DwmSetWindowAttribute($hGUI, $DWMWA_USE_IMMERSIVE_DARK_MODE, True) GUIRegisterMsg($WM_NOTIFY, WM_NOTIFY) GUISetState(@SW_SHOW) While True Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd EndFunc ;==>Example Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam Local $tNMHDR = DllStructCreate($tagNMHDR, $lParam) Local $hWndFrom = DllStructGetData($tNMHDR, "hWndFrom") Local $iCode = DllStructGetData($tNMHDR, "Code") If _WinAPI_GetClassName($hWndFrom) = "SysListView32" And $iCode = $NM_CUSTOMDRAW Then Local $tCustomDraw = DllStructCreate($tagNMLVCUSTOMDRAW, $lParam) Local $hDC, $tHeader, $iGroupID, $iState, $bIsCollapsible, $iMiddle, $iLabelW Local $iChevron Local Static $mGroupCache[] ; for handling caching of LVGS_COLLAPSIBLE check (likely merge with $mGroupInfo later) Local Static $mGroupInfo[] Local Static $bFirstRun = True If $tCustomDraw.dwDrawStage <> $CDDS_POSTPAINT Then Return $CDRF_DODEFAULT If $tCustomDraw.dwItemType <> $LVCDI_GROUP Then Return $CDRF_DODEFAULT $hDC = $tCustomDraw.hDC $iGroupID = $tCustomDraw.dwItemSpec ;$iState = _GetListViewGroupState($hWndFrom, $iGroupID) $bIsCollapsible = _IsGroupCollapsible_Cached($hWndFrom, $iGroupId, $mGroupCache) $iChevron = Round((16 * $__DM_g_iDpiRatio) + (16 / $__DM_g_iDpiRatio)) ; rcText provides the exact rectangle coordinates needed for LVGGR_HEADER $tHeader = DllStructCreate($tagRECT, DllStructGetPtr($tCustomDraw, "TextLeft")) Local $iTextLeft = $tCustomDraw.TextLeft Local $iTextTop = $tCustomDraw.TextTop Local $iTextRight = $tCustomDraw.TextRight Local $iTextBottom = $tCustomDraw.TextBottom ; Get the ListView's current client area dimensions Local $aClientSize = WinGetClientSize($hWndFrom) Local $iClientWidth = $aClientSize[0] Local $iClientHeight = $aClientSize[1] ; Extract coordinates from your group header rect Local $iTop = $tHeader.Top Local $iBottom = $tHeader.Bottom If $iBottom <= 0 Or $iTop >= $iClientHeight Then ; It is 100% off-screen (either fully above or fully below) Return $CDRF_DODEFAULT EndIf Local $aData If MapExists($mGroupInfo, $iGroupID) Then ; Window found in Map -> get $aData $aData = $mGroupInfo[$iGroupID] $sText = $aData[0] $iAlign = $aData[1] $iGroupID = $aData[2] ;ConsoleWrite("$sText (from cache): " & $sText & @CRLF) ;ConsoleWrite("$iAlign (from cache): " & $iAlign & @CRLF) ;ConsoleWrite("$iGroupID (from cache): " & $iGroupID & @CRLF) Else ; Window not found in Map -> AUTOMATIC FIRST TIME INITIALIZATION Dim $aData[4] $aData[0] = 0 ; placeholder for $sText $aData[1] = 0 ; placeholder for $iAlign $aData[2] = 0 ; placeholder for $iGroupID EndIf Local $iGroupCount = _GUICtrlListView_GetGroupCount($hWndFrom) Local $aGroup If $bFirstRun And $iGroupCount > 0 Then For $i = 0 To $iGroupCount - 1 $aGroup = _GUICtrlListView_GetGroupInfoByIndex($hWndFrom, $i) $aData[0] = $aGroup[0] ; Text $aData[1] = $aGroup[1] ; Alignment $aData[2] = $aGroup[2] ; GroupID $mGroupInfo[$aGroup[2]] = $aData ; add $aData back to map Next $bFirstRun = False EndIf $iGroupID = $tCustomDraw.dwItemSpec ; Get group header label rect Local Static $tLabelRect = DllStructCreate($tagRECT) DllStructSetData($tLabelRect, "Top", $LVGGR_LABEL) _SendMessage($hWndFrom, $LVM_GETGROUPRECT, $iGroupID, DllStructGetPtr($tLabelRect)) ; Group header label width $iLabelW = $tLabelRect.right - $tLabelRect.left Local $aGroupInfo = _GUICtrlListView_GetGroupInfo($hWndFrom, $iGroupID) Local $sText = $aGroupInfo[0] ; Switch any non-left aligned header label to left aligned (unable to support center or right align) ;If $aGroupInfo[1] <> 0 Then _GUICtrlListView_SetGroupInfo($hWndFrom, $iGroupID, $sText, 0, $iState) If $bIsCollapsible Then $tHeader.right = $tHeader.right - $iChevron $iMiddle = ($tHeader.bottom - $tHeader.top) / 2 Local $hOldFont = _WinAPI_SelectObject($hDC, $__DM_g_hDefaultFont) Local $tSIZE = _WinAPI_GetTextExtentPoint32($hDC, $sText) $iLabelW = $tSIZE.X _WinAPI_SetBkMode($hDC, $TRANSPARENT) _WinAPI_SetTextColor($hDC, 0xFFFFFF) Local $iOptions = $ETO_CLIPPED Local $iLeftTextOut = DllStructGetData($tLabelRect, "Left") Local $iTopTextOut = DllStructGetData($tLabelRect, "Top") _WinAPI_ExtTextOut($hDC, $iLeftTextOut + 1, $iTopTextOut, $iOptions, $sText, DllStructGetPtr($tLabelRect)) _WinAPI_SelectObject($hDC, $hOldFont) Local $hOldPen = _WinAPI_SelectObject($hDC, $__DM_g_hPenBtnBor) _WinAPI_DrawLine($hDC, $tHeader.left + $iLabelW + 16, $tHeader.top + $iMiddle, $tHeader.right - ($bIsCollapsible ? 0: 10), $tHeader.top + $iMiddle) _WinAPI_SelectObject($hDC, $hOldPen) Return $CDRF_SKIPDEFAULT EndIf Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY Func _GetListViewGroupState($hWndListView, $iGroupID) Local $tagLVGROUP = "uint cbSize;uint mask;ptr pszHeader;int cchHeader;ptr pszFooter;int cchFooter;int iGroupId;uint stateMask;uint state;uint uAlign;" Local $tGroup = DllStructCreate($tagLVGROUP) $tGroup.cbSize = DllStructGetSize($tGroup) $tGroup.mask = $LVGF_STATE $tGroup.iGroupId = $iGroupID $tGroup.stateMask = 0xFFFFFFFF ; Request all states ; Send the message (this populates $tGroup in memory) Local $iResult = _SendMessage($hWndListView, $LVM_GETGROUPINFO, $iGroupID, DllStructGetPtr($tGroup)) If $iResult <> -1 Then ; Read the state member from the structure, NOT the return of _SendMessage Return $tGroup.state EndIf Return -1 EndFunc ;==>_GetListViewGroupState Func _CleanUp() _WinAPI_DeleteObject($__DM_g_hPenBtnBor) _WinAPI_DeleteObject($g_hMDL2Font) If $__DM_g_hDefaultFont Then _WinAPI_DeleteObject($__DM_g_hDefaultFont) EndFunc ;==>_CleanUp ;Function for getting HWND from PID Func _GetHwndFromPID($PID) $hWnd = 0 $winlist = WinList() Do For $i = 1 To $winlist[0][0] If $winlist[$i][0] <> "" Then $iPID2 = WinGetProcess($winlist[$i][1]) If $iPID2 = $PID Then $hWnd = $winlist[$i][1] ExitLoop EndIf EndIf Next Until $hWnd <> 0 Return $hWnd EndFunc ;==>_GetHwndFromPID Func _IsGroupCollapsible_Cached($hWnd, $iGroupId, ByRef $mCache) If MapExists($mCache, $iGroupId) Then Return $mCache[$iGroupId] EndIf Local Static $tGroup = DllStructCreate( _ "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 cItems;" & _ "ptr pszSubsetTitle;" & _ "uint cchSubsetTitle" _ ) Local Static $pGroup = DllStructGetPtr($tGroup) ; Clear structure to avoid dirty data DllStructSetData($tGroup, 1, DllStructGetSize($tGroup)) DllStructSetData($tGroup, 2, $LVGF_STATE) DllStructSetData($tGroup, 7, $iGroupId) DllStructSetData($tGroup, 8, $LVGS_COLLAPSIBLE) ; Send message Local $aResult = DllCall("user32.dll", "lresult", "SendMessageW", _ "hwnd", $hWnd, _ "uint", 0x1000 + 149, _ ; $LVM_GETGROUPINFO "wparam", $iGroupId, _ "ptr", $pGroup) Local $bIsCollapsible = False If Not @error And $aResult[0] <> -1 Then ; Field index 9 corresponds to 'state' in our layout Local $iState = DllStructGetData($tGroup, 9) $bIsCollapsible = (BitAND($iState, $LVGS_COLLAPSIBLE) <> 0) EndIf $mCache[$iGroupId] = $bIsCollapsible Return $bIsCollapsible EndFunc ; #FUNCTION# ==================================================================================================================== ; Name ..........: _PM_GetDefaultFont ; Description ...: Creates a DPI-scaled font that is identical to the default system font used for dialogs. ; Author ........: WildByDesign ; =============================================================================================================================== Func _PM_GetDefaultFont($iDPI) Local $hFont = __PM_GetNCMFont("lfMessageFont", $iDPI) Return $hFont EndFunc ;==>_PM_GetDefaultFont ; #FUNCTION# ==================================================================================================================== ; Name ..........: __PM_GetNCMFont ; Description ...: Internal helper function for _PM_GetMenuFont and _PM_GetDefaultFont. ; Author ........: WildByDesign ; =============================================================================================================================== Func __PM_GetNCMFont($sFontNCM, $iDPI) Local Const $SPI_GETNONCLIENTMETRICS = 0x0029 Local $tNCM = DllStructCreate("uint cbSize;int iBorderWidth;int iScrollWidth;int iScrollHeight;" & _ "int iCaptionWidth;int iCaptionHeight;byte lfCaptionFont[92];" & _ "int iSmCaptionWidth;int iSmCaptionHeight;byte lfSmCaptionFont[92];" & _ "int iMenuWidth;int iMenuHeight;byte lfMenuFont[92];" & _ "byte lfStatusFont[92];byte lfMessageFont[92];int iPaddedBorderWidth") DllStructSetData($tNCM, "cbSize", DllStructGetSize($tNCM)) Local $aResult = DllCall("user32.dll", "bool", "SystemParametersInfoForDpi", _ "uint", $SPI_GETNONCLIENTMETRICS, _ "uint", DllStructGetSize($tNCM), _ "ptr", DllStructGetPtr($tNCM), _ "uint", 0, _ "uint", $iDPI) If @error Or Not $aResult[0] Then $aResult = DllCall("user32.dll", "bool", "SystemParametersInfo", _ "uint", $SPI_GETNONCLIENTMETRICS, _ "uint", DllStructGetSize($tNCM), _ "ptr", DllStructGetPtr($tNCM), _ "uint", 0) EndIf ; Obtain LOGFONT structure for default dialog font Local $tLOGFONT = DllStructCreate("long lfHeight;long lfWidth;long lfEscapement;long lfOrientation;" & _ "long lfWeight;byte lfItalic;byte lfUnderline;byte lfStrikeOut;byte lfCharSet;" & _ "byte lfOutPrecision;byte lfClipPrecision;byte lfQuality;byte lfPitchAndFamily;" & _ "wchar lfFaceName[32]", DllStructGetPtr($tNCM, $sFontNCM)) ; Obtain font handle for default font Local $hFont = _WinAPI_CreateFontIndirect($tLOGFONT) Return $hFont EndFunc ;==>__PM_GetNCMFont ; #FUNCTION# ==================================================================================================================== ; Author.........: WildByDesign ; =============================================================================================================================== Func _WinAPI_ExtTextOut($hDC, $iX, $iY, $iOptions, $sText, $tRect = 0) Local $iLength = StringLen($sText) ; Pointer to the RECT structure, or NULL if no RECT is passed Local $pRECT = 0 If IsDllStruct($tRect) Then $pRECT = DllStructGetPtr($tRect) Local $aResult = DllCall("gdi32.dll", "bool", "ExtTextOutW", _ "handle", $hDC, _ "int", $iX, _ "int", $iY, _ "uint", $iOptions, _ "ptr", $pRECT, _ "wstr", $sText, _ "uint", $iLength, _ "ptr", 0) ; lpDx array is omitted (NULL) If @error Or Not $aResult[0] Then Return SetError(1, 0, False) Return True EndFunc ;==>_WinAPI_ExtTextOut Func __DM_WinAPI_GetDPIForWindow($hWnd) ; UEZ Local $aResult = DllCall('user32.dll', "uint", "GetDpiForWindow", "hwnd", $hWnd) ;requires Win10 v1607+ / no server support If Not IsArray($aResult) Or @error Then Return SetError(1, @extended, 0) If Not $aResult[0] Then Return SetError(2, @extended, 0) Return $aResult[0] EndFunc ;==>__DM_WinAPI_GetDPIForWindow Â
ahmet Posted October 28 Posted October 28 What about using map in a map? You can have cached map with the key "hwnd" of the list view control. That key can then have anything you need: an array, an ID or anything else. Also, why are you not subclassing controls for this?
WildByDesign Posted October 28 Author Posted October 28 37 minutes ago, ahmet said: What about using map in a map? You can have cached map with the key "hwnd" of the list view control. That key can then have anything you need: an array, an ID or anything else. This sounds good. I just don't know how to do a map in a map. Anytime I try to visualize map functionality, it hurts my head. I have a pretty good understanding of arrays. But I am just not good with maps. 42 minutes ago, ahmet said: Also, why are you not subclassing controls for this? It looks much better when it's in GUIDarkTheme UDF. I just had to make this example smaller to share in the forum.
Solution WildByDesign Posted October 29 Author Solution Posted October 29 I ended up solving the cache issue by combining the handle and groupID together:Â $hWndFrom & "_" & $iGroupID ; Create a unique composite key for this specific ListView and Group ID Local $sCompositeKey = $hWndFrom & "_" & $iGroupID Local $aData, $aNewData, $aGroup ; Fill ListView group header info cache if not already cached If Not MapExists($mGroupInfo, $sCompositeKey) Then $aGroup = _GUICtrlListView_GetGroupInfo($hWndFrom, $iGroupID) Dim $aNewData[3] $aNewData[0] = $aGroup[0] ; Text $aNewData[1] = $aGroup[1] ; Alignment $aNewData[2] = _GetListViewGroupState($hWndFrom, $iGroupID) ; Store using the composite key: hWnd_GroupID $mGroupInfo[$hWndFrom & "_" & $iGroupID] = $aNewData EndIf ; Retrieve group data from the cache If MapExists($mGroupInfo, $sCompositeKey) Then $aData = $mGroupInfo[$sCompositeKey] $sText = $aData[0] $iAlign = $aData[1] $iState = $aData[2] EndIf Â
ioa747 Posted October 29 Posted October 29 12 hours ago, WildByDesign said: I just don't know how to do a map in a map. You’ve been around the forum long enough and mature enough as a dev that you really shouldn't be letting nested maps intimidate you at this point! 😉 Here is a quick example to help you visualize how a "map of maps" works in practice:  expandcollapse popupLocal $m[], $mMapOfMaps[] ; Add John to the $m map $m.name = "john" $m.age = 30 $m.email = "john@gmail.com" $mMapOfMaps[$m.name] = $m ; <- Add $m to the map of maps as map with the name john ; Add jim to the $m map $m.name = "jim" $m.age = 40 $m.email = "jim@gmail.com" $mMapOfMaps[$m.name] = $m ; <- Add $m to the map of maps as map with the name jim ; Access John's data ConsoleWrite("VarGetType($mMapOfMaps.john): " & VarGetType($mMapOfMaps.john) & @CRLF) ConsoleWrite("$mMapOfMaps.john.name: " & $mMapOfMaps.john.name & @CRLF) ConsoleWrite("$mMapOfMaps.john.age: " & $mMapOfMaps.john.age & @CRLF) ConsoleWrite("$mMapOfMaps.john.email: " & $mMapOfMaps.john.email & @CRLF) ConsoleWrite("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" & @CRLF) ; Access Jim's data ConsoleWrite("VarGetType($mMapOfMaps.jim): " & VarGetType($mMapOfMaps.jim) & @CRLF) ConsoleWrite("$mMapOfMaps.jim.name: " & $mMapOfMaps.jim.name & @CRLF) ConsoleWrite("$mMapOfMaps.jim.age: " & $mMapOfMaps.jim.age & @CRLF) ConsoleWrite("$mMapOfMaps.jim.email: " & $mMapOfMaps.jim.email & @CRLF) ConsoleWrite("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" & @CRLF) ; Modify John's data directly through the nested map $mMapOfMaps.john.age = 42 $mMapOfMaps.john.email = "john_new@gmail.com" ConsoleWrite("$mMapOfMaps.john.age: " & $mMapOfMaps.john.age & @CRLF) ConsoleWrite("$mMapOfMaps.john.email: " & $mMapOfMaps.john.email & @CRLF) ConsoleWrite("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" & @CRLF) ; Extract a sub-map into a local variable $m = $mMapOfMaps.jim ConsoleWrite("$m.name: " & $m.name & @CRLF) ConsoleWrite("$m.age: " & $m.age & @CRLF) ConsoleWrite("$m.email: " & $m.email & @CRLF) ConsoleWrite("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" & @CRLF) ; Add a new property to Jim's map $m.phone = "2233455788" $mMapOfMaps[$m.name] = $m ; <- return $m back to the map of maps as map with the name jim ConsoleWrite("$mMapOfMaps.jim.phone: " & $mMapOfMaps.jim.phone & @CRLF)  WildByDesign and argumentum 2 I know that I know nothing
WildByDesign Posted October 29 Author Posted October 29 1 hour ago, ioa747 said: You’ve been around the forum long enough and mature enough as a dev that you really shouldn't be letting nested maps intimidate you at this point! 😉 You make a very good, legitimate point. And it gave me a good laugh when I read this. 😆 And I think you are right about me letting nested maps intimidate me. I remember being intimidated by 2D arrays when I first started with AutoIt and I was very apprehensive about them. But now I fully understand them and use them quite often. 1 hour ago, ioa747 said: Here is a quick example to help you visualize how a "map of maps" works in practice: Thank you. This is a fantastic example to help visualize how the data is stored. It also shows off just how flexible maps are. I'm going to use this and practice some more with maps over the next few days. There's some recent functions added to the forum in recent months, one from gianni if I recall, that shows maps in TreeView as well which is great for visualizing. As far as my quest to use custom draw for the ListView group header only, I am probably going to have to scrap the idea and remove the functionality added to the most recent GUIDarkTheme UDF release. It works great and looks great with an example of about a dozen items. But when I tried to use it in a project of mine with about 325 items, it would randomly crash. I even made a lighter version and it still crashed after a while. The problem with ListView controls in AutoIt is that anytime you hover the cursor or scroll the control, it sends a NM_CUSTOMDRAW notification for every single item in the ListView. It's getting absolutely hammered with requests with 325 items. So I could not even imagine having 1,000 or more items. Basically, it is constantly rendering all items, even items that are not visible within the range of the viewport. Even a subclass with early returns and caching mechanisms can't keep up with thousands of notifications per second when scrolling a ListView. There are virtual ListViews which handle only the data visible within the viewport and therefore much more efficient. However, they don't support groups. ioa747 1
ahmet Posted October 29 Posted October 29 Can you share your entire code with the list view that has 325 items? What happens if you use normal (non group) view?
WildByDesign Posted October 29 Author Posted October 29 34 minutes ago, ahmet said: Can you share your entire code with the list view that has 325 items? What happens if you use normal (non group) view? Yes I can share it. It's a work-in-progress still. The GUI script to run is LaunchAppContainer.au3. The code related to the custom drawing of the group headers for the ListView is in the __GUIDarkTheme_WM_NOTIFY function of GUIDarkTheme.au3 in Case "SysListView32" around line 1743. Usually what triggers the crash for me is when I scroll down and expand the "Other" group, then start scrolling up/down near the top of the ListView where the groups are. Some times it crashes in 10-15 seconds and sometimes it could be minutes. It's quite random. Thank you. LaunchAppContainer.7z
WildByDesign Posted October 29 Author Posted October 29 (edited) 41 minutes ago, ahmet said: What happens if you use normal (non group) view? Sorry, I missed this question. I will test right now with non-group mode and edit this comment. EDIT: No, it does not seem to crash when I turn group mode off. Edited October 29 by WildByDesign
WildByDesign Posted October 31 Author Posted October 31 I ended up finding a better, native solution to this group header issue. It turns out that the DarkMode_Explorer theme does not support dark mode group headers. The newer DarkMode_DarkTheme does support dark group headers but that is only on Windows 11 24H2 and newer builds. However, DarkMode_ItemsView does all of the same dark theming that DarkMode_Explorer does but it also does dark themed group headers. So I'm going to switch to that in the next GUIDarkTheme UDF release. And some other nice surprises... ahmet 1
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