473,397 Members | 2,068 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

Custom draw/highlight color

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.NOTIFYITEMDRA W)

Case (ApiEnum.CustomDrawDrawStage.ITEMPREPAINT)

'Ask to notify postPaint and subitem

m.Result = New
IntPtr(ApiEnum.CustomDrawReturnFlags.NOTIFYSUBITEM DRAW 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


Nov 20 '05 #1
1 2169
Hi,

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

Ken
---------------------
"Stefano Baldi" <sb**********@aruba.it> wrote in message
news:OH**************@TK2MSFTNGP12.phx.gbl...
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.NOTIFYITEMDRA W)

Case (ApiEnum.CustomDrawDrawStage.ITEMPREPAINT)

'Ask to notify postPaint and subitem

m.Result = New
IntPtr(ApiEnum.CustomDrawReturnFlags.NOTIFYSUBITEM DRAW 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

Nov 20 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Steve | last post by:
I have created a transparent custom drawn treeview in c#(using lots of native code as well) that has a bitmap for its background. As well as that, I have created a custom highlight that is a...
0
by: Piotrek Stachowicz | last post by:
Hi, Just one more question about owner draw menus. How can I get rid of this nasty standard highlight bar, and instead draw it by myself? When I receive the drawItem event I can check whether the...
2
by: Benny Raymond | last post by:
More problems with this... When I run this code, the main form returns an invalid cast exception as it's executing the line "TreeNode n = (TreeNode) this.Nodes;" Does anyone know what would...
5
by: Brian Keating EI9FXB | last post by:
Hello there, Wonder can anyone point me in the correct direction? I would like to change the standard list view control so that i can have alternated rows in a different color, i.e. white grey...
4
by: Jason Perry | last post by:
Hey Gang, I'm writing my first custom component and am trying to add the text that describes the custom properties. I'm talking about the text that displays in the property inspector (design...
15
by: Tinus | last post by:
Hello all, I've created a custom control that draws a monthly schedule (using the Draw function in C#). Basically it draws 31 boxes and writes the day number in every box. This works...
4
by: Alvo von Cossel I | last post by:
hi, i have been asked to make a good-looking app for a friend. i have an options form with a big tabstrip in it. 1. how can i customize it e.g. change from the standard system style...
3
by: Arnold the Aardvark | last post by:
I am creating a custom draw tree view based on CTreeCtrl. When the control is re-sized the background is blanked completely, resulting in a horrible flicker. I've seen various suggestions...
1
by: Robin Tucker | last post by:
Hi ppl, My owner draw list box controls do not "refresh" old selected items when a new selection is made. This means that as you click to make selections, the previously selected items stay...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.