⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 syntax_coloring.shtml.htm

📁 一套比较全的编辑框控制教程。。。附源代码。
💻 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 &quot;coloreditwnd&quot; is the
editor and &quot;colorize&quot; 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 = &quot;keywords.ini&quot;;<br>
  bool casesensitive = false;<br>
  long pchardx = 10;<br>
  long pchardy = 16;<br>
  long ptabsize = 4;<br>
  int pfontsize = 120;<br>
  cstring pfontname = &quot;courier new&quot;;</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-&gt;showwindow(sw_show);</font></p>
</blockquote>

<p>use the methods &quot;loadtext&quot; and &quot;unloadtext&quot; 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 '&amp;' 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 + -