?? syntax_coloring.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"><!-- article title -->syntax coloring text edit window class </font></h3>
<hr>
<!-- author and contact details -->
<p>this article was contributed by <!-- author email --><a href="mailto:rmore@cri.com"><!-- author name -->randy more</a>. <!-- sample image - gif or jpg --> </p>
<p><img src="syntax_coloring.gif"
tppabs="http://www.codeguru.com/editctrl/syntax_coloring.gif" width="357" height="360"> <!-- text / source code --> </p>
<p>this class provides a cwnd derived editor that provides syntax coloring based on a
keyword file you provide. it also supports auto-indent and retab. it is much faster than
using cricheditview to do the same thing, but it flickers a little and does not support
any additional formatting.</p>
<p>there are two classes that must be added to a project "coloreditwnd" is the
editor and "colorize" is the parser. the included project shows how to add the
window.</p>
<p>add the window as follows:</p>
<p>add a member variable which is a pointer to a coloreditwnd (in this example ccolorwnd)</p>
<p>after initialization of the parent window instantiate the color edit window as follows:</p>
<blockquote>
<font size="-1" color="#990000"><p>crect client;<br>
getclientrect(client);<br>
cstring keywordsfile = "keywords.ini";<br>
bool casesensitive = false;<br>
long pchardx = 10;<br>
long pchardy = 16;<br>
long ptabsize = 4;<br>
int pfontsize = 120;<br>
cstring pfontname = "courier new";</font> </p>
<p><font size="-1" color="#990000">ccolorwnd = new coloreditwnd(</font></p>
<blockquote>
<font size="-1" color="#990000"><p>this, //parent window<br>
client, //initial size and position<br>
idc_color_wnd, //id value<br>
keywordsfile, //keywords file<br>
casesensitive, //case sensitive ? <br>
pchardx, //width of each character<br>
pchardy, //height of each character<br>
ptabsize, //size of a tab in characters<br>
pfontsize, //font size * 10 (i.e. 100 = 10)<br>
pfontname); //the font name</font></p>
</blockquote>
<p><font size="-1" color="#990000">ccolorwnd->showwindow(sw_show);</font></p>
</blockquote>
<p>use the methods "loadtext" and "unloadtext" to control the text in
the edit window. .</p>
<p><font size="+1"><b>keyword file</b></font></p>
<p>the keyword file is a simple text file with each word on a separate line. individual
words will appear as keywords (blue), words preceded by '&' are user defined functions
(red). if a word is preceded by '+' it causes an auto-indent, '-' causes an auto-unindent.</p>
<p>the example project includes a keyword file for vba.</p>
<p><font size="+1"><b>limitations</b></font></p>
<p>there is some flickering in the current version.</p>
<!-- zipped source -->
<p><!-- first the filename (zip files) --><a href="syntax_coloring_project.zip"
tppabs="http://www.codeguru.com/editctrl/syntax_coloring_project.zip">download source -
41kb</a> <!-- posted / update date mm/dd/yy - add to the list --> </p>
<p>date posted: 09 may 1998 <!--comments--> </p>
</body>
</html>
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -