Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: VC6 WinXP Win32 SDK
Dear Friends,
 
How can we applying different colors to individual characters in single listview item.
I use win32 sdk platform in widows xp environment.Please help me to get the solution
 

Best regards,
Suji
Posted 1-Jun-13 4:32am

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

The first step to a solution is to research 'Custom Draw' controls and make yourself a Custom Draw specialized List Control.
The second step is to draw the text of the list view items in your own code in a single colour and return the correct flags to the underlying List Control so that it doesn't draw the item text anymore, it just leaves it to you.
The third step is probably the hardest, you can't simply draw text one character at a time because of kerning, kashidas and other intercharacter shaping. In order to draw individual characters in a different colour you need to draw multiple copies of the whole string in different colours and then combine them together.
The strings should be drawn to offscreen bitmap contexts and then sections from separate bitmaps copied to the List Control device context in place of drawing the string.
 
It may seem as if this will produce too poor performance but as long as you don't have too many colours and you only render each string in each colour once it will work fine. I have implemented similar in the past.
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 451
1 Afzaal Ahmad Zeeshan 184
2 /\jmot 176
3 Marcin Kozub 150
4 Sergey Alexandrovich Kryukov 150
0 OriginalGriff 8,344
1 Sergey Alexandrovich Kryukov 7,407
2 DamithSL 5,634
3 Maciej Los 5,024
4 Manas Bhardwaj 4,986


Advertise | Privacy | Mobile
Web03 | 2.8.1411023.1 | Last Updated 1 Jun 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100