WildByDesign Posted December 29, 2025 Posted December 29, 2025 I've seen many ListView header subclassing examples in the forum that use CUSTOMDRAW to change colors with SetTextColor and SetBkColor. But I'm wondering, is it technically possible to color the background of LV header items with _WinAPI_CreateSolidBrush and _WinAPI_FillRect while setting the background mix mode with _WinAPI_SetBkMode to transparent? This would, of course, require the text color to be changed with _WinAPI_SetTextColor and drawn with _WinAPI_DrawText. I'm just not even sure if this is possible with CUSTOMDRAW because I simply don't have much experience with it. My biggest problem and misunderstanding is that I don't know how to get the rectangle sizes to start with to even test whether or not the FillRect will work. I will share an example that @UEZ shared as SampleControls.au3 in Dark Mode but I have chopped it down to only what is required for ListView to keep the script as small as possible. The ListView header subclassing is done in the _SubclassProc function at line 147 in this example. As always, thank you so much for your time and help. expandcollapse popup; Coded by UEZ build 2025-12-18 beta ; not DPI aware! #include <APIConstants.au3> #include <ListViewConstants.au3> #include <WinAPIConstants.au3> #include <WinAPIGdi.au3> #include <WinAPIShellEx.au3> #include <WinAPISys.au3> #include <WinAPITheme.au3> Enum $APPMODE_FORCEDARK ; Dark Mode Colors (RGB) Global Const $COLOR_BG_DARK = 0x202020 Global Const $COLOR_TEXT_LIGHT = 0xFFFFFF Global Const $COLOR_EDIT_BG = 0x1E1E1E ; Global variables for subclassing (MUST be declared before _Example()!) Global $g_hGUI = 0, $g_ListView Global $g_aControls[50][3] = [[0, 0, 0]] ; [ControlID, hWnd, OldWndProc] Global $g_iControlCount = 0 Global $g_pSubclassProc = 0 ; Structure for NM_CUSTOMDRAW notification Global Const $tagNMCUSTOMDRAW = _ $tagNMHDR & ";" & _ ; Contains NM_CUSTOMDRAW / NMHDR header among other things "dword dwDrawStage;" & _ ; Current drawing stage (CDDS_*) "handle hdc;" & _ ; Device Context Handle "long left;long top;long right;long bottom;" & _ ; Drawing rectangle "dword_ptr dwItemSpec;" & _ ; Item index or other info (depending on the control) "uint uItemState;" & _ ; State Flags (CDIS_SELECTED, CDIS_FOCUS etc.) "lparam lItemlParam" ; lParam set by the item (e.g., via LVITEM.lParam) _Example() Func _Example() #Region GUI $g_hGUI = GUICreate("Sample GUI with Dark Mode", 400, 400) GUISetBkColor($COLOR_BG_DARK, $g_hGUI) #EndRegion GUI #Region LIST VIEW Local $idListView = GUICtrlCreateListView("Sample|ListView|", 10, 10, 380, 380, -1, BitOR($LVS_EX_DOUBLEBUFFER, $LVS_EX_FULLROWSELECT, $WS_EX_CLIENTEDGE)) _AddControlForSubclass($idListView) GUICtrlSetBkColor($idListView, $COLOR_EDIT_BG) GUICtrlSetColor($idListView, $COLOR_TEXT_LIGHT) GUICtrlSetTip(-1, '#Region LIST VIEW') GUICtrlCreateListViewItem("A|One", $idListView) GUICtrlCreateListViewItem("B|Two", $idListView) GUICtrlCreateListViewItem("C|Three", $idListView) $g_ListView = GUICtrlGetHandle($idListView) #EndRegion LIST VIEW ; Apply Dark Mode _ApplyDarkModeToAllControls() GUISetState(@SW_SHOW) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE _CleanupSubclassing() ExitLoop EndSwitch WEnd GUIDelete() EndFunc ;==>_Example Func _ColorToCOLORREF($iColor) ;RGB to BGR Local $iR = BitAND(BitShift($iColor, 16), 0xFF) Local $iG = BitAND(BitShift($iColor, 8), 0xFF) Local $iB = BitAND($iColor, 0xFF) Return BitOR(BitShift($iB, -16), BitShift($iG, -8), $iR) EndFunc ;==>_ColorToCOLORREF Func _AddControlForSubclass($iCtrlID) Local $hCtrl = GUICtrlGetHandle($iCtrlID) If $hCtrl Then $g_aControls[$g_iControlCount][0] = $iCtrlID $g_aControls[$g_iControlCount][1] = $hCtrl $g_aControls[$g_iControlCount][2] = 0 ; Placeholder for OldWndProc $g_iControlCount += 1 EndIf EndFunc ;==>_AddControlForSubclass Func _ApplyDarkModeToAllControls() ; DWM Dark Mode for the main window _WinAPI_SetPreferredAppMode($APPMODE_FORCEDARK) ; Create subclass callback If Not $g_pSubclassProc Then $g_pSubclassProc = DllCallbackRegister("_SubclassProc", "lresult", "hwnd;uint;wparam;lparam;uint_ptr;dword_ptr") ; Subclass all controls Local $hCtrl, $sClass, $hEdit, $hComboLBox, $hHeader, $hUpDown For $i = 0 To $g_iControlCount - 1 $hCtrl = $g_aControls[$i][1] If $hCtrl Then $sClass = _WinAPI_GetClassName($hCtrl) ; Use SetWindowSubclass _WinAPI_SetWindowSubclass($hCtrl, DllCallbackGetPtr($g_pSubclassProc), $i, 0) ; Special themes for different control types Switch StringLower($sClass) Case "syslistview32" _WinAPI_SetWindowTheme($hCtrl, "DarkMode_Explorer", 0) ; Also make the ListView header dark $hHeader = _SendMessage($hCtrl, $LVM_GETHEADER, 0, 0) If $hHeader Then _WinAPI_SetWindowTheme($hHeader, "DarkMode_ItemsView", 0) EndIf Case Else _WinAPI_SetWindowTheme($hCtrl, "DarkMode_Explorer", 0) EndSwitch _WinAPI_AllowDarkModeForWindow($hCtrl, True) EndIf Next ; Update theme system _WinAPI_RefreshImmersiveColorPolicyState() _WinAPI_FlushMenuThemes() _WinAPI_DwmSetWindowAttribute($g_hGUI, $DWMWA_USE_IMMERSIVE_DARK_MODE, True) ; Redraw GUI _WinAPI_RedrawWindow($g_hGUI, 0, 0, $RDW_UPDATENOW) EndFunc ;==>_ApplyDarkModeToAllControls Func _CleanupSubclassing() ; Remove all subclasses If $g_pSubclassProc Then Local $hCtrl For $i = 0 To $g_iControlCount - 1 $hCtrl = $g_aControls[$i][1] If $hCtrl Then _WinAPI_RemoveWindowSubclass($hCtrl, DllCallbackGetPtr($g_pSubclassProc), $i) EndIf Next DllCallbackFree($g_pSubclassProc) $g_pSubclassProc = 0 EndIf EndFunc ;==>_CleanupSubclassing Func _SubclassProc($hWnd, $iMsg, $wParam, $lParam, $iID, $pData) Switch $iMsg Case $WM_NOTIFY Local $tNMHDR = DllStructCreate($tagNMHDR, $lParam) Local $hFrom = $tNMHDR.hWndFrom Local $iCode = $tNMHDR.Code ; --- Adjust ListView Header text color --- If $iCode = $NM_CUSTOMDRAW Then Local $tNMCUSTOMDRAW = DllStructCreate($tagNMCUSTOMDRAW, $lParam) Local $dwDrawStage = $tNMCUSTOMDRAW.dwDrawStage Local $hDC = $tNMCUSTOMDRAW.hdc Switch $dwDrawStage Case $CDDS_PREPAINT Return $CDRF_NOTIFYITEMDRAW Case $CDDS_ITEMPREPAINT _WinAPI_SetTextColor($hDC, _ColorToCOLORREF($COLOR_TEXT_LIGHT)) ; White text _WinAPI_SetBkColor($hDC, _ColorToCOLORREF($COLOR_BG_DARK)) ; Dark background Return BitOR($CDRF_NEWFONT, $CDRF_NOTIFYPOSTPAINT) EndSwitch EndIf Case $WM_PAINT ; Custom Paint for better Dark Mode rendering Return _WinAPI_DefSubclassProc($hWnd, $iMsg, $wParam, $lParam) EndSwitch ; Forward standard message to DefSubclassProc Return _WinAPI_DefSubclassProc($hWnd, $iMsg, $wParam, $lParam) EndFunc ;==>_SubclassProc Func _WinAPI_FindWindowEx($hParent, $hAfter, $sClass, $sTitle = "") Local $ret = DllCall("user32.dll", "hwnd", "FindWindowExW", "hwnd", $hParent, "hwnd", $hAfter, "wstr", $sClass, "wstr", $sTitle) If @error Or Not IsArray($ret) Then Return 0 Return $ret[0] EndFunc ;==>_WinAPI_FindWindowEx Func _WinAPI_AllowDarkModeForWindow($hWND, $bAllow = True) Local $aResult = DllCall("UxTheme.dll", "bool", 133, "hwnd", $hWND, "bool", $bAllow) If @error Then Return SetError(1, 0, False) Return ($aResult[0] <> 0) EndFunc ;==>_WinAPI_AllowDarkModeForWindow Func _WinAPI_FlushMenuThemes() Local $aResult = DllCall("UxTheme.dll", "none", 136) If @error Then Return SetError(1, 0, False) Return True EndFunc ;==>_WinAPI_FlushMenuThemes Func _WinAPI_RefreshImmersiveColorPolicyState() Local $aResult = DllCall("UxTheme.dll", "none", 104) If @error Then Return SetError(1, 0, False) Return True EndFunc ;==>_WinAPI_RefreshImmersiveColorPolicyState Func _WinAPI_SetPreferredAppMode($iPreferredAppMode) ;Windows 10 Build 18362+ Local $aResult = DllCall("UxTheme.dll", "long", 135, "long", $iPreferredAppMode) If @error Then Return SetError(1, 0, False) Return $aResult[0] EndFunc ;==>_WinAPI_SetPreferredAppMode #EndRegion DarkMode API
WildByDesign Posted December 29, 2025 Author Posted December 29, 2025 By the way, the reason why I would like to trying using FillRect/SetBkMode is because I am trying to apply Windows 11 materials to all controls in another app (Files Au3), with the exception of the header seen in the screenshot below. Files Au3 uses a detached header. But I figured that it might be easier to share an example of a ListView header since that is much more common. Anyway, I just wanted to give a bit of reason for why I am trying to do this.
Solution Nine Posted December 29, 2025 Solution Posted December 29, 2025 I tested in my colored header script and it is working well. Case $CDDS_ITEMPREPAINT $hDC = $tCustDraw.hDC $iItem = $tCustDraw.dwItemSpec $tRect = DllStructCreate($tagRECT, DllStructGetPtr($tCustDraw, "Left")) _WinAPI_SetBkMode($hDC, 1) _WinAPI_SetTextColor($hDC, 0xFFFFFF) $hBrush = _WinAPI_CreateSolidBrush(0x808080) _WinAPI_FillRect($hDC, $tRect, $hBrush) _WinAPI_DeleteObject($hBrush) _WinAPI_InflateRect($tRect, -5, -2) _WinAPI_DrawText($hDC, _GUICtrlHeader_GetItemText($tCustDraw.hWndFrom, $iItem), $tRect, $DT_LEFT) Return $CDRF_SKIPDEFAULT You need to adapt to your own script. WildByDesign 1 “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
WildByDesign Posted December 29, 2025 Author Posted December 29, 2025 3 hours ago, Nine said: I tested in my colored header script and it is working well. Thank you very much. The good news is that my theory on the FillRect/SetBkMode being the "secret sauce" to getting the Windows 11 materials to apply ended up being correct. But if you don't mind and have a few extra minutes, there are a couple of parts that I'm not sure about. How can I get the rectangle size of the remaining right-side of the header? This method seems to take away the hover color and clicking color, how can we restore that? Here is the updated code to see how it is working now: expandcollapse popup; Coded by UEZ build 2025-12-18 beta ; not DPI aware! #include <APIConstants.au3> #include <ListViewConstants.au3> #include <WinAPIConstants.au3> #include <WinAPIGdi.au3> #include <WinAPIShellEx.au3> #include <WinAPISys.au3> #include <WinAPITheme.au3> #include <GuiHeader.au3> ; DPI awareness DllCall("User32.dll", "bool", "SetProcessDpiAwarenessContext" , "HWND", "DPI_AWARENESS_CONTEXT" -2) Enum $APPMODE_FORCEDARK ; Dark Mode Colors (RGB) Global Const $COLOR_BG_DARK = 0x000000 Global Const $COLOR_TEXT_LIGHT = 0xFFFFFF Global Const $COLOR_EDIT_BG = 0x1E1E1E ; Global variables for subclassing (MUST be declared before _Example()!) Global $g_hGUI = 0, $g_ListView Global $g_aControls[50][3] = [[0, 0, 0]] ; [ControlID, hWnd, OldWndProc] Global $g_iControlCount = 0 Global $g_pSubclassProc = 0 ; Structure for NM_CUSTOMDRAW notification Global Const $tagNMCUSTOMDRAW = _ $tagNMHDR & ";" & _ ; Contains NM_CUSTOMDRAW / NMHDR header among other things "dword dwDrawStage;" & _ ; Current drawing stage (CDDS_*) "handle hdc;" & _ ; Device Context Handle "long left;long top;long right;long bottom;" & _ ; Drawing rectangle "dword_ptr dwItemSpec;" & _ ; Item index or other info (depending on the control) "uint uItemState;" & _ ; State Flags (CDIS_SELECTED, CDIS_FOCUS etc.) "lparam lItemlParam" ; lParam set by the item (e.g., via LVITEM.lParam) _Example() Func _Example() #Region GUI $g_hGUI = GUICreate("Sample GUI with Dark Mode", 400, 400) GUISetBkColor($COLOR_BG_DARK, $g_hGUI) #EndRegion GUI #Region LIST VIEW Local $idListView = GUICtrlCreateListView("Sample|ListView|", 10, 10, 380, 380, -1, BitOR($LVS_EX_DOUBLEBUFFER, $LVS_EX_FULLROWSELECT, $WS_EX_CLIENTEDGE)) _AddControlForSubclass($idListView) GUICtrlSetBkColor($idListView, $COLOR_EDIT_BG) GUICtrlSetColor($idListView, $COLOR_TEXT_LIGHT) GUICtrlSetTip(-1, '#Region LIST VIEW') GUICtrlCreateListViewItem("A|One", $idListView) GUICtrlCreateListViewItem("B|Two", $idListView) GUICtrlCreateListViewItem("C|Three", $idListView) $g_ListView = GUICtrlGetHandle($idListView) #EndRegion LIST VIEW ; Apply Dark Mode _ApplyDarkModeToAllControls() If @OSBuild >= 22621 Then _WinAPI_DwmSetWindowAttribute_unr($g_hGUI, 38, 3) _WinAPI_DwmExtendFrameIntoClientArea($g_hGUI, _WinAPI_CreateMargins(-1, -1, -1, -1)) EndIf GUISetState(@SW_SHOW) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE _CleanupSubclassing() ExitLoop EndSwitch WEnd GUIDelete() EndFunc ;==>_Example Func _ColorToCOLORREF($iColor) ;RGB to BGR Local $iR = BitAND(BitShift($iColor, 16), 0xFF) Local $iG = BitAND(BitShift($iColor, 8), 0xFF) Local $iB = BitAND($iColor, 0xFF) Return BitOR(BitShift($iB, -16), BitShift($iG, -8), $iR) EndFunc ;==>_ColorToCOLORREF Func _AddControlForSubclass($iCtrlID) Local $hCtrl = GUICtrlGetHandle($iCtrlID) If $hCtrl Then $g_aControls[$g_iControlCount][0] = $iCtrlID $g_aControls[$g_iControlCount][1] = $hCtrl $g_aControls[$g_iControlCount][2] = 0 ; Placeholder for OldWndProc $g_iControlCount += 1 EndIf EndFunc ;==>_AddControlForSubclass Func _ApplyDarkModeToAllControls() ; DWM Dark Mode for the main window _WinAPI_SetPreferredAppMode($APPMODE_FORCEDARK) ; Create subclass callback If Not $g_pSubclassProc Then $g_pSubclassProc = DllCallbackRegister("_SubclassProc", "lresult", "hwnd;uint;wparam;lparam;uint_ptr;dword_ptr") ; Subclass all controls Local $hCtrl, $sClass, $hEdit, $hComboLBox, $hHeader, $hUpDown For $i = 0 To $g_iControlCount - 1 $hCtrl = $g_aControls[$i][1] If $hCtrl Then $sClass = _WinAPI_GetClassName($hCtrl) ; Use SetWindowSubclass _WinAPI_SetWindowSubclass($hCtrl, DllCallbackGetPtr($g_pSubclassProc), $i, 0) ; Special themes for different control types Switch StringLower($sClass) Case "syslistview32" _WinAPI_SetWindowTheme($hCtrl, "DarkMode_Explorer", 0) ; Also make the ListView header dark $hHeader = _SendMessage($hCtrl, $LVM_GETHEADER, 0, 0) If $hHeader Then _WinAPI_SetWindowTheme($hHeader, "DarkMode_ItemsView", 0) EndIf Case Else _WinAPI_SetWindowTheme($hCtrl, "DarkMode_Explorer", 0) EndSwitch _WinAPI_AllowDarkModeForWindow($hCtrl, True) EndIf Next ; Update theme system _WinAPI_RefreshImmersiveColorPolicyState() _WinAPI_FlushMenuThemes() _WinAPI_DwmSetWindowAttribute($g_hGUI, $DWMWA_USE_IMMERSIVE_DARK_MODE, True) ; Redraw GUI _WinAPI_RedrawWindow($g_hGUI, 0, 0, $RDW_UPDATENOW) EndFunc ;==>_ApplyDarkModeToAllControls Func _CleanupSubclassing() ; Remove all subclasses If $g_pSubclassProc Then Local $hCtrl For $i = 0 To $g_iControlCount - 1 $hCtrl = $g_aControls[$i][1] If $hCtrl Then _WinAPI_RemoveWindowSubclass($hCtrl, DllCallbackGetPtr($g_pSubclassProc), $i) EndIf Next DllCallbackFree($g_pSubclassProc) $g_pSubclassProc = 0 EndIf EndFunc ;==>_CleanupSubclassing Func _SubclassProc($hWnd, $iMsg, $wParam, $lParam, $iID, $pData) Switch $iMsg Case $WM_NOTIFY Local $tNMHDR = DllStructCreate($tagNMHDR, $lParam) Local $hFrom = $tNMHDR.hWndFrom Local $iCode = $tNMHDR.Code ; --- Adjust ListView Header text color --- If $iCode = $NM_CUSTOMDRAW Then Local $tNMCUSTOMDRAW = DllStructCreate($tagNMCUSTOMDRAW, $lParam) Local $dwDrawStage = $tNMCUSTOMDRAW.dwDrawStage Local $hDC = $tNMCUSTOMDRAW.hdc Switch $dwDrawStage Case $CDDS_PREPAINT Return $CDRF_NOTIFYITEMDRAW Case $CDDS_ITEMPREPAINT ;_WinAPI_SetTextColor($hDC, _ColorToCOLORREF($COLOR_TEXT_LIGHT)) ; White text ;_WinAPI_SetBkColor($hDC, _ColorToCOLORREF($COLOR_BG_DARK)) ; Dark background ;Return BitOR($CDRF_NEWFONT, $CDRF_NOTIFYPOSTPAINT) $hDC = $tNMCUSTOMDRAW.hDC $iItem = $tNMCUSTOMDRAW.dwItemSpec $tRect = DllStructCreate($tagRECT, DllStructGetPtr($tNMCUSTOMDRAW, "Left")) _WinAPI_SetBkMode($hDC, 1) _WinAPI_SetTextColor($hDC, 0xFFFFFF) $hBrush = _WinAPI_CreateSolidBrush(0x000000) _WinAPI_FillRect($hDC, $tRect, $hBrush) _WinAPI_DeleteObject($hBrush) _WinAPI_InflateRect($tRect, -5, -2) _WinAPI_DrawText($hDC, _GUICtrlHeader_GetItemText($tNMCUSTOMDRAW.hWndFrom, $iItem), $tRect, $DT_LEFT) Return $CDRF_SKIPDEFAULT EndSwitch EndIf Case $WM_PAINT ; Custom Paint for better Dark Mode rendering Return _WinAPI_DefSubclassProc($hWnd, $iMsg, $wParam, $lParam) EndSwitch ; Forward standard message to DefSubclassProc Return _WinAPI_DefSubclassProc($hWnd, $iMsg, $wParam, $lParam) EndFunc ;==>_SubclassProc Func _WinAPI_FindWindowEx($hParent, $hAfter, $sClass, $sTitle = "") Local $ret = DllCall("user32.dll", "hwnd", "FindWindowExW", "hwnd", $hParent, "hwnd", $hAfter, "wstr", $sClass, "wstr", $sTitle) If @error Or Not IsArray($ret) Then Return 0 Return $ret[0] EndFunc ;==>_WinAPI_FindWindowEx Func _WinAPI_AllowDarkModeForWindow($hWND, $bAllow = True) Local $aResult = DllCall("UxTheme.dll", "bool", 133, "hwnd", $hWND, "bool", $bAllow) If @error Then Return SetError(1, 0, False) Return ($aResult[0] <> 0) EndFunc ;==>_WinAPI_AllowDarkModeForWindow Func _WinAPI_FlushMenuThemes() Local $aResult = DllCall("UxTheme.dll", "none", 136) If @error Then Return SetError(1, 0, False) Return True EndFunc ;==>_WinAPI_FlushMenuThemes Func _WinAPI_RefreshImmersiveColorPolicyState() Local $aResult = DllCall("UxTheme.dll", "none", 104) If @error Then Return SetError(1, 0, False) Return True EndFunc ;==>_WinAPI_RefreshImmersiveColorPolicyState Func _WinAPI_SetPreferredAppMode($iPreferredAppMode) ;Windows 10 Build 18362+ Local $aResult = DllCall("UxTheme.dll", "long", 135, "long", $iPreferredAppMode) If @error Then Return SetError(1, 0, False) Return $aResult[0] EndFunc ;==>_WinAPI_SetPreferredAppMode #EndRegion DarkMode API ; #FUNCTION# ==================================================================================================================== ; Name ..........: _WinAPI_DwmSetWindowAttribute_unr ; Description ...: Dose the same as _WinAPI_DwmSetWindowAttribute; But has no Restrictions ; Syntax ........: _WinAPI_DwmSetWindowAttribute_unr($hWnd, $iAttribute, $iData) ; Parameters ....: $hWnd - a handle value. ; $iAttribute - an integer value. ; $iData - an integer value. ; Return values .: Success: 1 Failure: @error, @extended & False ; Author ........: argumentum ; Modified ......: ; Remarks .......: ; Related .......: ; Link ..........: https://www.autoitscript.com/forum/topic/211475-winapithemeex-darkmode-for-autoits-win32guis/?do=findComment&comment=1530103 ; Example .......: No ; =============================================================================================================================== Func _WinAPI_DwmSetWindowAttribute_unr($hWnd, $iAttribute, $iData) ; #include <WinAPIGdi.au3> ; unthoughtful unrestricting mod. Local $aCall = DllCall('dwmapi.dll', 'long', 'DwmSetWindowAttribute', 'hwnd', $hWnd, 'dword', $iAttribute, _ 'dword*', $iData, 'dword', 4) If @error Then Return SetError(@error, @extended, 0) If $aCall[0] Then Return SetError(10, $aCall[0], 0) Return 1 EndFunc ;==>_WinAPI_DwmSetWindowAttribute_unr Parsix 1
Nine Posted December 29, 2025 Posted December 29, 2025 (edited) Nvm my previous answer if you read it before. The solution is to remove the line : Return $CDRF_SKIPDEFAULT Edited December 29, 2025 by Nine WildByDesign 1 “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
WildByDesign Posted December 29, 2025 Author Posted December 29, 2025 54 minutes ago, Nine said: Nvm my previous answer if you read it before. The solution is to remove the line : Thanks for the follow up. Unfortunately, it does not seem like this produces the correct result. I mean, it does bring back the hot color but it seems to get rid of any of the custom colors. Here is what I have so far: Case $CDDS_ITEMPREPAINT $hDC = $tNMCUSTOMDRAW.hDC $iItem = $tNMCUSTOMDRAW.dwItemSpec $tRect = DllStructCreate($tagRECT, DllStructGetPtr($tNMCUSTOMDRAW, "Left")) _WinAPI_SetBkMode($hDC, 1) _WinAPI_SetTextColor($hDC, 0xFFFFFF) If BitAND($tNMCUSTOMDRAW.uItemState, $CDIS_SELECTED) Then $hBrush = _WinAPI_CreateSolidBrush(0xff00ff) ElseIf BitAND($tNMCUSTOMDRAW.uItemState, $CDIS_HOT) Then $hBrush = _WinAPI_CreateSolidBrush(0xff0000) ElseIf BitAND($tNMCUSTOMDRAW.uItemState, $CDIS_FOCUS) Then $hBrush = _WinAPI_CreateSolidBrush(0x0000ff) Else $hBrush = _WinAPI_CreateSolidBrush(0x000000) EndIf _WinAPI_FillRect($hDC, $tRect, $hBrush) _WinAPI_DeleteObject($hBrush) _WinAPI_InflateRect($tRect, -5, -2) _WinAPI_DrawText($hDC, _GUICtrlHeader_GetItemText($tNMCUSTOMDRAW.hWndFrom, $iItem), $tRect, $DT_LEFT) Return $CDRF_SKIPDEFAULT The $CDIS_SELECTED color is working and the Else part is working. But the $CDIS_HOT and $CDIS_FOCUS don't work for some reason.
Nine Posted December 30, 2025 Posted December 30, 2025 There is no notification for hot and focus on list view header. But you can have standard behavior when you click on header if you do not skip default. WildByDesign 1 “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
WildByDesign Posted December 30, 2025 Author Posted December 30, 2025 (edited) Thank you for the help, @Nine. I appreciate it very much. So it seems that my options are quite limited when it comes to some of the behaviour, particularly hovering over the header items. That might very well be a deal breaker on this. But for sake of curiosity, I was able to achieve very nice behaviour when clicking on a header item. Since the CDIS_SELECTED state does work, I was able to use that to change the brush FillRect colour when clicking on the header item and modify the InflateRect by 1 pixel x/y to have the same effect as a standard header click. It looks and feels identical. Case $CDDS_ITEMPREPAINT $hDC = $tNMCUSTOMDRAW.hDC $iItem = $tNMCUSTOMDRAW.dwItemSpec $tRect = DllStructCreate($tagRECT, DllStructGetPtr($tNMCUSTOMDRAW, "Left")) _WinAPI_SetBkMode($hDC, 1) _WinAPI_SetTextColor($hDC, 0xFFFFFF) If BitAND($tNMCUSTOMDRAW.uItemState, $CDIS_SELECTED) Then $hBrush = _WinAPI_CreateSolidBrush(0x121212) Else $hBrush = _WinAPI_CreateSolidBrush(0x000000) EndIf _WinAPI_FillRect($hDC, $tRect, $hBrush) _WinAPI_DeleteObject($hBrush) If BitAND($tNMCUSTOMDRAW.uItemState, $CDIS_SELECTED) Then _WinAPI_InflateRect($tRect, -6, -3) Else _WinAPI_InflateRect($tRect, -5, -2) EndIf _WinAPI_DrawText($hDC, _GUICtrlHeader_GetItemText($tNMCUSTOMDRAW.hWndFrom, $iItem), $tRect, $DT_LEFT) Return $CDRF_SKIPDEFAULT This is quite neat and works well. However, missing the hover/hot state may cause me to decide to not end up using this. The user, no doubt, would get the impression that the header items are not intended to be clicked on when in fact that they are. Anyway, one remaining question. Do you have any idea how to do a SetBkMode/FillRect on the header area to the right of the header items? Edited December 30, 2025 by WildByDesign
Nine Posted December 30, 2025 Posted December 30, 2025 One solution I am thinking is to use this : _GUICtrlListView_SetColumnWidth($hListView, $n, $LVSCW_AUTOSIZE_USEHEADER) where $n = number header columns - 1 WildByDesign 1 “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
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