如何在单个列表视图项中将不同的颜色应用于单个字符 [英] How to apply different colors to individual characters in single listview item

查看:67
本文介绍了如何在单个列表视图项中将不同的颜色应用于单个字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的朋友们,



我们如何在单个列表视图项目中为单个字符应用不同的颜色。

我使用win32 sdk平台widows xp environment.Please帮我解决方案





祝你好运,

Suji

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

推荐答案

解决方案的第一步是研究自定义绘制控件并使自己成为自定义绘制专用列表控件。

第二步步骤是以单一颜色在您自己的代码中绘制列表视图项的文本,并将正确的标志返回到基础列表控件,以便它不再绘制项目文本,它只是留给您。 br />
第三步可能是最困难的,你不能简单地一次绘制一个字符,因为字距调整,kashidas和其他字符间的形成。为了绘制不同颜色的单个字符,您需要以不同的颜色绘制整个字符串的多个副本,然后将它们组合在一起。

字符串应该绘制到屏幕外位图上下文然后从单独的位图复制到列表控制设备上下文而不是绘制字符串。



看起来这可能会产生太差的性能,但只要你没有没有太多的颜色,只有在每种颜色都能正常工作的情况下才能渲染每个颜色。我过去实现了类似的功能。
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.


这篇关于如何在单个列表视图项中将不同的颜色应用于单个字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆