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

📄 028-031.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=2//-->
<!--PAGES=028-031//-->
<!--UNASSIGNED1//-->
<!--UNASSIGNED2//-->

<CENTER>
<TABLE BORDER>
<TR>
<TD><A HREF="025-028.html">Previous</A></TD>
<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>
<TD><A HREF="031-033.html">Next</A></TD>
</TR>
</TABLE>
</CENTER>
<P><BR></P>
<P><FONT SIZE="+1"><B>The WM_CREATE Message</B></FONT></P>
<P>The <I>CreateWindow</I> and <I>CreateWindowEx</I> functions both send a WM_CREATE message to the window procedure of the window being created. This message is sent after the window has been created but before it becomes visible. Furthermore, the WM_CREATE message is sent before the <I>CreateWindow</I> and <I>CreateWindowEx</I> functions return.</P>
<P>As Table 2.2 shows, the WM_CREATE message passes a pointer to a CREATESTRUCT structure containing information about the window being created. Here is the definition of the CREATESTRUCT structure:</P>
<!-- CODE //-->
<PRE>
  typedef struct tagCREATESTRUCT
  &#123;
    LPVOID lpCreateParams;
    HINSTANCE hInstance;
    HMENU hMenu;
    HWND hwndParent;
    int cy;
    int cx;
    int y;
    int x;
    LONG style;
    LPCTSTR lpszName;
    LPCTSTR lpszClass;
    DWORD dwExStyle;
  &#125; CREATESTRUCT, *LPCREATESTRUCT;
</PRE>
<!-- END CODE //-->
<TABLE WIDTH="100%" BORDER RULES="ROWS">
<CAPTION ALIGN=LEFT><B>Table 2.2</B> The WM_CREATE Message Parameters
<TR>
<TH WIDTH="30%" ALIGN="LEFT">PARAMETER
<TH WIDTH="70%" ALIGN="LEFT">MEANING
<TR>
<TD>wParam
<TD>Not used
<TR>
<TD VALIGN="TOP">(LPCREATESTRUCT)lParam
<TD>Pointer to the CREATESTRUCT structure containing information about the window being created
</TABLE>
<P>The <I>lpCreateParams</I> member of CREATESTRUCT contains the <I>lpParam</I> passed to the <I>CreateWindow</I> or <I>CreateWindowEx</I> call that generated the WM_CREATE message. If you use the <I>lpParam</I> parameter of <I>CreateWindow</I> or <I>CreateWindowEx</I> to pass some application-specific value for use during window creation, your application extracts it from this member.</P>
<P><I>hInstance</I> identifies the module (application or dynamic link library) that owns the window that was just created.</P>
<P><I>hMenu</I> identifies the window menu. As we&#146;ll see later in Chapter 4, windows do not support menu bars under Windows CE. The <I>hMenu</I> member will therefore be NULL unless the window created is a child window. In that case this member will contain the child window identifier.</P>
<P><I>hwndParent</I> contains the HWND of the parent of the newly created window.</P>
<P><I>cx</I>, <I>cy</I>, <I>y</I>, and <I>x</I> are the width, height, y position, and x position of the window, respectively. For top-level windows such as overlapped or pop-up windows, these values are given in screen coordinates. For child windows, these coordinates are relative to the upper left corner of the window&#146;s parent.</P>
<P>The <I>style</I> and <I>dwExStyle</I> members are DWORD values containing the style and extended style bits defined for the newly created window. In other words, these members are exactly the same as the <I>dwStyle</I> and <I>dwExStyle</I> values passed to <I>CreateWindow</I> or <I>CreateWindowEx</I>.</P>

<TABLE BORDER="2" BORDERCOLOR="#0000" ALIGN="CENTER">
<TR><TD><FONT SIZE="+1"><B>Adding or Removing Styles after a Window Has Been Created</B></FONT>
<P>It is common to want to add or remove window styles or extended styles from windows after they have been created. You can do this using the <I>GetWindowLong</I> and <I>SetWindowLong</I> functions.</P>
<P>For example, let&#146;s say you want to disable scrolling in a window programmatically. An application would do this:</P>
<!-- CODE SNIP //-->
<PRE>
  //hwndNoScroll is the window of interest
  DWORD dwStyle;
  //Get the current set of window style bits
  dwStyle = GetWindowLong(hwndNoScroll, GWL_STYLE);
  //Disable WS_VSCROLL, WS_HSCROLL
  SetWindowLong(hwndNoScroll, GWL_STYLE,
      (dwStyle &#38; &#8764;(WS_VSCROLL | WS_HSCROLL)
</PRE>
<!-- END CODE SNIP //-->
</TABLE>

<P>Finally, <I>lpszName</I> and <I>lpszClass</I> contain the window caption and window class name, respectively, of the newly created window.</P>
<P>The value that an application returns in response to the WM_CREATE message controls the value returned by the <I>CreateWindow</I> and <I>CreateWindowEx</I> functions that triggered the WM_CREATE message. If an application returns 0 (zero) in response to this message, <I>CreateWindow</I> and <I>CreateWindowEx</I> continue with their normal execution. When the functions finish, they return the HWND of the window that was created.</P>
<P>On the other hand, if the application returns &#150;1 in response to WM_CREATE, the new window is destroyed and <I>CreateWindow</I> and <I>CreateWindowEx</I> return NULL.</P>
<P>Applications respond to the WM_CREATE message to implement custom window creation behavior or to take more control of the window creation process.</P>
<P>As a very contrived example, let&#146;s say that we are writing an application that includes a registered window class with a window procedure named <I>WideWndProc</I>. Our application wants to refuse to create any instance of this class that is not at least 300 pixels wide.</P>
<P>To implement this feature, the WM_CREATE message handler of <I>WideWndProc</I> would look like this:</P>
<!-- CODE //-->
<PRE>
  LRESULT CALLBACK WideWndProc(
    HWND hwnd,
    UINT message,
    WPARAM wParam,
    LPARAM lParam)
  &#123;
    switch(message)
    &#123;
     case WM_CREATE:
      LPCREATESTRUCT lpcs;
      lpcs = (LPCREATESTRUCT)lParam;
      if (lpcs-&gt;cx &lt; 300)
      &#123;
       return (-1);
      &#125;
      return (0);
     &#133;
  &#125;
</PRE>
<!-- END CODE //-->
<P><BR></P>
<CENTER>
<TABLE BORDER>
<TR>
<TD><A HREF="025-028.html">Previous</A></TD>
<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>
<TD><A HREF="031-033.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 + -