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

📄 345-349.html

📁 WindowsCE.[Essential Windows CE Application Programming].Jon Wiley & Son.zip
💻 HTML
📖 第 1 页 / 共 2 页
字号:

<!-- END SUB HEADER -->

<!--Begin Content Column -->

<FONT FACE="Arial,Helvetica" SIZE="-1">
To access the contents, click the chapter and section titles.
</FONT>
<P>
<B>Essential Windows CE Application Programming</B>
<FONT SIZE="-1">
<BR>
<I>(Publisher: John Wiley & Sons, Inc.)</I>
<BR>
Author(s): Robert Burdick
<BR>
ISBN: 0471327476
<BR>
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=345-349//-->
<!--UNASSIGNED1//-->
<!--UNASSIGNED2//-->

<CENTER>
<TABLE BORDER>
<TR>
<TD><A HREF="342-345.html">Previous</A></TD>
<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>
<TD><A HREF="349-352.html">Next</A></TD>
</TR>
</TABLE>
</CENTER>
<P><BR></P>
<P><FONT SIZE="+1"><B>Program Buttons</B></FONT></P>
<P>The Palm-size PC program buttons (also called application buttons) are used to launch applications. They can also be used as hot keys for performing application-specific functions.
</P>
<P>The message mechanism used by the program button is a little different from that used by the other navigation buttons. Whenever a program button is pressed or released, a series of WM_KEYDOWN or WM_KEYUP messages is sent to the Palm-size PC shell. The <I>wParam</I> of the first message is VK_LWIN. This tells the shell to wait for the next WM_KEYDOWN or WM_KEYUP message to determine which application to launch. The <I>wParam</I> of the second message contains information for the shell about where to look in the Windows CE registry to find the name of the application to launch.</P>
<P>Let&#146;s look at an example to make this more clear. Assume that a user presses program button number 1. The series of messages shown in Table 13.11 is generated. The first message alerts the shell that a program button has been pressed. It now knows to look for the next WM_KEYDOWN message. This second message&#146;s <I>wParam</I> value contains a virtual key code which the shell uses to look up application information in the registry.</P>
<TABLE WIDTH="100%" BORDER RULES="ROWS"><CAPTION ALIGN=LEFT><B>Table 13.11</B> Program Button 1 Messages
<TR>
<TH WIDTH="35%" ALIGN="LEFT" VALIGN="BOTTOM">ACTION
<TH WIDTH="30%" ALIGN="LEFT" VALIGN="BOTTOM">MESSAGE
<TH WIDTH="35%" ALIGN="LEFT">VIRTUAL KEY CODE (WPARAM)
<TR>
<TD>Press button
<TD>WM_KEYDOWN
<TD>VK_LWIN
<TR>
<TD>
<TD>WM_KEYDOWN
<TD>0xC1
</TABLE>
<P>Specifically, upon receiving the second WM_KEYDOWN message, the shell responds by looking for the registry subkey \HKEY_LOCAL_ MACHINE\Software\Microsoft\Shell\Keys\40C1. The default value of this subkey is the full path name of the application to be launched. The shell launches the referenced application. Notice that the last two characters of the subkey name correspond to the virtual key code.
</P>
<P>When the shell receives another message containing VK_LWIN in the <I>wParam</I>, it begins sending the program button messages that it receives to the current application. VK_LWIN therefore acts as a switch, toggling the shell between handling program button messages itself and sending them to the currently running application.</P>
<BLOCKQUOTE>
<P><FONT SIZE="-1"><HR><B>NOTE:&nbsp;&nbsp;</B><B>P<SMALL>ROGRAM</SMALL> B<SMALL>UTTON</SMALL> V<SMALL>IRTUAL</SMALL> K<SMALL>EY</SMALL> C<SMALL>ODES</SMALL> M<SMALL>AY</SMALL> B<SMALL>E</SMALL> D<SMALL>IFFERENT</SMALL></B>
<P><B>Like the sequence of messages sent in response to navigation button actions, the virtual key codes that are sent with program buttons may be different on your device. The device driver provided by the OEM is responsible for making the mapping between program button and virtual key code. Refer to the documentation for the device driver on your specific device for details.</B><HR></FONT>
</BLOCKQUOTE>
</P>
<P><FONT SIZE="+1"><B><I>Optional Subkeys</I></B></FONT></P>
<P>There are other subkeys that may be present under an application&#146;s registry subkey. These subkeys are detailed in Table 13.12.
</P>
<TABLE WIDTH="100%" BORDER RULES="ROWS"><CAPTION ALIGN=LEFT><B>Table 13.12</B> Other Registry Subkeys Related to Program Navigation Buttons
<TR>
<TH WIDTH="40%" ALIGN="LEFT">STYLE
<TH WIDTH="60%" ALIGN="LEFT">MEANING
<TR>
<TD VALIGN="TOP">Name
<TD>Name of the application, not including the full directory path or .EXE extension.
<TR>
<TD>Icon
<TD>Full path name of the application&#146;s Start menu icon.
<TR>
<TD>Flags
<TD>Program control flags.
<TR>
<TD>ResetCmd
<TD>Default application command line.
</TABLE>
<P>For example, an application that resides in the file \Windows\ MyApp.exe may have a Name registry subkey with the value &#147;MyApp&#148;.
</P>
<P><FONT SIZE="+1"><B><I>Launching a Different Application with a Program Button</I></B></FONT></P>
<P>The registry values that tell the Palm-size PC shell which application to launch in response to a particular program button can be changed. This allows users to redefine which applications are launched by the various program buttons on their devices.
</P>
<P>The Button Properties dialog box allows users to redirect program buttons. Changing the mapping between a program button and the application it launches forces the shell to send a WM_WININICHANGE message to all running applications.</P>
<P><FONT SIZE="+1"><B><I>Adding Hot Keys</I></B></FONT></P>
<P>Program buttons can be programmed as hot keys to perform application-specific actions. For example, pressing and holding the program button that launches an application might invoke a particular menu item.
</P>
<P>Hot keys must be <I>registered</I> with the Palm-size PC shell. To register, your application must first call the Palm-size PC shell API <I>ShGetAppKeyAssoc</I> to determine if a program button is already assigned to the application:</P>
<!-- CODE SNIP //-->
<PRE>
  SHGetAppKeyAssoc(ptszApp);
</PRE>
<!-- END CODE SNIP //-->
<P><I>ptszApp</I> is a string containing the name of the application of interest. The function returns the virtual key code of the Program control associated with the application. If no program button is assigned to the specified application, <I>SHGetAppKeyAssoc</I> returns zero.</P>
<P>If no virtual key is assigned to the application you wish to register a hot key for, you can map a program button to the application using the Button Properties dialog.</P>
<P>Next, you register the hot key by calling <I>RegisterHotKey:</I></P>
<!-- CODE SNIP //-->
<PRE>
  RegisterHotKey(hWnd, id, fsModifiers,   vk);
</PRE>
<!-- END CODE SNIP //-->
<P><I>hWnd</I> is the window that is to receive the WM_HOTKEY messages. <I>id</I> is a unique hot key identifier.</P>
<P><I>fsModifiers</I> indicates other keys that must be pressed at the same time as the program button to invoke the hot key. This really only makes sense for non-Palm-size PC platforms. For the Palm-size PC platform, <I>fsModifiers</I> can be MOD_KEYUP. This means that the WM_HOTKEY message is sent both when the corresponding program button is pressed and when it is released.</P>
<P>Finally, <I>vk</I> indicates the virtual key code of the hot key.</P>
<P>For example, to register a hot key with MyApp.exe, I could write:</P>
<!-- CODE SNIP //-->
<PRE>
  BYTE bVirtKey;
  bVirtKey = SHGetAppKeyAssoc(TEXT("\\Windows\\MyApp.exe"));
  RegisterHotKey(hwndMain, 0, 0, bVirtKey);
</PRE>
<!-- END CODE SNIP //-->
<P>This example assumes that the window procedure of the window <I>hwndMain</I> handles the WM_HOTKEY messages. It also assumes that a program button has been mapped to the application MyApp.exe.</P>
<BLOCKQUOTE>
<P><FONT SIZE="-1"><HR><B>NOTE:&nbsp;&nbsp;</B><B>U<SMALL>SING</SMALL> AYGSHELL.DLL</B>
<P><B>The implementation of the <I>SHGetAppKeyAssoc</I> function is in the dynamic link library AYGSHELL.DLL. In order to use this function, your application must include the header file AYGSHELL.H. It must also either link dynamically with AYGSHELL.DLL or statically with AYGSHELL.LIB.</B><HR></FONT>
</BLOCKQUOTE>
</P><P><BR></P>
<CENTER>
<TABLE BORDER>
<TR>
<TD><A HREF="342-345.html">Previous</A></TD>
<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>
<TD><A HREF="349-352.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 + -