Scriptonize Posted March 19, 2015 Share Posted March 19, 2015 @LarsJ Impressive. Great job If you learn from It, it's not a mistake Link to comment Share on other sites More sharing options...
JohnOne Posted March 19, 2015 Author Share Posted March 19, 2015 (edited) Bah! Never factored that I have multiple Listviews in my gui. This tries to apply the colours to listviews which are different and subsequently crashes. Tried to first check if the correct tab was active in WM_NOTIFY, but the WM_NOTIFY function appears to be actioned before the tab appears and I can get the text from it. EDIT: Never mind, answer >here. Just need ti implement it in my code. Edited March 19, 2015 by JohnOne AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
Scriptonize Posted March 20, 2015 Share Posted March 20, 2015 Never factored that I have multiple Listviews in my gui. This tries to apply the colours to listviews which are different and subsequently crashes. Strange, I had no crash. If you learn from It, it's not a mistake Link to comment Share on other sites More sharing options...
jugador Posted October 19, 2019 Share Posted October 19, 2019 (edited) Sorry, I know this is old thread but as I am trying out @LarsJ code so asking here. @LarsJ Is there any other way to color ListView specific cell if logic is true. Without using DllStruct. I don’t understand DllStructucture logic properly & in my case Array size is no to big [30][15]. So can it be done using GUICtrlSetBkColor or _GUICtrlListView_CreateSolidBitMap? Edited October 19, 2019 by jugador Link to comment Share on other sites More sharing options...
LarsJ Posted October 19, 2019 Share Posted October 19, 2019 The custom draw technique is the great, right, flexible and fast way to apply colors in a listview. Read about DllStruct in the help file and just ask more questions if you have any doubts. jugador 1 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...
jugador Posted October 21, 2019 Share Posted October 21, 2019 @LarsJ ok I get it how to color listview but No I didnt get it how DllStruct work 😂. I use @mikell code to understand how it work. expandcollapse popup#include <GUIConstantsEx.au3> #include <GuiListView.au3> #include <WindowsConstants.au3> Global $myitem = -1, $mysubitem = -1 $Form1 = GUICreate("Form1", 350, 250, -1, -1) $ListView1 = GUICtrlCreateListView("Header|Header|Header", 0, 0, 350, 200) GuiCtrlCreateListViewItem('White|White|White',$ListView1) GuiCtrlCreateListViewItem('Pink|Green|Pink',$ListView1) GuiCtrlCreateListViewItem('White|White|White',$ListView1) $btn = GuiCtrlCreateButton('button', 20, 210, 50, 25) $iRows = 3 $iCols = 3 Global $aColors[$iRows][$iCols] For $i = 0 To $iRows - 1 For $j = 0 To $iCols - 1 If $i = 1 Then If $j = 1 Then $aColors[$i][$j] = RGB2BGR(0x00aa00) ; green Else $aColors[$i][$j] = RGB2BGR(0xffaaff) ; pink EndIf Else $aColors[$i][$j] = RGB2BGR(0xFFFFFF) ; white EndIf Next Next GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $btn $aColors[1][1] = RGB2BGR(0xFF0000) ; red _GUICtrlListView_SetItemText($ListView1, 1, "Red", 1) 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") $hListView = GuiCtrlGetHandle($ListView1) Switch $hWndFrom Case $hListView Switch $iCode 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") DllStructSetData($tCustDraw, "clrTextBk", $aColors[$iItem][$iSubItem]) ; background color 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