多色编辑控件,如何实现? [英] Multi Color Edit Control, how can I implement this?!

查看:87
本文介绍了多色编辑控件,如何实现?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好:)

我有一个基于对话框的应用程序,除其他外,该应用程序具有很长的单行编辑控件.当用户输入内容时,它应该以一种颜色(蓝色)显示数字,一些符号应该以另一种颜色(让我们说红色)显示,另外我还有一组关键字,它们的颜色也不同(绿色).所有其余测试应使用默认的黑色.

事实证明,这项任务比我想象的要复杂得多.我尝试编写自己的CEdit 派生控件,但没有按我预期的那样工作,然后我尝试了CRichEditCtrl ,它具有所有的功能,但是它具有Win2000样式的边框,看上去很丑,因为我还有其他编辑控件接近于此,对于具有不同边框的特定编辑控件来说似乎真的不合适.

我可以从头开始编写CWnd派生的编辑控件,并将其附加到无边框的静态控件资源上,并在我的OnPaint中绘制边框,但是该解决方案对我来说看起来非常笨拙...

请给我一个建议,我该怎么办? :)

Hi All :)

I have a dialog based application that has a long single line edit control among other things. As the user types in, it should display numbers in one color (blue), some symbols should be in another color (lets say red), and also I have a set of keywords that have ot be in a different color (green). all the rest of the test should be in the default black color.

This task proved to be much more complex than I thought. I tried to write my own CEdit derived control but it didn''t worck as I expected, then I tried CRichEditCtrl which had all the signs to work but it has that Win2000 style border which looks ugly, since I have other edit controls close to this one and it would look really inappropriate for this particular edit control to have a different border.

I can write a CWnd derived edit control from scratch and attach it to a static control resource without border and draw the border in my OnPaint, but that solution looks very inelegant and sloppy to me...

Please give me an advise what should I do? :)
Thanks a lot in advance!

推荐答案

这里有一个很好的用户控件,它具有以下要求:

着色编辑控件 [
There a nice user control here with that requirements:

Colorizing edit control[^].


这篇关于多色编辑控件,如何实现?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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