Custom draw/highlight color

  • Thread starter Thread starter Stefano Baldi
  • Start date Start date
S

Stefano Baldi

I'm trying to change highlight color af a ListItem
Here's my function


Private Sub ListViewCustomDraw(ByRef m As System.Windows.Forms.Message)

Dim lvcd As NMLVCUSTOMDRAW

Dim oListViewItemEx As ListViewItemEx

'Get lvcd structure

lvcd = CType(m.GetLParam(lvcd.GetType), NMLVCUSTOMDRAW)

Select Case lvcd.nmcd.dwDrawStage

Case ApiEnum.CustomDrawDrawStage.PREPAINT

m.Result = New
IntPtr(ApiEnum.CustomDrawReturnFlags.NOTIFYITEMDRAW)

Case (ApiEnum.CustomDrawDrawStage.ITEMPREPAINT)

'Ask to notify postPaint and subitem

m.Result = New
IntPtr(ApiEnum.CustomDrawReturnFlags.NOTIFYSUBITEMDRAW Or
ApiEnum.CustomDrawReturnFlags.NOTIFYPOSTPAINT)

Case (ApiEnum.CustomDrawDrawStage.ITEMPREPAINT Or
ApiEnum.CustomDrawDrawStage.SUBITEM)

oListViewItemEx = MyBase.Items(lvcd.nmcd.dwItemSpec)

If Not oListViewItemEx Is Nothing Then

If oListViewItemEx.Selected Then

lvcd.clrTextBk = 15718086

'Don't draw as selected

lvcd.nmcd.uItemState = ApiEnum.CustomDrawItemState.GRAYED

m.Result = New IntPtr(ApiEnum.CustomDrawReturnFlags.NEWFONT)

End If

End If

Case ApiEnum.CustomDrawDrawStage.ITEMPOSTPAINT

DrawItemLines(lvcd)

m.Result = New IntPtr(ApiEnum.CustomDrawReturnFlags.DODEFAULT)


End Select

End Sub





The problem is both lvcd.clrTextBk and lvcd.nmcd.uItemState have no effect

Can't understand why. I did something like that in vb6 without problems



Thanks

Stefano Baldi
 
Back
Top