Search the Community
Showing results for tags 'headercolumn'.
-
I have a LV with different coloured Cols: ;https://autoit.de/index.php/Thread/84279-Unterschiedliche-Textfarben-innerhalb-einer-ListView/?postID=674195#post674195 #include <GUIConstantsEx.au3> #include <GuiListView.au3> #include <array.au3> #include <ListViewConstants.au3> #include <StructureConstants.au3> #include <WindowsConstants.au3> $aColBK = IniReadSection(@ScriptDir & "\lv_format.ini", "ColBKColor") _ArrayDelete($aColBK, 0) ;_ArrayDisplay($aColBK) $aRowBK = IniReadSection(@ScriptDir & "\lv_format.ini", "RowBKColor") _ArrayDelete($aRowBK, 0) ;_ArrayDisplay($aColBK) $aColText = IniReadSection(@ScriptDir & "\lv_format.ini", "ColTextColor") _ArrayDelete($aColText, 0) ;_ArrayDisplay($aColBK) $aRowText = IniReadSection(@ScriptDir & "\lv_format.ini", "RowTextColor") _ArrayDelete($aRowText, 0) ;_ArrayDisplay($aRowText) $GUI = GUICreate("Listview Farbig", 1024, 300, 0, 0) ;<==== Breite geändert $cListView = GUICtrlCreateListView("", 2, 2, 1020, 294, -1, BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT)) ;<==== Breite geändert $hListView = GUICtrlGetHandle($cListView) For $i = 1 To 31 _GUICtrlListView_InsertColumn($hListView, $i - 1, $i, 25) _GUICtrlListView_SetColumnWidth($hListView, $i - 1, 32) ;<==== eingefügt für Spaltenbreite Next For $i = 0 To 21 ; alle Item/SubItem erstellen _GUICtrlListView_AddItem($hListView, "Item: " &$i, $i) For $j = 1 To 30 _GUICtrlListView_AddSubItem($hListView, $i, "Sub: "&$j, $j) Next Next GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") GUISetState() While True $msg = GUIGetMsg() Switch $msg Case -3 ExitLoop EndSwitch WEnd Func WM_NOTIFY($hWnd, $msg, $wParam, $lParam) Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR $tNMHDR = DllStructCreate($tagNMHDR, $lParam) $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) $iIDFrom = DllStructGetData($tNMHDR, "IDFrom") $iCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom Case $hListView Switch $iCode Case $NM_CUSTOMDRAW Local $tCustDraw = DllStructCreate($tagNMLVCUSTOMDRAW, $lParam) Local $iDrawStage, $iItem, $iSubitem, $hDC, $tRect $iDrawStage = DllStructGetData($tCustDraw, 'dwDrawStage') Switch $iDrawStage Case $CDDS_ITEMPREPAINT Return $CDRF_NOTIFYSUBITEMDRAW Case BitOR($CDDS_ITEMPREPAINT, $CDDS_SUBITEM) ; Item/SubItem das aktuell gezeichnet werden soll ermitteln $iItem = DllStructGetData($tCustDraw, 'dwItemSpec') $iSubitem = DllStructGetData($tCustDraw, 'iSubItem') Switch $iItem ; Zeilenwahl Case -1 ;kommt nicht vor ist aber notwendig, damit case else verwendet werden kann Case Else $iIndex = _ArraySearch($aRowBK, $iItem, 0, 0, 0, 0, 1, 0) If $iIndex = -1 Then ;nicht im Array für spezielle Zeilen also weiß DllStructSetData($tCustDraw, 'clrTextBk', RGB2BGR(0xFFFFFF)) Else DllStructSetData($tCustDraw, 'clrTextBk', RGB2BGR($aRowBK[$iIndex][1])) ;ConsoleWrite('Item '&$iItem&' BK: '&$aRowBK[$iIndex][1] & @CRLF) EndIf $iIndex = _ArraySearch($aRowText, $iItem, 0, 0, 0, 0, 1, 0) If $iIndex = -1 Then ;nicht im Array für spezielle Zeilen also schwarz DllStructSetData($tCustDraw, 'clrText', RGB2BGR(0x000000)) Else DllStructSetData($tCustDraw, 'clrText', RGB2BGR($aRowText[$iIndex][1])) ;ConsoleWrite('Item '&$iItem&' Text: '&$aRowText[$iIndex][1] & @CRLF) EndIf EndSwitch Switch $iSubitem Case -1 ;kommt nicht vor ist aber notwendig, damit case else verwendet werden kann Case Else $iIndex = _ArraySearch($aColBK, $iSubitem, 0, 0, 0, 0, 1, 0) If $iIndex <> -1 Then DllStructSetData($tCustDraw, 'clrTextBk', RGB2BGR($aColBK[$iIndex][1])) ;ConsoleWrite('SubItem '&$iSubitem&' BK: '&$aColBK[$iIndex][1] & @CRLF) EndIf $iIndex = _ArraySearch($aColText, $iSubitem, 0, 0, 0, 0, 1, 0) If $iIndex <> -1 Then DllStructSetData($tCustDraw, 'clrText', RGB2BGR($aColText[$iIndex][1])) ;ConsoleWrite('SubItem '&$iSubitem&' Text: '&$aColText[$iIndex][1] & @CRLF) EndIf EndSwitch Return $CDRF_NEWFONT EndSwitch EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY Func RGB2BGR($iColor) Local $sH = Hex($iColor, 6) Return '0x' & StringRight($sH, 2) & StringMid($sH, 3, 2) & StringLeft($sH, 2) EndFunc ;==>RGB2BGR i use lv_format.ini for defining the cols Background- and Textcolour. Now i want to colour the cols in the LV-Header also, but i can't figure it out.
- 21 replies
-
- guictrlcreatelistview
- wm_notify
-
(and 1 more)
Tagged with: