Nhardel Posted October 11, 2013 Share Posted October 11, 2013 Okay, who is ready to point me to the quickest answer ever on this forum? I am attempting to make a listview type control and cant get my head around how to pull this off. Requirements DYNAMIC number of rows and columns Autoscroll capabilities for a set ctrl size Ability to click individual cells Issues with listviews I can select an item but that really just selects the whole row - perhaps I am missing a style or exstyle setting? meets all other requirements Issues with table.au3 even modified to use input boxes Don't know how I would stick entire table into some type of ctrl box that would do the autoscroll capabilities when the table starts to get large Groupbox? Issues with Embeded excel No way to know for sure that computer that is being used will have excel Don't want to go down the road of making sure installed if I don't have to. Another possible answer is Gridviews but there isnt much info on these in the forum other than how to interact with one already in another application. Not sure how I might go about creating one for myself in autoit So there we go, I have scoured the forums and I can post some code if that helps. Not sure how it will as the code I have works as expected from an Autoit standpoint, just not what I need. Let the 'Ah Ha' moments begin! Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted October 11, 2013 Moderators Share Posted October 11, 2013 (edited) nhardel, I have been looking for a way to hightlight individual cells in a ListView for a long time and never found anything really satisfactory. This is the best I have ever managed myself based on my GUIListViewEx UDF: Let me know what you think. M23 Edited September 27, 2017 by Melba23 Nhardel 1 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Nhardel Posted October 11, 2013 Author Share Posted October 11, 2013 Wow, my skills must be improving. I have stumped one of the AutoIT sorcerers. Melba, Looking thru the sample script, I see your point. It works but man, ouch. I don't need to really edit the cell, just recognize what cell it is and maybe change the background color so the user knows that they selected that cell. I think I can adapt what you have to pull this off, still looking thru it and at work so tons of interuptions. It really seems like such a simple request for individual selectable cells. Thanks for the input. To all others Keep the ideas coming. As you can see there is a demand for a good way to do this. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted October 11, 2013 Moderators Share Posted October 11, 2013 nhardel, It works but man, ouchI could not have put it better myself! But seriously, if all you are looking for is to highlight a single cell then it should be possible to reduce the code significantly. We are forecast a wet weekend here - so if you think there is some merit in the line I have taken I could see what I could develop. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
LarsJ Posted October 12, 2013 Share Posted October 12, 2013 (edited) May be a custom drawn listview: expandcollapse popup#include <WindowsConstants.au3> #include <GUIConstantsEx.au3> #include <GuiListView.au3> Opt( "MustDeclareVars", 1 ) Global $hGui, $hLV, $aHit[2] = [ -1, -1 ] ; $aHit contains row & col of marked cell MainFunc() Func MainFunc() $hGui = GUICreate( "Mark Cell in Listview", 300, 222 ) Local $idLV = GUICtrlCreateListView( "Column 0|Column 1|Column 2", 2, 2, 300-4, 222-4 ) $hLV = ControlGetHandle( $hGui, "", $idLV ) For $i = 0 To 49 GUICtrlCreateListViewItem( "Cell " & $i & ".0" & "|Cell " & $i & ".1" & "|Cell " & $i & ".2", $idLV ) Next GUIRegisterMsg( $WM_NOTIFY, "WM_NOTIFY" ) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd EndFunc Func WM_NOTIFY( $hWnd, $iMsg, $wParam, $lParam ) #forceref $hWnd, $iMsg, $wParam Local $tNMHDR, $hWndFrom, $iCode Local Static $bItemChanged $tNMHDR = DllStructCreate( $tagNMHDR, $lParam ) $hWndFrom = HWnd( DllStructGetData( $tNMHDR, "hWndFrom" ) ) $iCode = DllStructGetData( $tNMHDR, "Code" ) Switch $hWndFrom Case $hLV Switch $iCode Case $LVN_ITEMCHANGED $bItemChanged = True Local $aInfo = GUIGetCursorInfo( $hGui ) If $aInfo[2] Then $aInfo = _GUICtrlListView_SubItemHitTest( $hLV, $aInfo[0], $aInfo[1] ) If $aInfo[0] > -1 And $aInfo[1] > -1 Then If $aHit[0] > -1 Then _ _GUICtrlListView_RedrawItems( $hLV, $aHit[0], $aHit[0] ) $aHit[0] = $aInfo[0] ; Row $aHit[1] = $aInfo[1] ; Col _GUICtrlListView_RedrawItems( $hLV, $aHit[0], $aHit[0] ) _GUICtrlListView_SetItemSelected( $hLV, $aHit[0], False ) EndIf Else Local $tNMLISTVIEW = DllStructCreate( $tagNMLISTVIEW, $lParam ) _GUICtrlListView_SetItemSelected( $hLV, DllStructGetData( $tNMLISTVIEW, "Item" ), False ) EndIf Case $NM_CLICK If Not $bItemChanged Then Local $aInfo = GUIGetCursorInfo( $hGui ) $aInfo = _GUICtrlListView_SubItemHitTest( $hLV, $aInfo[0], $aInfo[1] ) If $aInfo[0] > -1 And $aInfo[1] > -1 Then If $aHit[0] > -1 Then _ _GUICtrlListView_RedrawItems( $hLV, $aHit[0], $aHit[0] ) $aHit[0] = $aInfo[0] ; Row $aHit[1] = $aInfo[1] ; Col _GUICtrlListView_RedrawItems( $hLV, $aHit[0], $aHit[0] ) _GUICtrlListView_SetItemSelected( $hLV, $aHit[0], False ) EndIf EndIf $bItemChanged = False Case $NM_RCLICK Local $aInfo = GUIGetCursorInfo( $hGui ) $aInfo = _GUICtrlListView_SubItemHitTest( $hLV, $aInfo[0], $aInfo[1] ) If $aInfo[0] = $aHit[0] And $aInfo[1] = $aHit[1] Then _GUICtrlListView_RedrawItems( $hLV, $aHit[0], $aHit[0] ) _GUICtrlListView_SetItemSelected( $hLV, $aHit[0], False ) $aHit[0] = -1 ; Row $aHit[1] = -1 ; Col EndIf Case $NM_CUSTOMDRAW Local $tNMLVCUSTOMDRAW = DllStructCreate( $tagNMLVCUSTOMDRAW, $lParam ) Local $dwDrawStage = DllStructGetData( $tNMLVCUSTOMDRAW, "dwDrawStage" ) Switch $dwDrawStage ; Holds a value that specifies the drawing stage Case $CDDS_PREPAINT ; Before the paint cycle begins Return $CDRF_NOTIFYITEMDRAW ; Notify the parent window of any ITEM-related drawing operations Case $CDDS_ITEMPREPAINT ; Before painting an item Return $CDRF_NOTIFYSUBITEMDRAW ; Notify the parent window of any SUBITEM-related drawing operations Case BitOR( $CDDS_ITEMPREPAINT, $CDDS_SUBITEM ) ; Before painting a subitem Local $dwItemSpec = DllStructGetData( $tNMLVCUSTOMDRAW, "dwItemSpec" ) ; Item index Local $iSubItem = DllStructGetData( $tNMLVCUSTOMDRAW, "iSubItem" ) ; Subitem index Local $uItemState = DllStructGetData( $tNMLVCUSTOMDRAW, "uItemState" ) ; Item state If $dwItemSpec = $aHit[0] Then ; Marked row Switch $iSubItem Case $aHit[1] ; Marked column DllStructSetData( $tNMLVCUSTOMDRAW, "ClrText", 0x000000 ) ; Forecolor black DllStructSetData( $tNMLVCUSTOMDRAW, "clrTextBk", 0xFFFF00 ) ; Backcolor cyan, BGR Case Else ; Other columns If BitAnd( $uItemState, $CDIS_FOCUS ) Then ; Selected row DllStructSetData( $tNMLVCUSTOMDRAW, "ClrText", 0xFFFFFF ) ; Forecolor white DllStructSetData( $tNMLVCUSTOMDRAW, "clrTextBk", 0xCC6600 ) ; Backcolor dark blue, BGR Else DllStructSetData( $tNMLVCUSTOMDRAW, "ClrText", 0x000000 ) ; Forecolor black DllStructSetData( $tNMLVCUSTOMDRAW, "ClrTextBk", 0xFFFFFF ) ; Backcolor white EndIf EndSwitch Else ; Other rows If BitAnd( $uItemState, $CDIS_FOCUS ) Then ; Selected row DllStructSetData( $tNMLVCUSTOMDRAW, "ClrText", 0xFFFFFF ) DllStructSetData( $tNMLVCUSTOMDRAW, "clrTextBk", 0xCC6600 ) Else DllStructSetData( $tNMLVCUSTOMDRAW, "ClrText", 0x000000 ) DllStructSetData( $tNMLVCUSTOMDRAW, "ClrTextBk", 0xFFFFFF ) EndIf EndIf Return $CDRF_NEWFONT ; $CDRF_NEWFONT must be returned after changing font or colors EndSwitch EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFuncEdit: Added code for NM_CLICK-event.Edit 2: Right click to unmark.Edit 3: Don't use this code. Use the code in post 6 or 7. Edited October 14, 2013 by LarsJ Digisoul 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...
LarsJ Posted October 13, 2013 Share Posted October 13, 2013 (edited) Click to mark. Click once more to unmark. expandcollapse popup#include <WindowsConstants.au3> #include <GUIConstantsEx.au3> #include <GuiListView.au3> Opt( "MustDeclareVars", 1 ) Global $hGui, $hLV, $aHit[2] = [ -1, -1 ] ; $aHit contains row & col of marked cell MainFunc() Func MainFunc() $hGui = GUICreate( "Mark Cell in Listview", 250, 222 ) Local $idLV = GUICtrlCreateListView( "Column 0|Column 1|Column 2", 2, 2, 250-4, 222-4 ) $hLV = ControlGetHandle( $hGui, "", $idLV ) For $i = 0 To 49 GUICtrlCreateListViewItem( "Cell " & $i & ".0" & "|Cell " & $i & ".1" & "|Cell " & $i & ".2", $idLV ) Next GUIRegisterMsg( $WM_NOTIFY, "WM_NOTIFY" ) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd EndFunc Func WM_NOTIFY( $hWnd, $iMsg, $wParam, $lParam ) #forceref $hWnd, $iMsg, $wParam Local $tNMHDR, $hWndFrom, $iCode $tNMHDR = DllStructCreate( $tagNMHDR, $lParam ) $hWndFrom = HWnd( DllStructGetData( $tNMHDR, "hWndFrom" ) ) $iCode = DllStructGetData( $tNMHDR, "Code" ) Switch $hWndFrom Case $hLV Switch $iCode Case $LVN_ITEMCHANGED Local $tNMLISTVIEW, $iItem, $aInfo $tNMLISTVIEW = DllStructCreate( $tagNMLISTVIEW, $lParam ) $iItem = DllStructGetData( $tNMLISTVIEW, "Item" ) _GUICtrlListView_SetItemSelected( $hLV, $iItem, False ) Local $aInfo = GUIGetCursorInfo( $hGui ) If $aInfo[2] Then $aInfo = _GUICtrlListView_SubItemHitTest( $hLV, $aInfo[0]-2, $aInfo[1]-2 ) ; Upper left = ( 2, 2 ) If $aInfo[0] > -1 And $aInfo[1] > -1 And $aInfo[0] = $iItem Then If $aHit[0] > -1 Then _ _GUICtrlListView_RedrawItems( $hLV, $aHit[0], $aHit[0] ) If $aHit[0] <> $aInfo[0] Or $aHit[1] <> $aInfo[1] Then $aHit[0] = $aInfo[0] ; Row $aHit[1] = $aInfo[1] ; Col Else $aHit[0] = -1 ; Row $aHit[1] = -1 ; Col EndIf _GUICtrlListView_RedrawItems( $hLV, $iItem, $iItem ) EndIf EndIf Case $NM_CUSTOMDRAW Local $tNMLVCUSTOMDRAW = DllStructCreate( $tagNMLVCUSTOMDRAW, $lParam ) Local $dwDrawStage = DllStructGetData( $tNMLVCUSTOMDRAW, "dwDrawStage" ) Switch $dwDrawStage ; Holds a value that specifies the drawing stage Case $CDDS_PREPAINT ; Before the paint cycle begins Return $CDRF_NOTIFYITEMDRAW ; Notify the parent window of any ITEM-related drawing operations Case $CDDS_ITEMPREPAINT ; Before painting an item Return $CDRF_NOTIFYSUBITEMDRAW ; Notify the parent window of any SUBITEM-related drawing operations Case BitOR( $CDDS_ITEMPREPAINT, $CDDS_SUBITEM ) ; Before painting a subitem Local $dwItemSpec = DllStructGetData( $tNMLVCUSTOMDRAW, "dwItemSpec" ) ; Item index Local $iSubItem = DllStructGetData( $tNMLVCUSTOMDRAW, "iSubItem" ) ; Subitem index Local $uItemState = DllStructGetData( $tNMLVCUSTOMDRAW, "uItemState" ) ; Item state If $dwItemSpec = $aHit[0] Then ; Marked row Switch $iSubItem Case $aHit[1] ; Marked column DllStructSetData( $tNMLVCUSTOMDRAW, "ClrText", 0x000000 ) ; Forecolor black DllStructSetData( $tNMLVCUSTOMDRAW, "clrTextBk", 0xFFFF00 ) ; Backcolor cyan, BGR Case Else ; Other columns If BitAnd( $uItemState, $CDIS_FOCUS ) Then ; Selected row DllStructSetData( $tNMLVCUSTOMDRAW, "ClrText", 0xFFFFFF ) ; Forecolor white DllStructSetData( $tNMLVCUSTOMDRAW, "clrTextBk", 0xCC6600 ) ; Backcolor dark blue, BGR Else DllStructSetData( $tNMLVCUSTOMDRAW, "ClrText", 0x000000 ) ; Forecolor black DllStructSetData( $tNMLVCUSTOMDRAW, "ClrTextBk", 0xFFFFFF ) ; Backcolor white EndIf EndSwitch Else ; Other rows If BitAnd( $uItemState, $CDIS_FOCUS ) Then ; Selected row DllStructSetData( $tNMLVCUSTOMDRAW, "ClrText", 0xFFFFFF ) DllStructSetData( $tNMLVCUSTOMDRAW, "clrTextBk", 0xCC6600 ) Else DllStructSetData( $tNMLVCUSTOMDRAW, "ClrText", 0x000000 ) DllStructSetData( $tNMLVCUSTOMDRAW, "ClrTextBk", 0xFFFFFF ) EndIf EndIf Return $CDRF_NEWFONT ; $CDRF_NEWFONT must be returned after changing font or colors EndSwitch EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFuncEdit: Forgot to take into account that the upper left corner of the listview is ( 2, 2 ) and not ( 0, 0 ). Cleaned up the code. Edited October 14, 2013 by LarsJ 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...
LarsJ Posted October 14, 2013 Share Posted October 14, 2013 Multiple cells. expandcollapse popup#include <WindowsConstants.au3> #include <GUIConstantsEx.au3> #include <GuiListView.au3> ;#include <Array.au3> Opt( "MustDeclareVars", 1 ) Global $hGui, $hLV ; $aMarkedCells is used to store columns with marked cells. Line (index) in $aMarkedCells is stored in ItemParam. When all ; marks in a row are cleared the line in question in $aMarkedCells can be reused. Line (index) is stored in $aNotUsedLines. Global $iMarkedCells = 0, $aMarkedCells[10][4] ; Col 3 = number of marked cells per row Global $iNotUsedLines = 0, $aNotUsedLines[10] MainFunc() Func MainFunc() $hGui = GUICreate( "Mark Cells in Listview", 250, 222, 300, 300 ) Local $idLV = GUICtrlCreateListView( "Column 0|Column 1|Column 2", 2, 2, 250-4, 222-4 ), $idx $hLV = ControlGetHandle( $hGui, "", $idLV ) ; ItemParam will be used to keep track of marked cells ; Create rows with _GUICtrlListView_AddItem and _GUICtrlListView_AddSubItem ; (For rows created with GUICtrlCreateListViewItem ControlID is stored in ItemParam) For $i = 0 To 49 $idx = _GUICtrlListView_AddItem( $hLV, "Cell " & $i & ".0" ) _GUICtrlListView_AddSubItem( $hLV, $idx, "Cell " & $i & ".1", 1 ) _GUICtrlListView_AddSubItem( $hLV, $idx, "Cell " & $i & ".2", 2 ) ;GUICtrlCreateListViewItem( "Cell " & $i & ".0" & "|Cell " & $i & ".1" & "|Cell " & $i & ".2", $idLV ) Next GUIRegisterMsg( $WM_NOTIFY, "WM_NOTIFY" ) GUISetState() While 1 Switch GUIGetMsg() ;Case $GUI_EVENT_SECONDARYDOWN ; _ArrayDisplay( $aMarkedCells, "$aMarkedCells" ) ; _ArrayDisplay( $aNotUsedLines, "$aNotUsedLines" ) Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd EndFunc Func WM_NOTIFY( $hWnd, $iMsg, $wParam, $lParam ) #forceref $hWnd, $iMsg, $wParam Local $tNMHDR, $hWndFrom, $iCode $tNMHDR = DllStructCreate( $tagNMHDR, $lParam ) $hWndFrom = HWnd( DllStructGetData( $tNMHDR, "hWndFrom" ) ) $iCode = DllStructGetData( $tNMHDR, "Code" ) Switch $hWndFrom Case $hLV Switch $iCode Case $LVN_ITEMCHANGED Local $tNMLISTVIEW, $iItem, $iParam, $aInfo $tNMLISTVIEW = DllStructCreate( $tagNMLISTVIEW, $lParam ) $iItem = DllStructGetData( $tNMLISTVIEW, "Item" ) $iParam = DllStructGetData( $tNMLISTVIEW, "Param" ) _GUICtrlListView_SetItemSelected( $hLV, $iItem, False ) $aInfo = GUIGetCursorInfo( $hGui ) If $aInfo[2] Then $aInfo = _GUICtrlListView_SubItemHitTest( $hLV, $aInfo[0]-2, $aInfo[1]-2 ) ; Upper left = ( 2, 2 ) If $aInfo[0] > -1 And $aInfo[1] > -1 And $aInfo[0] = $iItem Then If Not $iParam Then ; First mark in row Local $idxMarkedCells If $iNotUsedLines Then ; Unused lines in $aMarkedCells? $idxMarkedCells = $aNotUsedLines[$iNotUsedLines-1] $iNotUsedLines -= 1 Else ; Allocate a new line in $aMarkedCells? $idxMarkedCells = $iMarkedCells $iMarkedCells += 1 If Mod( $iMarkedCells, 10 ) = 0 Then _ ReDim $aMarkedCells[$iMarkedCells+10][4] EndIf $aMarkedCells[$idxMarkedCells][3] = 1 $aMarkedCells[$idxMarkedCells][$aInfo[1]] = 1 _GUICtrlListView_SetItemParam( $hLV, $iItem, $idxMarkedCells + 1 ) Else $iParam -= 1 If Not $aMarkedCells[$iParam][$aInfo[1]] Then ; Add mark in row $aMarkedCells[$iParam][$aInfo[1]] = 1 $aMarkedCells[$iParam][3] += 1 Else ; Del mark in row $aMarkedCells[$iParam][$aInfo[1]] = 0 $aMarkedCells[$iParam][3] -= 1 If Not $aMarkedCells[$iParam][3] Then _GUICtrlListView_SetItemParam( $hLV, $iItem, 0 ) ; When all marks in a row are cleared store the line (index) from $aMarkedCells in ; $aNotUsedLines. This line can be reused to store marks in another row in the LV. $aNotUsedLines[$iNotUsedLines] = $iParam $iNotUsedLines += 1 If Mod( $iNotUsedLines, 10 ) = 0 Then _ ReDim $aNotUsedLines[$iNotUsedLines+10] EndIf EndIf EndIf _GUICtrlListView_RedrawItems( $hLV, $iItem, $iItem ) EndIf EndIf Case $NM_CUSTOMDRAW Local $tNMLVCUSTOMDRAW = DllStructCreate( $tagNMLVCUSTOMDRAW, $lParam ) Local $dwDrawStage = DllStructGetData( $tNMLVCUSTOMDRAW, "dwDrawStage" ) Switch $dwDrawStage ; Holds a value that specifies the drawing stage Case $CDDS_PREPAINT ; Before the paint cycle begins Return $CDRF_NOTIFYITEMDRAW ; Notify the parent window of any ITEM-related drawing operations Case $CDDS_ITEMPREPAINT ; Before painting an item Return $CDRF_NOTIFYSUBITEMDRAW ; Notify the parent window of any SUBITEM-related drawing operations Case BitOR( $CDDS_ITEMPREPAINT, $CDDS_SUBITEM ) ; Before painting a subitem Local $lItemlParam = DllStructGetData( $tNMLVCUSTOMDRAW, "lItemlParam" ) ; Item param Local $iSubItem = DllStructGetData( $tNMLVCUSTOMDRAW, "iSubItem" ) ; Subitem index Local $uItemState = DllStructGetData( $tNMLVCUSTOMDRAW, "uItemState" ) ; Item state If $lItemlParam Then ; Marked row If $aMarkedCells[$lItemlParam-1][$iSubItem] Then ; Marked column DllStructSetData( $tNMLVCUSTOMDRAW, "ClrText", 0x000000 ) ; Forecolor black If BitAnd( $uItemState, $CDIS_FOCUS ) Then ; Selected row DllStructSetData( $tNMLVCUSTOMDRAW, "clrTextBk", 0x00FFFF ) ; Backcolor yellow, BGR Else DllStructSetData( $tNMLVCUSTOMDRAW, "clrTextBk", 0xFFFF00 ) ; Backcolor cyan, BGR EndIf Else ; Other columns If BitAnd( $uItemState, $CDIS_FOCUS ) Then ; Selected row DllStructSetData( $tNMLVCUSTOMDRAW, "ClrText", 0xFFFFFF ) ; Forecolor white DllStructSetData( $tNMLVCUSTOMDRAW, "clrTextBk", 0xCC6600 ) ; Backcolor dark blue, BGR Else DllStructSetData( $tNMLVCUSTOMDRAW, "ClrText", 0x000000 ) ; Forecolor black DllStructSetData( $tNMLVCUSTOMDRAW, "ClrTextBk", 0xFFFFFF ) ; Backcolor white EndIf EndIf Else ; Other rows If BitAnd( $uItemState, $CDIS_FOCUS ) Then ; Selected row DllStructSetData( $tNMLVCUSTOMDRAW, "ClrText", 0xFFFFFF ) DllStructSetData( $tNMLVCUSTOMDRAW, "clrTextBk", 0xCC6600 ) Else DllStructSetData( $tNMLVCUSTOMDRAW, "ClrText", 0x000000 ) DllStructSetData( $tNMLVCUSTOMDRAW, "ClrTextBk", 0xFFFFFF ) EndIf EndIf Return $CDRF_NEWFONT ; $CDRF_NEWFONT must be returned after changing font or colors EndSwitch EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc Skysnake 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...
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