gcue Posted July 26, 2016 Share Posted July 26, 2016 (edited) hello i am changing colors of listview items via wm_notify after they have been drawn but the color change wont appear until i scroll away and back to the item. is there any way to refresh the listview somehow so i can see the change immediately? thanks in advance!!! (credit to AutoBert/BugFix for the original example provided) expandcollapse popup;Original von BugFix http://www.autoit.de/index.php?page=Thread&postID=173432#post173432 #include <GUIConstantsEx.au3> #include <GuiListView.au3> #include <array.au3> #include <ListViewConstants.au3> #include <StructureConstants.au3> #include <WindowsConstants.au3> ;create arrays for listview index items changing colors Global $untagged_array[1][2], $unsaved_array[1][2], $partly_tagged_array[1][2], $fully_tagged_array[2][2] ;define which listview items will change colors $untagged_array[0][0] = "2" $untagged_array[0][1] = "0xFAFAFA" $unsaved_array[0][0] = "4" $unsaved_array[0][1] = "0xFF0000" $partly_tagged_array[0][0] = "1" $partly_tagged_array[0][1] = "0xFFD700" $fully_tagged_array[0][0] = "0" $fully_tagged_array[0][1] = "0x00FF00" $GUI = GUICreate("Listview", 1024, 300, 0, 0) $cListView = GUICtrlCreateListView("", 2, 2, 1020, 294, -1, BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT)) $hListView = GUICtrlGetHandle($cListView) For $i = 1 To 31 _GUICtrlListView_InsertColumn($hListView, $i - 1, $i, 25) _GUICtrlListView_SetColumnWidth($hListView, $i - 1, 32) Next For $i = 0 To 21 _GUICtrlListView_AddItem($hListView, "", $i) For $j = 0 To 30 _GUICtrlListView_AddSubItem($hListView, $i, "", $j) Next Next GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") GUISetState() ;;;;;;;;;;;at this point all is working normally ;pause before making an additional color change msgbox(0,"","pause") ;make additional color change $fully_tagged_array[1][0] = "7" $fully_tagged_array[1][1] = "0x00FF00" ;;;;;;;;; last color change (done after pause) doesnt show.. BUT will show if you scroll all the way down the listview then back up to the item While True $msg = GUIGetMsg() Switch $msg Case -3 ExitLoop EndSwitch WEnd Exit 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) $iItem = DllStructGetData($tCustDraw, 'dwItemSpec') Switch $iItem ; Rows Case -1 Case Else $iIndex = _ArraySearch($untagged_array, String($iItem), 0, 0, 0, 0, 0, 0) If $iIndex <> -1 Then DllStructSetData($tCustDraw, 'clrTextBk', RGB2BGR($untagged_array[$iIndex][1])) EndIf $iIndex = _ArraySearch($unsaved_array, String($iItem), 0, 0, 0, 0, 0, 0) If $iIndex <> -1 Then DllStructSetData($tCustDraw, 'clrTextBk', RGB2BGR($unsaved_array[$iIndex][1])) EndIf $iIndex = _ArraySearch($partly_tagged_array, String($iItem), 0, 0, 0, 0, 0, 0) If $iIndex <> -1 Then DllStructSetData($tCustDraw, 'clrTextBk', RGB2BGR($partly_tagged_array[$iIndex][1])) EndIf $iIndex = _ArraySearch($fully_tagged_array, String($iItem), 0, 0, 0, 0, 0, 0) If $iIndex <> -1 Then DllStructSetData($tCustDraw, 'clrTextBk', RGB2BGR($fully_tagged_array[$iIndex][1])) 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 Edited July 26, 2016 by gcue Link to comment Share on other sites More sharing options...
gcue Posted July 27, 2016 Author Share Posted July 27, 2016 sorry moderators, i accidentally posted in wrong section - can you please move this topic to AutoIt General Help and Support thanks! Link to comment Share on other sites More sharing options...
LarsJ Posted July 27, 2016 Share Posted July 27, 2016 Take a look at _GUICtrlListView_RedrawItems. Controls, File Explorer, ROT objects, UI Automation, Windows Message MonitorCompiled code: Accessing AutoIt variables, DotNet.au3 UDF, Using C# and VB codeShell menus: The Context menu, The Favorites menu. Shell related: Control Panel, System Image ListsGraphics related: Rubik's Cube, OpenGL without external libraries, Navigating in an image, Non-rectangular selectionsListView controls: Colors and fonts, Multi-line header, Multi-line items, Checkboxes and icons, Incremental searchListView controls: Virtual ListViews, Editing cells, Data display functions Link to comment Share on other sites More sharing options...
gcue Posted July 27, 2016 Author Share Posted July 27, 2016 worked great! thank youuuu! 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