PC Review


Reply
Thread Tools Rate Thread

Custom draw/highlight color

 
 
Stefano Baldi
Guest
Posts: n/a
 
      7th Dec 2003
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




 
Reply With Quote
 
 
 
 
Ken Tucker [MVP]
Guest
Posts: n/a
 
      8th Dec 2003
Hi,

Maybe this will help
http://www.codeproject.net/cs/miscctrl/customheader.asp

Ken
---------------------
"Stefano Baldi" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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
>
>
>
>



 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
custom color for font color and or background shading color Ben Microsoft Excel Programming 2 5th May 2010 02:32 PM
How can I create a custom highlight color (highight, not shading) =?Utf-8?B?V3J5dGly?= Microsoft Word Document Management 2 26th Oct 2007 06:30 AM
How to change the highlight color and not just the flag color =?Utf-8?B?R3JlZw==?= Microsoft Outlook Discussion 0 4th Jun 2007 02:59 PM
How do I draw a circle around a cell I want to highlight Janev Microsoft Excel New Users 3 18th Sep 2006 09:17 PM
can I select a color from a gif and use the same color to draw a . =?Utf-8?B?QmlsbCBHZWFyeQ==?= Microsoft Powerpoint 2 12th Apr 2005 08:38 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:59 AM.