📄 ch20.htm
字号:
'<br>
End Sub</font></tt> </p>
</blockquote>
<hr>
<p>There are three parts to this one routine. The first part of the code handles the
actual TTS request. Only the first option (<tt><font FACE="Courier">vTxtSpeak</font></tt>)
involves any coding. Since the <tt><font FACE="Courier">MDINOTE</font></tt> project uses a
single text box for user input, this text box is automatically used as the source for all
TTS playback. </p>
<div align="center"><center>
<table BORDERCOLOR="#000000" BORDER="1" WIDTH="80%">
<tr>
<td><b>Note</b></td>
</tr>
<tr>
<td><blockquote>
<p>You'll notice that an index value is used to power this routine. This index value comes
from an array of command buttons or from a menu array. You'll build these later. Control
and menu arrays are excellent ways to build compact code in Visual Basic.</p>
</blockquote>
</td>
</tr>
</table>
</center></div>
<p>The second part of the code handles the enabling and disabling of the menu items on the
edit form. When the edit form is opened, a single menu item is activated (<tt><font
FACE="Courier">Read</font></tt>). Once the TTS engine starts reading, the other options (<tt><font
FACE="Courier">Rewind</font></tt>, <tt><font FACE="Courier">Forward</font></tt>, and <tt><font
FACE="Courier">Stop</font></tt>) are made visible. The third and last part of this routine
makes sure the proper buttons appear on the toolbar. This works the same as the menu
array. You'll build the menu and control array in the next section. </p>
<p>This is the end of the code module for the project. Save the module as <tt><font
FACE="Courier">MDISP.BAS</font></tt> and the project as <tt><font FACE="Courier">MDINOTE.VBP</font></tt>
before continuing. </p>
<h2><a NAME="ModifyingtheMDINoteForms"><font SIZE="5" COLOR="#FF0000">Modifying the </font><tt><font
SIZE="5" COLOR="#FF0000" FACE="Courier">MDINote</font></tt><font SIZE="5" COLOR="#FF0000">
Forms</font></a></h2>
<p>There are two forms in the <tt><font FACE="Courier">MDINOTE</font></tt> project that
must be modified: the <tt><font FACE="Courier">frmMDI</font></tt> form and the <tt><font
FACE="Courier">frmNotePad</font></tt> form. The <tt><font FACE="Courier">frmMDI</font></tt>
form holds the button array and calls the <tt><font FACE="Courier">InitSAPI</font></tt>
and <tt><font FACE="Courier">UnInitSAPI</font></tt> routines. It also has code to handle
the timer controls. The <tt><font FACE="Courier">frmNotePad</font></tt> form holds the
menu array and has code to control the starting and stopping of the TTS engine. </p>
<h3><a NAME="ModifyingtheMDIForm">Modifying the MDI Form</a></h3>
<p>The first task in modifying the <tt><font FACE="Courier">frmMDI</font></tt> form is
adding the button array to the toolbar. You'll use image controls to hold the buttons
views. You'll also need to add code to the <tt><font FACE="Courier">Form_Load</font></tt>
and <tt><font FACE="Courier">Form_Unload</font></tt> events. Finally, you'll add code for
the two timer events. </p>
<h4>Adding the Timer and Button Objects</h4>
<p>First, you need to open the <tt><font FACE="Courier">frmMDI</font></tt> form and add an
array of four image controls and then add two timers. Table 20.1 shows the controls that
need to be added to the form. Refer to Figure 20.1 and Table 20.1 for the placement of the
image controls on the form. </p>
<p><a HREF="f20-1.gif"><b>Figure 20.1 : </b><i>Placing the controls on the frmMDI form.</i></a>
<br>
</p>
<p align="center"><b>Table 20.1. Adding the controls to the <font SIZE="1"
FACE="MCPdigital-B">frmMDI</font> form.</b> </p>
<div align="center"><center>
<table BORDERCOLOR="#000000" BORDER="1" WIDTH="80%">
<tr>
<td><i>Control</i></td>
<td WIDTH="90"><i>Property</i> </td>
<td WIDTH="90"><i>Setting</i></td>
</tr>
<tr>
<td WIDTH="99"><tt><font FACE="Courier">VB.Timer</font></tt> </td>
<td WIDTH="90"><tt><font FACE="Courier">Name</font></tt></td>
<td WIDTH="90">SRTimer</td>
</tr>
<tr>
<td WIDTH="99"> </td>
<td WIDTH="90"><tt><font FACE="Courier">Left</font></tt> </td>
<td WIDTH="90">6180</td>
</tr>
<tr>
<td WIDTH="99"> </td>
<td WIDTH="90"><tt><font FACE="Courier">Top</font></tt> </td>
<td WIDTH="90">0</td>
</tr>
<tr>
<td WIDTH="99"><tt><font FACE="Courier">VB.Timer</font></tt> </td>
<td WIDTH="90"><tt><font FACE="Courier">Name</font></tt></td>
<td WIDTH="90">TTSTimer</td>
</tr>
<tr>
<td WIDTH="99"> </td>
<td WIDTH="90"><tt><font FACE="Courier">Left</font></tt> </td>
<td WIDTH="90">6480</td>
</tr>
<tr>
<td WIDTH="99"> </td>
<td WIDTH="90"><tt><font FACE="Courier">Top</font></tt> </td>
<td WIDTH="90">60</td>
</tr>
<tr>
<td WIDTH="99"><tt><font FACE="Courier">VB.Image</font></tt> </td>
<td WIDTH="90"><tt><font FACE="Courier">Name</font></tt></td>
<td WIDTH="90">ImgVText</td>
</tr>
<tr>
<td WIDTH="99"> </td>
<td WIDTH="90"><tt><font FACE="Courier">Height</font></tt> </td>
<td WIDTH="90">330</td>
</tr>
<tr>
<td WIDTH="99"> </td>
<td WIDTH="90"><tt><font FACE="Courier">Index</font></tt> </td>
<td WIDTH="90">3</td>
</tr>
<tr>
<td WIDTH="99"> </td>
<td WIDTH="90"><tt><font FACE="Courier">Left</font></tt> </td>
<td WIDTH="90">3120</td>
</tr>
<tr>
<td WIDTH="99"> </td>
<td WIDTH="90"><tt><font FACE="Courier">Stretch</font></tt> </td>
<td WIDTH="90">-1 'True</td>
</tr>
<tr>
<td WIDTH="99"> </td>
<td WIDTH="90"><tt><font FACE="Courier">Top</font></tt> </td>
<td WIDTH="90">0</td>
</tr>
<tr>
<td WIDTH="99"> </td>
<td WIDTH="90"><tt><font FACE="Courier">Visible</font></tt> </td>
<td WIDTH="90">0 'False</td>
</tr>
<tr>
<td WIDTH="99"> </td>
<td WIDTH="90"><tt><font FACE="Courier">Width</font></tt> </td>
<td WIDTH="90">375</td>
</tr>
<tr>
<td WIDTH="99"><tt><font FACE="Courier">VB.Image</font></tt> </td>
<td WIDTH="90"><tt><font FACE="Courier">Name</font></tt></td>
<td WIDTH="90">ImgVText</td>
</tr>
<tr>
<td WIDTH="99"> </td>
<td WIDTH="90"><tt><font FACE="Courier">Height</font></tt> </td>
<td WIDTH="90">330</td>
</tr>
<tr>
<td WIDTH="99"> </td>
<td WIDTH="90"><tt><font FACE="Courier">Index</font></tt> </td>
<td WIDTH="90">2</td>
</tr>
<tr>
<td WIDTH="99"> </td>
<td WIDTH="90"><tt><font FACE="Courier">Left</font></tt> </td>
<td WIDTH="90">2760</td>
</tr>
<tr>
<td WIDTH="99"> </td>
<td WIDTH="90"><tt><font FACE="Courier">Stretch</font></tt> </td>
<td WIDTH="90">-1 'True</td>
</tr>
<tr>
<td WIDTH="99"> </td>
<td WIDTH="90"><tt><font FACE="Courier">Top</font></tt> </td>
<td WIDTH="90">0</td>
</tr>
<tr>
<td WIDTH="99"> </td>
<td WIDTH="90"><tt><font FACE="Courier">Visible</font></tt> </td>
<td WIDTH="90">0 'False</td>
</tr>
<tr>
<td WIDTH="99"> </td>
<td WIDTH="90"><tt><font FACE="Courier">Width</font></tt> </td>
<td WIDTH="90">375</td>
</tr>
<tr>
<td WIDTH="99"><tt><font FACE="Courier">VB.Image</font></tt> </td>
<td WIDTH="90"><tt><font FACE="Courier">Name</font></tt></td>
<td WIDTH="90">ImgVText</td>
</tr>
<tr>
<td WIDTH="99"> </td>
<td WIDTH="90"><tt><font FACE="Courier">Height</font></tt> </td>
<td WIDTH="90">330</td>
</tr>
<tr>
<td WIDTH="99"> </td>
<td WIDTH="90"><tt><font FACE="Courier">Index</font></tt> </td>
<td WIDTH="90">1</td>
</tr>
<tr>
<td WIDTH="99"> </td>
<td WIDTH="90"><tt><font FACE="Courier">Left</font></tt> </td>
<td WIDTH="90">2400</td>
</tr>
<tr>
<td WIDTH="99"> </td>
<td WIDTH="90"><tt><font FACE="Courier">Stretch</font></tt> </td>
<td WIDTH="90">-1 'True</td>
</tr>
<tr>
<td WIDTH="99"> </td>
<td WIDTH="90"><tt><font FACE="Courier">Top</font></tt> </td>
<td WIDTH="90">0</td>
</tr>
<tr>
<td WIDTH="99"> </td>
<td WIDTH="90"><tt><font FACE="Courier">Visible</font></tt> </td>
<td WIDTH="90">0 'False</td>
</tr>
<tr>
<td WIDTH="99"> </td>
<td WIDTH="90"><tt><font FACE="Courier">Width</font></tt> </td>
<td WIDTH="90">375</td>
</tr>
<tr>
<td WIDTH="99"><tt><font FACE="Courier">VB.Image</font></tt> </td>
<td WIDTH="90"><tt><font FACE="Courier">Name</font></tt></td>
<td WIDTH="90">ImgVText</td>
</tr>
<tr>
<td WIDTH="99"> </td>
<td WIDTH="90"><tt><font FACE="Courier">Height</font></tt> </td>
<td WIDTH="90">330</td>
</tr>
<tr>
<td WIDTH="99"> </td>
<td WIDTH="90"><tt><font FACE="Courier">Index</font></tt> </td>
<td WIDTH="90">0</td>
</tr>
<tr>
<td WIDTH="99"> </td>
<td WIDTH="90"><tt><font FACE="Courier">Left</font></tt> </td>
<td WIDTH="90">2040</td>
</tr>
<tr>
<td WIDTH="99"> </td>
<td WIDTH="90"><tt><font FACE="Courier">Stretch</font></tt> </td>
<td WIDTH="90">-1 'True</td>
</tr>
<tr>
<td WIDTH="99"> </td>
<td WIDTH="90"><tt><font FACE="Courier">Top</font></tt> </td>
<td WIDTH="90">0</td>
</tr>
<tr>
<td WIDTH="99"> </td>
</tr>
</table>
</center></div>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -