NepesX Posted October 28, 2013 Share Posted October 28, 2013 How To Set Background color for Listview sub item created with _GUICtrlListView_AddItem/_GUICtrlListView_AddSubItem? Please Help?! Link to comment Share on other sites More sharing options...
l3ill Posted October 28, 2013 Share Posted October 28, 2013 Check out this post: The poster used some code that is doing what you want I think. good luck! Bill My Contributions... SnippetBrowser NewSciTE PathFinder Text File Manipulation FTP Connection Tester / INI File - Read, Write, Save & Load Example Link to comment Share on other sites More sharing options...
mikell Posted October 28, 2013 Share Posted October 28, 2013 Something like this ? expandcollapse popup#include <GuiConstantsEx.au3> #include <WindowsConstants.au3> #include <GuiListView.au3> Global $Array1[6], $click_item = -1, $click_subitem $Array1[0] = "JPM" $Array1[1] = "Holger" $Array1[2] = "Jon" $Array1[3] = "Larry" $Array1[4] = "Jeremy" $Array1[5] = "Valik" $hGUI = GUICreate("Test", 300, 300) Global $hListView = _GUICtrlListView_Create($hGUI, "Items|SubItems|", 10, 10, 280, 180, -1, $WS_EX_CLIENTEDGE) _GUICtrlListView_SetExtendedListViewStyle($hListView, BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT)) For $i = 0 To 5 _GUICtrlListView_AddItem($hListView, "Item :" & $i) _GUICtrlListView_AddSubItem($hListView, $i , $Array1[$i], 1) Next GUISetState() GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func WM_NOTIFY($hWnd, $Msg, $wParam, $lParam) Local $tNMHDR, $hWndFrom, $iCode $tNMHDR = DllStructCreate($tagNMHDR, $lParam) $hWndFrom = DllStructGetData($tNMHDR, "hWndFrom") $iCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom Case $hListView Switch $iCode Case $NM_CLICK $tInfo = DllStructCreate($tagNMITEMACTIVATE, $lParam) $click_item = DllStructGetData($tInfo, "Index") $click_subItem = DllStructGetData($tInfo, "SubItem") ControlListView($hGUI, "", $hListview, "DeSelect", -1) _GUICtrlListView_SetTextColor($hListview, RGB2BGR(0x000000)) Case $NM_CUSTOMDRAW Local $tCustDraw = DllStructCreate($tagNMLVCUSTOMDRAW, $lParam) Local $iDrawStage = DllStructGetData($tCustDraw, "dwDrawStage") If $iDrawStage = $CDDS_PREPAINT Then Return $CDRF_NOTIFYITEMDRAW If $iDrawStage = $CDDS_ITEMPREPAINT Then Return $CDRF_NOTIFYSUBITEMDRAW Local $iSubItem = DllStructGetData($tCustDraw, "iSubItem") Local $iItem = DllStructGetData($tCustDraw, "dwItemSpec") Local $iColor If $iItem = $click_item and $iSubItem = $click_subitem Then If $click_subitem = 0 Then $iColor = RGB2BGR(0x00ff00) ElseIf $click_subitem = 1 Then $iColor = RGB2BGR(0xff0000) EndIf Else $iColor = RGB2BGR(0xffffff) EndIf DllStructSetData($tCustDraw, "clrTextBk", $iColor) Return $CDRF_NEWFONT EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY Func RGB2BGR($iColor) Return BitAND(BitShift(String(Binary($iColor)), 8), 0xFFFFFF) EndFunc ;==>RGB2BGR() 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