#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>
#include <FontConstants.au3>
#include <GuiListView.au3>
#include <Constants.au3>
Opt('MustDeclareVars', 1)
Global $hGUI, $cListView, $hListView
Global $iDllGDI = DllOpen("gdi32.dll")
Global $iDllUSER32 = DllOpen("user32.dll")
Global $aCol[3][2] = [[0x0, 0xE9E4DA],[0x0, 0xE9E4DA],[0x0, 0xE9E4DA]]
For $i = 0 To UBound($aCol)-1
$aCol[$i][0] = _BGR2RGB($aCol[$i][0])
$aCol[$i][1] = _BGR2RGB($aCol[$i][1])
Next
$hGUI = GUICreate("Set Listview Header Colour ", 500, 300)
GUISetBkColor(0x0)
$cListView = GUICtrlCreateListView("Имя|Handle|Размещение", 10, 10, 480, 278)
$hListView = GUICtrlGetHandle($cListView)
_GUICtrlListView_SetExtendedListViewStyle($hListView, BitOR($LVS_EX_DOUBLEBUFFER, $LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT))
Global $hHeader = HWnd(GUICtrlSendMsg($cListView, $LVM_GETHEADER, 0, 0))
DllCall("uxtheme.dll", "int", "SetWindowTheme", "hwnd", $hHeader, "wstr", "", "wstr", "")
Global $wProcNew = DllCallbackRegister("_LVWndProc", "ptr", "hwnd;uint;wparam;lparam")
Global $wProcOld = _WinAPI_SetWindowLong($hListView, $GWL_WNDPROC, DllCallbackGetPtr($wProcNew))
Global $iStyle = _WinAPI_GetWindowLong($hHeader, $GWL_STYLE)
_WinAPI_SetWindowLong($hHeader, $GWL_STYLE, BitOR($iStyle, $HDS_FLAT))
_GUICtrlListView_AddItem($hListView, "Ляля")
_GUICtrlListView_AddSubItem($hListView, 0, "0x123456789", 1)
_GUICtrlListView_AddSubItem($hListView, 0, "С:\ляля.xyi", 2)
_GUICtrlListView_SetColumnWidth($hListView, 0, $LVSCW_AUTOSIZE_USEHEADER)
_GUICtrlListView_SetColumnWidth($hListView, 1, $LVSCW_AUTOSIZE_USEHEADER)
_GUICtrlListView_SetColumnWidth($hListView, 2, $LVSCW_AUTOSIZE_USEHEADER)
_GUICtrlListView_SetBkColor($hListView, 0x0)
_GUICtrlListView_SetTextBkColor($hListView, 0x0)
_GUICtrlListView_SetTextColor($hListView, 0x0000FF)
GUISetState()
Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE
If $wProcOld Then _WinAPI_SetWindowLong($hListView, $GWL_WNDPROC, $wProcOld)
If $wProcNew Then DllCallbackFree($wProcNew)
GUIDelete()
Exit
Func _LVWndProc($hWnd, $iMsg, $wParam, $lParam)
If $iMsg = $WM_NOTIFY Then
Local $tNMHDR, $hWndFrom, $iCode, $iItem, $hDC
$tNMHDR = DllStructCreate($tagNMHDR, $lParam)
$hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
$iCode = DllStructGetData($tNMHDR, "Code")
Switch $hWndFrom
Case $hHeader
Switch $iCode
Case $NM_CUSTOMDRAW
Local $tCustDraw = DllStructCreate($tagNMLVCUSTOMDRAW, $lParam)
Switch DllStructGetData($tCustDraw, "dwDrawStage")
Case $CDDS_PREPAINT
Return $CDRF_NOTIFYITEMDRAW
Case $CDDS_ITEMPREPAINT
$hDC = DllStructGetData($tCustDraw, "hDC")
DllCall($iDllGDI, "int", "SetTextColor", "handle", $hDC, "dword", $aCol[$iItem][0])
DllCall($iDllGDI, "int", "SetBkColor", "handle", $hDC, "dword", $aCol[$iItem][1])
Return $CDRF_NEWFONT
EndSwitch
EndSwitch
EndSwitch
EndIf
Local $aResult = DllCall($iDllUSER32, "lresult", "CallWindowProcW", "ptr", $wProcOld, _
"hwnd", $hWnd, "uint", $iMsg, "wparam", $wParam, "lparam", $lParam)
If @error Then Return -1
Return $aResult[0]
EndFunc
Func _BGR2RGB($iColor)
Return BitOR(BitShift(BitAND($iColor, 0x0000FF), -16), BitAND($iColor, 0x00FF00), BitShift(BitAND($iColor, 0xFF0000), 16))
EndFunc