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

📄 333-338.html

📁 WindowsCE.[Essential Windows CE Application Programming].Jon Wiley & Son.zip
💻 HTML
📖 第 1 页 / 共 2 页
字号:
Publication Date: 03/01/99
</FONT>
<P>
<form name="Search" method="GET" action="http://search.earthweb.com/search97/search_redir.cgi">

<INPUT TYPE="hidden" NAME="Action" VALUE="Search">
<INPUT TYPE="hidden" NAME="SearchPage" VALUE="http://search.earthweb.com/search97/samples/forms/srchdemo.htm">
<INPUT TYPE="hidden" NAME="Collection" VALUE="ITK">
<INPUT TYPE="hidden" NAME="ResultTemplate" VALUE="itk-simple-intrabook.hts">
<INPUT TYPE="hidden" NAME="ViewTemplate" VALUE="view.hts">

<font face="arial, helvetica" size=2><b>Search this book:</b></font><br>
<INPUT NAME="queryText" size=50 VALUE="">&nbsp;<input type="submit" name="submitbutton" value="Go!">
<INPUT type=hidden NAME="section_on" VALUE="on">
<INPUT type=hidden NAME="section" VALUE="http://www.itknowledge.com/reference/standard/0471327476/">

</form>


<!-- Empty Reference Subhead -->

<!--ISBN=0471327476//-->
<!--TITLE=Essential Windows CE Application Programming//-->
<!--AUTHOR=Robert Burdick//-->
<!--PUBLISHER=John Wiley & Sons, Inc.//-->
<!--IMPRINT=Wiley Computer Publishing//-->
<!--CHAPTER=13//-->
<!--PAGES=333-338//-->
<!--UNASSIGNED1//-->
<!--UNASSIGNED2//-->

<CENTER>
<TABLE BORDER>
<TR>
<TD><A HREF="329-333.html">Previous</A></TD>
<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>
<TD><A HREF="338-342.html">Next</A></TD>
</TR>
</TABLE>
</CENTER>
<P><BR></P>
<H3><A NAME="Heading3"></A><FONT COLOR="#000077">Programming the Rich Ink Control</FONT></H3>
<P>Programming the rich ink control is fairly simple. The simplicity comes from the fact that the control supports no custom styles, and there are only five rich ink control messages. These messages are detailed in Table 13.1 on page 336. The remainder of this section describes how to use each of the messages.
</P>
<TABLE WIDTH="100%" BORDER RULES="ROWS"><CAPTION ALIGN=LEFT><B>Table 13.1</B> Rich Ink Control Messages
<TR>
<TH WIDTH="40%" ALIGN="LEFT">MESSAGE
<TH WIDTH="60%" ALIGN="LEFT">MEANING
<TR>
<TD>IM_SHOWCMDBAR
<TD>Hides or shows the rich ink control command bar.
<TR>
<TD>IM_GETDATALEN
<TD>Returns the length of the ink data in bytes.
<TR>
<TD VALIGN="TOP">IM_SETDATA
<TD>Sets the contents of the specified rich ink control to the specified data.
<TR>
<TD>IM_GETDATA
<TD>Retrieves the ink data currently displayed by the rich ink control.
<TR>
<TD>IM_CLEARALL
<TD>Erases the rich ink control contents.
</TABLE>
<BLOCKQUOTE>
<P><FONT SIZE="-1"><HR><B>NOTE:&nbsp;&nbsp;</B><B>IM_REINIT D<SMALL>OES</SMALL> N<SMALL>OT</SMALL> E<SMALL>XIST</SMALL></B>
<P><B>The Palm-size PC SDK on-line documentation incorrectly identifies a message called IM_REINIT for erasing the contents of a rich ink control. This message is not defined in any of the Windows CE header files. The real message is called IM_CLEARALL.</B><HR></FONT>
</BLOCKQUOTE>
</P>
<P><FONT SIZE="+1"><B>Initializing and Creating the Rich Ink Control</B></FONT></P>
<P>Like the HTML viewer control, the rich ink control lives in its own DLL. This DLL is called INKX.DLL. The header file defining the rich ink control messages and exported functions is RICHINK.H.
</P>
<P>Before an application can create instances of the rich ink control, it must first load INKX.DLL and then call the exported function <I>InitInkX</I>. If the DLL is implicitly linked, it is not necessary for the application to load it. See Chapter 11 for background on explicit and implicit linking of DLLs.</P>
<P><I>InitInkX </I>is responsible for registering the rich ink control window class. The control&#146;s window class name is defined by the symbol WC_INKX in the header file RICHINK.H. After calling <I>InitInkX</I>, an application can create rich ink controls.</P>
<P>For example, the sample application INK.EXE includes the following code in its <I>WinMain</I> function to create the rich ink control that it uses:</P>
<!-- CODE //-->
<PRE>
  #define IDC_INK   1028
  HWND hwndInk;
  #include &lt;richink.h&gt;
  int WINAPI WinMain(HINSTANCE hInstance,
    HINSTANCE hPrevInstance,
    LPTSTR lpCmdLine,
    int nCmdShow)
  &#123;
    /* Other application initialization code */
    InitInkX();
    /* Code for registering the main window class
      and creating the main window omitted.
     */
    hwndInk = CreateWindow(
     WC_INKX,
     NULL,
     WS_BORDER|WS_CHILD|WS_VISIBLE,
     0,75,200,150,
     hwndMain,
     (HMENU)IDC_INK,
     hInstance,
     NULL
     );
    /* Hide the command bar on the control */
    SendMessage(hwndInk, IM_SHOWCMDBAR,
     (WPARAM)FALSE, 0);
  &#125;
</PRE>
<!-- END CODE //-->
<P><A NAME="Fig6"></A><A HREF="javascript:displayWindow('images/13-06.jpg',240,320 )"><IMG SRC="images/13-06t.jpg"></A>
<BR><A HREF="javascript:displayWindow('images/13-06.jpg',240,320)"><FONT COLOR="#000077"><B>Figure 13.6</B></FONT></A>&nbsp;&nbsp;The rich ink control command bar.</P>
<P><A NAME="Fig7"></A><A HREF="javascript:displayWindow('images/13-07.jpg',240,320 )"><IMG SRC="images/13-07t.jpg"></A>
<BR><A HREF="javascript:displayWindow('images/13-07.jpg',240,320)"><FONT COLOR="#000077"><B>Figure 13.7</B></FONT></A>&nbsp;&nbsp;The rich ink control Format dialog.</P>
<P>The application initializes the rich ink control class and then creates an instance of the rich ink control. It then sends the control an IM_SHOWCMDBAR message. This message programmatically hides or shows the command bar (Figure 13.6) associated with the specified rich ink control. The effect of the IM_SHOWCMDBAR message in this case is to make the command bar invisible when the rich ink control is created. The IM_SHOWCMDBAR message is described in Table 13.2.
</P>
<TABLE WIDTH="100%" BORDER RULES="ROWS"><CAPTION ALIGN=LEFT><B>Table 13.2</B> The IM_SHOWCMDBAR Message
<TR>
<TH WIDTH="40%" ALIGN="LEFT">PARAMETER
<TH WIDTH="60%" ALIGN="LEFT">MEANING
<TR>
<TD VALIGN="TOP">wParam
<TD>If TRUE, the command bar is made visible. If FALSE, the command bar is hidden.
<TR>
<TD>lParam
<TD>Not used, should be 0.
</TABLE>
<P><FONT SIZE="+1"><B>Working with Inking Data</B></FONT></P>
<P>As users draw in a rich ink control, the control stores the ink data in an internal data structure. Users need to be able to store and retrieve what they input into the control as needed.
</P>
<P>For example, one application of the rich ink control might be a simple notepad application. Users make handwritten notes on a &#147;page&#148; of the notepad and then save the note for later reference. The application obviously needs to be able to store and retrieve inking data in persistent storage.</P>
<P>To demonstrate how to save and restore inking data, let&#146;s look at how the INK.EXE application saves and reads ink data files. The application stores inking data in files with the extension .INK.</P>
<P>Saving and restoring inking data requires the two rich ink control messages IM_GETDATA and IM_SETDATA. The meanings of their parameters are shown in Tables 13.3 and 13.4.</P>
<TABLE WIDTH="100%" BORDER RULES="ROWS"><CAPTION ALIGN=LEFT><B>Table 13.3</B> The IM_GETDATA Message
<TR>
<TH WIDTH="40%" ALIGN="LEFT">PARAMETER
<TH WIDTH="60%" ALIGN="LEFT">MEANING
<TR>
<TD VALIGN="TOP">wParam
<TD>Integer indicating the length of the inking data to be retrieved from the rich ink control.
<TR>
<TD VALIGN="TOP">lParam
<TD>Pointer to an array of bytes that receives the inking data from the control.
</TABLE>
<P>
</P>
<TABLE WIDTH="100%" BORDER RULES="ROWS"><CAPTION ALIGN=LEFT><B>Table 13.4</B> The IM_SETDATA Message
<TR>
<TH WIDTH="40%" ALIGN="LEFT">PARAMETER
<TH WIDTH="60%" ALIGN="LEFT">MEANING
<TR>
<TD VALIGN="TOP">wParam
<TD>Integer indicating the length of the data buffer that contains the rich ink control data.
<TR>
<TD VALIGN="TOP">lParam
<TD>Pointer to an array of bytes that contains the rich ink control inking data.
</TABLE>
<P>To implement the inking data file save and retrieval functionality, INK.EXE defines the function <I>OnOpenSave</I>. This function is responsible for both opening and displaying existing .ink files and for saving .ink files to the object store.</P>
<P>The prototype of <I>OnOpenSave</I> is found in the application header file INK.H:</P>
<!-- CODE SNIP //-->
<PRE>
  void OnOpenSave(HWND hwndApp, HWND hwndInk,
    BOOL bOpen);
</PRE>
<!-- END CODE SNIP //-->
<P>The <I>hwndApp</I> and <I>hwndInk</I> parameters are the main application window and the rich ink control window, respectively. The <I>bOpen</I> parameter tells the function if it is being called to open a file or save a file.</P>
<P>We will break further discussion of this function into two sections. The first describes how ink files are saved. The second discusses how INK.EXE opens and reads ink data files.</P><P><BR></P>
<CENTER>
<TABLE BORDER>
<TR>
<TD><A HREF="329-333.html">Previous</A></TD>
<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>
<TD><A HREF="338-342.html">Next</A></TD>
</TR>
</TABLE>
</CENTER>


<!-- all of the reference materials (books) have the footer and subfoot reveresed -->
<!-- reference_subfoot = footer -->
<!-- reference_footer = subfoot -->

<!-- BEGIN SUB FOOTER -->
		<br><br>
		</TD>
    </TR>
	</TABLE>

		
	<table width="640" border=0 cellpadding=0 cellspacing=0>
		<tr>
		<td align="left" width=135><img src="/images/white.gif" width=100 height="1" alt="" border="0"></td>
		
		
<!-- END SUB FOOTER -->

<!-- all of the books have the footer and subfoot reveresed -->
<!-- reference_subfoot = footer -->
<!-- reference_footer = subfoot -->

<!-- FOOTER -->
			
		<td width="515" align="left" bgcolor="#FFFFFF">
<font face="arial, helvetica" size="1"><b><a href="/products.html"><font color="#006666">Products</font></a>&nbsp;|&nbsp; <a href="/contactus.html"><font color="#006666">Contact Us</font></a>&nbsp;|&nbsp; <a href="/aboutus.html"><font color="#006666">About Us</font></a>&nbsp;|&nbsp; <a href="http://www.earthweb.com/corporate/privacy.html" target="_blank"><font color="#006666">Privacy</font></a> &nbsp;|&nbsp; <a href="http://www.itmarketer.com/" target="_blank"><font color="#006666">Ad Info</font></a> &nbsp;|&nbsp; <a href="/"><font color="#006666">Home</font></a></b>
		<br><br>
		
		Use of this site is subject to certain <a href="/agreement.html">Terms &amp; Conditions</a>, <a href="/copyright.html">Copyright &copy; 1996-1999 EarthWeb Inc.</a><br> 
All rights reserved.  Reproduction whole or in part in any form or medium without express written permision of EarthWeb is prohibited.</font><p>
</td>
		</tr>
</table>
</BODY>
</HTML>

<!-- END FOOTER -->

⌨️ 快捷键说明

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