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

📄 lion-tutorial33.htm

📁 内有一些代码
💻 HTM
📖 第 1 页 / 共 5 页
字号:
<html><head><title>Iczelion's Win32 Assembly Tutorial 33: RichEdit Control: Basics</title><meta http-equiv="Content-Type" content="text/html; charset="></head><body bgcolor="#FFFFFF"><h1 align="center"><font face="Tahoma" color="#0000CC">Tutorial 33: RichEdit Control:   Basics</font></h1><p align="left"><font face="Tahoma" size="-1">There are lots of request on tutorials   about RichEdit controls. Finally I have played with it enough to think I can   write tutorials about it. So here it is: the first RichEdit tutorial. The tutorials   will describe nearly everything there is to know about RichEdit control or at   least as much as I know it. The amount of information is rather large so I divide   it into several parts, this tutorial being the first part. In this tutorial,   you'll learn what a RichEdit control is, how to create it and how to load/save   data to/from it.</font></p><p align="left"><font face="Tahoma" size="-1">Download <a href="files/tut33.zip">the   example</a>.</font></p><h3 align="left"><font face="Times New Roman, Times, serif" color="#3333CC">Theory</font></h3><p align="left"><font face="Tahoma" size="-1">A richedit control can be thought   of as a souped-up edit control. It provides many desirable features that are   lacking from the plain simple edit control, for example, the ability to use   multiple font face/size, multiple-level undo/redo, search-for-text operation,   OLE-embedded objects, drag-and-drop editing support, etc. Since the richedit   control has so many features, it's stored in a separate DLL. This also means   that, to use it, you can't just call <font color="#336600"><b>InitCommonControls</b></font>   like other common controls. You have to call <font color="#336600"><b>LoadLibrary</b></font>   to load the richedit DLL.</font></p><p align="left"><font face="Tahoma" size="-1">The problem is that there are three   versions of richedit control up till now. Version 1,2, and 3. The table below   shows you the name of the DLL for each version.</font></p><table align="center" border="1">  <tr bgcolor="#CCFFCC">     <th nowrap><font face="MS Sans Serif" size="-1">DLL Name</font></th>    <th nowrap><font face="MS Sans Serif" size="-1">RichEdit version</font></th>    <th nowrap><font face="MS Sans Serif" size="-1">Richedit Class Name</font></th>  </tr>  <tr bgcolor="#FFFFCC">     <th nowrap><font face="MS Sans Serif" size="-1" color="#000000">Riched32.dll</font></th>    <th nowrap><font face="MS Sans Serif" size="-1" color="#000000">1.0</font></th>    <th nowrap><font face="MS Sans Serif" size="-1">RICHEDIT</font></th>  </tr>  <tr bgcolor="#FFFFCC">     <th nowrap><font face="MS Sans Serif" size="-1" color="#000000">RichEd20.dll</font></th>    <th nowrap><font face="MS Sans Serif" size="-1" color="#000000">2.0</font></th>    <th nowrap><font face="MS Sans Serif" size="-1">RICHEDIT20A</font></th>  </tr>  <tr bgcolor="#FFFFCC">     <th nowrap><font face="MS Sans Serif" size="-1" color="#000000">RichEd20.dll</font></th>    <th nowrap><font face="MS Sans Serif" size="-1" color="#000000">3.0</font></th>    <th nowrap><font face="MS Sans Serif" size="-1">RICHEDIT20A</font></th>  </tr></table><p align="left"><font face="Tahoma" size="-1">You can notice that richedit version   2 and 3 use the same DLL name. They also use the same class name! This can pose   a problem if you want to use specific features of richedit 3.0. Up to now, I   haven't found an official method of differentiating between version 2.0 and   3.0. However, there is a workaround which works ok, I'll show you later.</font></p><pre align="left"><font face="Tahoma"><b><font color="#660066">.data</font></b></font><font color="#660066"><b><font face="Tahoma">   RichEditDLL db &quot;RichEd20.dll&quot;,0<br>	.....<br>.data?<br>	hRichEditDLL dd ?<br>.code<br>	<font color="#006600">invoke LoadLibrary,addr RichEditDLL<br>	mov hRichEditDLL,eax</font><br>	......<br>	<font color="#006600">invoke FreeLibrary,hRichEditDLL</font></font></b></font><font color="#660066"><b><font face="Tahoma"><font color="#006600"></font></font></b></font></pre><p align="left"><font face="Tahoma" size="-1">When the richedit dll is loaded,   it registers the RichEdit window class. Thus it's imperative that you load the   DLL before you create the control. The names of the richedit control classes   are also different. Now you may have a question: how do I know which version   of richedit control should I use? Using the latest version is not always appropriate   if you don't require the extra features. So below is the table that shows the   features provided by each version of richedit control.</font></p><table cellpadding="3" align="center" border="1">  <tr bgcolor="#CCFFCC">     <th nowrap><font face="MS Sans Serif" size="-1">Feature</font></th>    <th nowrap><font face="MS Sans Serif" size="-1">Version 1.0</font></th>    <th nowrap><font face="MS Sans Serif" size="-1">Version 2.0</font></th>    <th nowrap><font face="MS Sans Serif" size="-1">Version 3.0</font></th>  </tr>  <tr bgcolor="#FFFFCC">     <td><font face="MS Sans Serif" size="-1">selection bar</font></td>    <td>       <div align="center"><font face="MS Sans Serif" size="-1">x</font></div>    </td>    <td>       <div align="center"><font face="MS Sans Serif" size="-1">x</font></div>    </td>    <td>       <div align="center"><font face="MS Sans Serif" size="-1">x</font></div>    </td>  </tr>  <tr bgcolor="#FFFFCC">     <td><font face="MS Sans Serif" size="-1">unicode editing</font></td>    <td>       <div align="center"><font face="MS Sans Serif" size="-1"></font></div>    </td>    <td>       <div align="center"><font face="MS Sans Serif" size="-1">x</font></div>    </td>    <td>       <div align="center"><font face="MS Sans Serif" size="-1">x</font></div>    </td>  </tr>  <tr bgcolor="#FFFFCC">     <td><font face="MS Sans Serif" size="-1">character/paragraph formatting</font></td>    <td>       <div align="center"><font face="MS Sans Serif" size="-1">x</font></div>    </td>    <td>       <div align="center"><font face="MS Sans Serif" size="-1">x</font></div>    </td>    <td>       <div align="center"><font face="MS Sans Serif" size="-1">x</font></div>    </td>  </tr>  <tr bgcolor="#FFFFCC">     <td><font face="MS Sans Serif" size="-1">search for text</font></td>    <td>       <div align="center"><font face="MS Sans Serif" size="-1">forward</font></div>    </td>    <td>       <div align="center"><font face="MS Sans Serif" size="-1">forward/backward</font></div>    </td>    <td>       <div align="center"><font face="MS Sans Serif" size="-1">forward/backward</font></div>    </td>  </tr>  <tr bgcolor="#FFFFCC">     <td><font face="MS Sans Serif" size="-1">OLE embedding</font></td>    <td>       <div align="center"><font face="MS Sans Serif" size="-1">x</font></div>    </td>    <td>       <div align="center"><font face="MS Sans Serif" size="-1">x</font></div>    </td>    <td>       <div align="center"><font face="MS Sans Serif" size="-1">x</font></div>    </td>  </tr>  <tr bgcolor="#FFFFCC">     <td><font face="MS Sans Serif" size="-1">Drag and drop editing</font></td>    <td>       <div align="center"><font face="MS Sans Serif" size="-1">x</font></div>    </td>    <td>       <div align="center"><font face="MS Sans Serif" size="-1">x</font></div>    </td>    <td>       <div align="center"><font face="MS Sans Serif" size="-1">x</font></div>    </td>  </tr>  <tr bgcolor="#FFFFCC">     <td><font face="MS Sans Serif" size="-1">Undo/Redo</font></td>    <td>       <div align="center"><font face="MS Sans Serif" size="-1">single-level</font></div>    </td>    <td>       <div align="center"><font face="MS Sans Serif" size="-1">multi-level</font></div>    </td>    <td>       <div align="center"><font face="MS Sans Serif" size="-1">multi-level</font></div>    </td>  </tr>  <tr bgcolor="#FFFFCC">     <td><font face="MS Sans Serif" size="-1">automatic URL recognition</font></td>    <td>       <div align="center"></div>    </td>    <td>       <div align="center"><font face="MS Sans Serif" size="-1">x</font></div>    </td>    <td>       <div align="center"><font face="MS Sans Serif" size="-1">x</font></div>    </td>  </tr>  <tr bgcolor="#FFFFCC">     <td><font face="MS Sans Serif" size="-1">Accelerator key support</font></td>    <td>       <div align="center"><font face="MS Sans Serif" size="-1"></font></div>    </td>    <td>       <div align="center"><font face="MS Sans Serif" size="-1">x</font></div>    </td>    <td>       <div align="center"><font face="MS Sans Serif" size="-1">x</font></div>    </td>  </tr>  <tr bgcolor="#FFFFCC">     <td><font face="MS Sans Serif" size="-1">Windowless operation</font></td>    <td>       <div align="center"><font face="MS Sans Serif" size="-1"></font></div>    </td>    <td>       <div align="center"><font face="MS Sans Serif" size="-1">x</font></div>    </td>    <td>       <div align="center"><font face="MS Sans Serif" size="-1">x</font></div>    </td>  </tr>  <tr bgcolor="#FFFFCC">     <td><font face="MS Sans Serif" size="-1">Line break</font></td>    <td>       <div align="center"><font face="MS Sans Serif" size="-1">CRLF</font></div>    </td>    <td>       <div align="center"><font face="MS Sans Serif" size="-1">CR only</font></div>    </td>    <td>       <div align="center"><font face="MS Sans Serif" size="-1">CR only (can emulate         version 1.0)</font></div>    </td>  </tr>  <tr bgcolor="#FFFFCC">     <td><font face="MS Sans Serif" size="-1">Zoom</font></td>    <td>       <div align="center"><font face="MS Sans Serif" size="-1"></font></div>    </td>    <td>       <div align="center"><font face="MS Sans Serif" size="-1"></font></div>    </td>    <td>       <div align="center"><font face="MS Sans Serif" size="-1">x</font></div>    </td>  </tr>  <tr bgcolor="#FFFFCC">     <td><font face="MS Sans Serif" size="-1">Paragraph numbering</font></td>    <td>       <div align="center"><font face="MS Sans Serif" size="-1"></font></div>    </td>    <td>       <div align="center"><font face="MS Sans Serif" size="-1"></font></div>    </td>    <td>       <div align="center"><font face="MS Sans Serif" size="-1">x</font></div>    </td>  </tr>  <tr bgcolor="#FFFFCC">     <td><font face="MS Sans Serif" size="-1">simple table</font></td>    <td>       <div align="center"><font face="MS Sans Serif" size="-1"></font></div>    </td>    <td>       <div align="center"><font face="MS Sans Serif" size="-1"></font></div>    </td>    <td>       <div align="center"><font face="MS Sans Serif" size="-1">x</font></div>    </td>  </tr>  <tr bgcolor="#FFFFCC">     <td><font face="MS Sans Serif" size="-1">normal and heading styles</font></td>    <td>       <div align="center"><font face="MS Sans Serif" size="-1"></font></div>    </td>    <td>       <div align="center"><font face="MS Sans Serif" size="-1"></font></div>    </td>    <td>       <div align="center"><font face="MS Sans Serif" size="-1">x</font></div>    </td>  </tr>  <tr bgcolor="#FFFFCC">     <td><font face="MS Sans Serif" size="-1">underline coloring</font></td>    <td>       <div align="center"><font face="MS Sans Serif" size="-1"></font></div>    </td>    <td>       <div align="center"><font face="MS Sans Serif" size="-1"></font></div>    </td>    <td>       <div align="center"><font face="MS Sans Serif" size="-1">x</font></div>    </td>  </tr>  <tr bgcolor="#FFFFCC">     <td><font face="MS Sans Serif" size="-1">hidden text</font></td>    <td>       <div align="center"><font face="MS Sans Serif" size="-1"></font></div>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -