📄 color_edit.shtml.htm
字号:
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
<meta name="author" content="zafir anjum">
<title>edit controls - table of contents</title>
<meta name="description" content="source code for various windows controls">
<meta name="keywords" content="mfc source code edit controls">
</head>
<body background="../di2001.jpg"
tppabs="http://www.codeguru.com/fancyhome/back.gif" bgcolor="#ffffff">
<h3 align="center"><font color="#aoao99">keyword coloring edit control</font></h3>
<hr>
<p>this article was contributed by <a href="mailto:keithr@europa.com">keith rule</a>. </p>
<p><a href="color_edit.zip" tppabs="http://www.codeguru.com/editctrl/color_edit.zip">download</a>
the project. 238kb. note that this is still work in progress and keith is open to
suggestions. this project requires vc++ 5.0 or later, don't expect to have an easy time of
build this project under vc++ 4.2 or earlier. </p>
<font face="arial" size="4"><b>
<p>about the project</p>
</b></font>
<p>this project implements a simple color encoding text editor, which is similar to the
editor found in visual c++ or visual basic. it allows the developer to configure the
encoding of keywords and comments. this project is an mdi application.</p>
<p><img src="color_edit.gif" tppabs="http://www.codeguru.com/editctrl/color_edit.gif"
width="646" height="489"></p>
<font face="arial" size="4"><b>
<p>defining the color encoding</p>
</b></font>
<p>the encoding is defined in the constructor for the <i>cdocument</i> derived class <i>ccoloreditdoc</i>.
the default configuration looks like the following:
<dir>
<dir>
<font color="#990000"><pre>ccoloreditdoc::ccoloreditdoc() : cundo(25, 64*1024)
{
m_text.addcomment(_t("/*"), _t("*/"));
m_text.addcomment(_t("//"), _t("\n"));
m_text.addkeyword(_t("static"));
m_text.addkeyword(_t("char"));
m_text.addkeyword(_t("short"));
m_text.addkeyword(_t("unsigned"));
.
.
.
}</pre>
</dir>
</dir>
</font>
<p>the definitions for defining a keyword or comment are as follows.</p>
<pre> <font color="#990000">// color coding
bool addkeyword(const cstring& keyword, colorref color = rgb(0, 0, 200));
bool addcomment(const cstring& begin = _t("//"), const cstring& end = _t("\n"), colorref color = rgb(0, 200, 0)); </pre>
</font><font size="2">
<p>notice that you can specify a unique color for every keyword and comment definition.</p>
</font><font face="arial" size="4"><b>
<p>goals of the project</p>
</b></font><font size="2">
<p>i wrote this project for three reasons.
<ol>
<li>i wanted to try out several of the classes found on the <a
href="http://www.codeguru.com" tppabs="http://www.codeguru.com/">www.codeguru.com</a>
webpage.</li>
<li>i wanted try out a real example of a worker thread.</li>
<li>i wanted to have a color encoding text editor in my toolbox of royalty free source code.</li>
</ol>
<p>however, this project has turned into my toolbox. i've placed many often used
techniques in this project such as printing support, cut/copy/paste support, undo/redo,
flicker free updates and so forth. i've found myself using the project as a place to pull
working code out into other projects. </p>
</font><font face="arial" size="4"><b>
<p>new features</p>
</b></font><font size="2">
<p>dragging during a selection will now scroll the window. i've fixed several problems and
have one know unresolved bug. color encoding quotes is now supported.</p>
</font><font face="arial" size="4"><b>
<p>known bugs</p>
</b></font><font size="2">
<p>the editor won't scroll beyond 1500 lines on win95. i suspect this is due to a
limitation in the size of the gdi area in mm_text. if anyone has some ideas for working
around this, please let me know.</p>
</font><font face="arial" size="4"><b>
<p>classes used</p>
</b></font><font size="2">
<p>this project uses the following classes found at www.codeguru.com. </p>
</font><tt><i><b>
<pre>
cundo</b></i> - undo/redo for <i>cdocument</i> derived classes
<i><b>cmemdc</b></i> - double buffering class for drawing
<i><b>csplash255wnd</b></i> - 256 color splash screen support
<i><b>ctoolbarex</b></i> - flat toolbar support
<i><b>cregexp</b></i> - regular expression matching
<i><b>cstringex</b></i> - extended <i>cstring
<b>cprogressbar </b></i>- a progress indicator on the status bar.
<i><b>cclockstatusbar</b> </i>- adds a clock to the status bar.
<i><b>ccreditstatic </b></i>- scrolls text in a static text field.</pre>
</tt><font size="2">
<p>in addition it defines the class:
<dir>
<i><b><p>ccolorstring</b></i> - </font><font face="courier new" size="2"><i>cstring</i>
plus rule based color encoding</font><font size="2"> </p>
</dir>
<p>i'm open to adding change request to my todo list for this application. feel free to
contact me at <a href="mailto:keithr@europa.com">keithr@europa.com</a> with suggestions,
fixes, or questions.</p>
</font>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -