huntpeck Posted April 23, 2022 Share Posted April 23, 2022 Hi, I feel like this should be easy, and probably is but I'm not able to find it. I just want to color the column headers of a listview. They can be the same color just want to make it easier to differentiate from the data. I've tried a couple of things but hoping someone has a simple answer. I've included test code I've been using. Thanks! #include <GUIConstantsEx.au3> #include <ColorConstants.au3> #include "GUIListViewEx.au3" #include <MsgBoxConstants.au3> GUICreate("listview items", 220, 250, 100, 200, -1) Global $idListview = GUICtrlCreateListView("col1 |col2|col3 ", 10, 10, 200, 150) GUICtrlCreateListViewItem("item1|item12|item13", $idListview) GUICtrlCreateListViewItem("item2|item22|item23", $idListview) GUICtrlCreateListViewItem("item3|item32|item33", $idListview) GUICtrlCreateListViewItem("item4|item42|item43", $idListview) GUICtrlCreateListViewItem("item5|item52|item53", $idListview) GUICtrlCreateListViewItem("item6|item62|item63", $idListview) $Test = IsHWnd(_GUICtrlListView_GetHeader($idListview)) ;$Test = _GUICtrlListView_GetHeader($idListview) _GUICtrlListView_SetBkColor($Test, $COLOR_RED) GUISetState(@SW_SHOW) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Link to comment Share on other sites More sharing options...
Nine Posted April 23, 2022 Share Posted April 23, 2022 Look at NM_CUSTOMDRAW “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) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted May 5, 2022 Moderators Share Posted May 5, 2022 huntpeck, My GUIListViewEx UDF (see link in my sig) allows you to have coloured headers - but it might be a bit OTT to use it just for that. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Nine Posted May 10, 2022 Share Posted May 10, 2022 Here a streamlined version : expandcollapse popup#include <GuiConstants.au3> #include <FontConstants.au3> #include <GuiListView.au3> #include <Constants.au3> #include <WinAPISysWin.au3> #include <WinAPITheme.au3> Opt('MustDeclareVars', True) Global $hHeader Example() Func Example() Local $hGUI = GUICreate("Listview Color Header", 500, 300) Local $idListView = GUICtrlCreateListView("Items List|SubList 1|SubList 2", 10, 10, 480, 280) _GUICtrlListView_SetExtendedListViewStyle($idListView, BitOR($LVS_EX_DOUBLEBUFFER, $LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT)) $hHeader = GUICtrlSendMsg($idListView, $LVM_GETHEADER, 0, 0) _WinAPI_SetWindowTheme($hHeader, "", "") ;Turn off theme for header Local $iStyle = _WinAPI_GetWindowLong($hHeader, $GWL_STYLE) _WinAPI_SetWindowLong($hHeader, $GWL_STYLE, BitOR($iStyle, $HDS_FLAT)) ; remove header 3D button effect For $i = 1 To 10 _GUICtrlListView_AddItem($idListView, "Item" & $i) _GUICtrlListView_AddSubItem($idListView, $i - 1, "SubItem" & $i, 1) _GUICtrlListView_AddSubItem($idListView, $i - 1, "SubItem" & $i, 2) Next _GUICtrlListView_SetColumnWidth($idListView, 0, $LVSCW_AUTOSIZE_USEHEADER) _GUICtrlListView_SetColumnWidth($idListView, 1, $LVSCW_AUTOSIZE_USEHEADER) _GUICtrlListView_SetColumnWidth($idListView, 2, $LVSCW_AUTOSIZE_USEHEADER) GUIRegisterMsg($WM_NOTIFY, WM_NOTIFY) GUISetState() Do Until GUIGetMsg() = $GUI_EVENT_CLOSE EndFunc ;==>Example Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam) Local $tNMHDR = DllStructCreate($tagNMHDR, $lParam) If $tNMHDR.hWndFrom = $hHeader And $tNMHDR.Code = $NM_CUSTOMDRAW Then Local $tCustDraw = DllStructCreate($tagNMLVCUSTOMDRAW, $lParam) Switch $tCustDraw.dwDrawStage Case $CDDS_PREPAINT Return $CDRF_NOTIFYITEMDRAW Case $CDDS_ITEMPREPAINT _WinAPI_SetTextColor($tCustDraw.hDC, 0) _WinAPI_SetBkColor($tCustDraw.hDC, 0x00FFFF) Return $CDRF_NEWFONT EndSwitch EndIf Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY pixelsearch 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) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
huntpeck Posted May 11, 2022 Author Share Posted May 11, 2022 Thanks to both of you! I will check these out. Link to comment Share on other sites More sharing options...
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