亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? ch08.htm

?? 24小時精通VC
?? HTM
?? 第 1 頁 / 共 4 頁
字號:
<UL>
	<LI>Messages sent from the operating system
	<LI>Messages sent to and from controls that deal with user input
</UL>

<P>Examples of messages sent from the operating system include messages used to tell
the program that it should start or close or to tell a window that it is being resized
or moved. Messages sent to controls can be used to change the font used by a window
or its title. Messages received from a control include notifications that a button
has been pressed or that a character has been entered in an edit control.</P>
<P>There are two reasons why messages are used so heavily in Windows programs:

<UL>
	<LI>Unlike a function call, a message is a physical chunk of data, so it can be easily
	queued and prioritized.<BR>
	<BR>
	
	<LI>A message is not dependent on a particular language or processor type, so a message-based
	program can easily be ported to other CPUs, as is often done with Windows NT.
</UL>

<P>Queues work well for event-driven programming. When an event occurs, a message
can be created and quickly queued to the appropriate window or program. Each message
that is queued can then be handled in an orderly manner.</P>
<P>The fact that messages are language independent has enabled Windows to grow over
the years. Today, you can write a Windows program using diverse languages such as
Visual Basic, Delphi, Visual C++, or PowerBuilder. Because messages are language
independent, messages can easily be sent between these programs. The message interface
enables you to add new features to the programs you write and also enables Windows
to grow in the future.


<BLOCKQUOTE>
	<P>
<HR>
<B> </B><FONT COLOR="#000077"><B>Just a Minute:</B></FONT><B> </B>Since it was first
	introduced, every release of Microsoft Windows has added new messages and new functionality.
	However, most of the core messages used in the initial version of Windows still are
	available, even on multiprocessor machines that are running Windows NT. 
<HR>
</P>
	<P>
<HR>
<B> </B><FONT COLOR="#000077"><B>CAUTION:</B></FONT><B> </B>When using an event-driven
	programming model such as Microsoft Windows, you cannot always be certain about message
	order. A subtle difference in the way different users use a program can cause messages
	to be received in a different sequence. This means that every time you handle an
	event, you should handle only that particular event and not assume that any other
	activity has taken place. 
<HR>


</BLOCKQUOTE>

<H3><FONT COLOR="#000077"><B>A Program to Test for Mouse Clicks</B></FONT></H3>
<P>As an example, you're about to create a program that actually shows how messages
are used to notify your application about events. This program, MouseTst, will be
an SDI application that displays a message whenever the mouse is clicked inside the
client area. The first step in creating MouseTst is to use AppWizard to create an
SDI application. Feel free to select or remove any options offered by AppWizard,
because none of the options have any bearing on the demonstration. Name the application
MouseTst.
<H3><FONT COLOR="#000077"><B>What Are Message Queues?</B></FONT></H3>
<P>Messages are delivered to all windows that must receive events. For example, the
simple act of moving the mouse cursor across the main window of a Windows program
generates a large number of messages. Messages sent to a window are placed in a queue,
and a program must examine each message in turn. Typically, a program examines messages
that are sent to it and responds only to messages that are of interest, as shown
in Figure 8.3.</P>

<P><A NAME="03"></A><A HREF="03.htm" tppabs="http://www.mcp.com/824169600/0-672/0-672-31242-5/ch08/03.htm"><B>Figure 8.3.</B> </A><I><BR>
Messages queued and handled in order by an application.</I></P>

<P>As shown in Figure 8.3, messages sent to a program are handled by a window procedure
that is defined for the program.
<H3><FONT COLOR="#000077"><B>How Are Messages Handled?</B></FONT></H3>
<P>When a user moves the mouse over a program's main window, two messages are sent
to the program's window procedure.

<UL>
	<LI><TT>WM_NCMOUSEMOVE</TT> is sent when the mouse is moved over the menu or caption
	bar.
	<LI><TT>WM_MOUSEMOVE</TT> is sent when the mouse is over the window's client area.
</UL>

<P>Another type of mouse message is the <TT>WM_LBUTTONDOWN</TT> message, sent when
the primary mouse button is pressed. Because this is the left button for most mouse
users, the message is named <TT>WM_LBUTTONDOWN</TT>. A similar message is <TT>WM_RBUTTONDOWN</TT>,
sent when the secondary, usually right, mouse button is pressed.</P>
<P>These and other messages are sent to a window's <I>window procedure</I>. A window
procedure is a function that handles messages sent to it. When a window procedure
receives the message, the parameters passed along with the message are used to help
decide how the message should be handled.
<H2><FONT COLOR="#000077"><B>Handling Messages with ClassWizard</B></FONT></H2>
<P>ClassWizard (also called MFC ClassWizard) adds code that typically is used for
a particular message-handling function. This commonly reused, or &quot;boilerplate,&quot;
code can help reduce the number of errors still further, because it's guaranteed
to be correct. Listing 8.1 is an example of a function created by ClassWizard to
handle the <TT>WM_LBUTTONDOWN</TT> message.
<H4><FONT COLOR="#000077">TYPE: Listing 8.1. The OnLButtonDown function created by
ClassWizard.</FONT></H4>
<PRE><FONT COLOR="#0066FF"><TT>void CMyView::OnLButtonDown(UINT nFlags, CPoint point)</TT>
<TT>{</TT>
<TT>    //TODO: Add your message handler code here and/or call default</TT>

<TT>    CView::OnLButtonDown(nFlags, point);</TT>
<TT>}</TT> </FONT></PRE>
<P><FONT COLOR="#000077"><B>New Term:</B></FONT><B> </B>A <I>message map</I> connects
messages sent to a program with the functions that are meant to handle those messages.</P>

<P>When AppWizard or ClassWizard adds a message-handling function, an entry is added
to the class message map. Listing 8.2 shows an example of a message map.
<H4><FONT COLOR="#000077">TYPE: Listing 8.2. A message map for the CMyView class.</FONT></H4>
<PRE><FONT COLOR="#0066FF"><TT>BEGIN_MESSAGE_MAP(CMyView, CView)</TT>
<TT>    //{{AFX_MSG_MAP(CMyView)</TT>
<TT>    ON_WM_LBUTTONDOWN()</TT>
<TT>    //}}AFX_MSG_MAP</TT>
<TT>    // Standard printing commands</TT>
<TT>    ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint)</TT>
<TT>    ON_COMMAND(ID_FILE_PRINT_DIRECT, CView::OnFilePrint)</TT>
<TT>    ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview)</TT>
<TT>END_MESSAGE_MAP()</TT></FONT></PRE>


<BLOCKQUOTE>
	<P>
<HR>
<B> </B><FONT COLOR="#000077"><B>CAUTION:</B></FONT><B> </B>The message map begins
	with the <TT>BEGIN_MESSAGE_MAP</TT> macro and ends with the <TT>END_MESSAGE_MAP</TT>
	macro. The lines reserved for use by ClassWizard start with <TT>//{{AFX_MSG_MAP</TT>
	and end with <TT>//}}AFX_MSG_MAP</TT>. If you make manual changes to the message
	map, do not change the entries reserved for ClassWizard; they are maintained automatically.
	
<HR>


</BLOCKQUOTE>

<H3><FONT COLOR="#000077"><B>Messages Handled by MouseTst</B></FONT></H3>
<P>The MouseTst program must handle four messages used to collect mouse events. The
messages used by MouseTst are listed in Table 8.1.
<H4><FONT COLOR="#000077">Table 8.1. Messages handled by MouseTst.</FONT></H4>
<P>
<TABLE BORDER="1">
	<TR ALIGN="LEFT" rowspan="1">
		<TD ALIGN="LEFT" VALIGN="TOP"><B>Message</B></TD>
		<TD ALIGN="LEFT" VALIGN="TOP"><B>Function</B></TD>
		<TD ALIGN="LEFT" VALIGN="TOP"><B>Description</B></TD>
	</TR>
	<TR ALIGN="LEFT" rowspan="1">
		<TD ALIGN="LEFT" VALIGN="TOP"><TT>WM_LBUTTONDOWN</TT></TD>
		<TD ALIGN="LEFT" VALIGN="TOP"><TT>OnLButtonDown</TT></TD>
		<TD ALIGN="LEFT" VALIGN="TOP">Left mouse button clicked</TD>
	</TR>
	<TR ALIGN="LEFT" rowspan="1">
		<TD ALIGN="LEFT" VALIGN="TOP"><TT>WM_LBUTTONDBLCLK</TT></TD>
		<TD ALIGN="LEFT" VALIGN="TOP"><TT>OnLButtonDblClk</TT></TD>
		<TD ALIGN="LEFT" VALIGN="TOP">Left mouse button double-clicked</TD>
	</TR>
	<TR ALIGN="LEFT" rowspan="1">
		<TD ALIGN="LEFT" VALIGN="TOP"><TT>WM_RBUTTONDOWN</TT></TD>
		<TD ALIGN="LEFT" VALIGN="TOP"><TT>OnRButtonDown</TT></TD>
		<TD ALIGN="LEFT" VALIGN="TOP">Right mouse button clicked</TD>
	</TR>
	<TR ALIGN="LEFT" rowspan="1">
		<TD ALIGN="LEFT" VALIGN="TOP"><TT>WM_RBUTTONDBLCLK</TT></TD>
		<TD ALIGN="LEFT" VALIGN="TOP"><TT>OnRButtonDblClk</TT></TD>
		<TD ALIGN="LEFT" VALIGN="TOP">Right mouse button double-clicked</TD>
	</TR>
</TABLE>
</P>
<P>In addition, when the <TT>WM_PAINT</TT> message is received, the MFC framework
calls the <TT>OnDraw</TT> member function. MouseTst will use <TT>OnDraw</TT> to update
the display with the current mouse position and last message.
<H3><FONT COLOR="#000077"><B>Updating the <TT>CMouseTst</TT> View Class</B></FONT></H3>
<P>All the work that keeps track of the mouse events will be done in the <TT>CMouseTstView</TT>
class. There are two steps to displaying the mouse event information in the MouseTst
program:

<DL>
	<DD>1. When one of the four mouse events occurs, the event type and mouse position
	are recorded, and the view's rectangle is invalidated. This causes a <TT>WM_PAINT</TT>
	message to be generated by Windows and sent to the MouseTst application.<BR>
	<BR>
	2. When a <TT>WM_PAINT</TT> message is received by MouseTst, the <TT>CMouseTstView::OnDraw</TT>
	member function is called, and the mouse event and position are displayed.
</DL>



<BLOCKQUOTE>
	<P>
<HR>
<B> </B><FONT COLOR="#000077"><B>Just a Minute:</B></FONT><B> </B>All output is done
	in response to a <TT>WM_PAINT</TT> message. <TT>WM_PAINT</TT> is sent when a window's
	client area is invalidated. This often is due to the window being uncovered or reopened.
	Because the window must be redrawn in response to a <TT>WM_PAINT</TT> message, most
	programs written for Windows do all their drawing in response to <TT>WM_PAINT</TT>
	and just invalidate their display window or view when the window should be updated.
	
<HR>


</BLOCKQUOTE>

<P>To keep track of the mouse event and position, you must add two member variables
to the <TT>CMouseTstView</TT> class. Add the three lines from Listing 8.3 as the
last three lines before the closing curly brace in <TT>CMouseTstView.h</TT>.
<H4><FONT COLOR="#000077">TYPE: Listing 8.3. New member variables for the CMouseTstView
class.</FONT></H4>
<PRE><FONT COLOR="#0066FF"><TT>private:</TT>
<TT>    CPoint   m_ptMouse;</TT>
</FONT></PRE>
<P><TT>CString m_szDescription;</TT> The constructor for <TT>CMouseTstView</TT> must
initialize the new member variables. Edit the constructor for <TT>CMouseTstView</TT>,
found in <TT>CMouseTstView.cpp</TT>, so it looks like the source code in Listing
8.4.
<H4><FONT COLOR="#000077">TYPE: Listing 8.4. The constructor for CMouseTstView.</FONT></H4>
<PRE><FONT COLOR="#0066FF"><TT>CMouseTstView::CMouseTstView()</TT>
<TT>{</TT>
<TT>    m_ptMouse = CPoint(0,0);</TT>
<TT>    m_szDescription.Empty();</TT>
</FONT></PRE>
<P><TT>}</TT> Using ClassWizard, add message-handling functions for the four mouse
events that you're handling in the MouseTst program. Open ClassWizard by pressing
Ctrl+W, or by right-clicking in a source-code window and selecting ClassWizard from
the menu. After ClassWizard appears, follow these steps:

<DL>
	<DD>1. Select the <TT>CMouseTstView</TT> class in the Object ID list box; a list

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美久久一区二区| 日韩一区二区三区免费观看| 韩国一区二区在线观看| 蜜桃av一区二区在线观看| 一区二区三区**美女毛片| 亚洲婷婷在线视频| 亚洲同性同志一二三专区| 综合激情成人伊人| 亚洲欧洲精品一区二区精品久久久| 国产精品三级av在线播放| 国产欧美精品区一区二区三区| 久久午夜电影网| 国产人伦精品一区二区| 国产欧美一区二区三区在线看蜜臀| xf在线a精品一区二区视频网站| 精品国产网站在线观看| 精品久久久久久综合日本欧美| 精品精品欲导航| 久久久久久久久一| 国产精品久久久久久妇女6080| 亚洲视频综合在线| 亚洲成人一区二区| 麻豆精品新av中文字幕| 91免费视频大全| 色综合激情久久| 欧美久久免费观看| 精品久久久久久无| 国产精品素人一区二区| 亚洲女爱视频在线| 亚洲成人av中文| 另类的小说在线视频另类成人小视频在线| 精品一区二区在线看| 国产精品1区2区| 91麻豆精东视频| 欧美精品日韩综合在线| 久久久综合视频| 亚洲精品成人a在线观看| 日韩高清电影一区| 国产精品99久久久久久宅男| 91麻豆蜜桃一区二区三区| 欧美日韩成人在线| 国产亚洲精品超碰| 亚洲一区二区三区在线播放| 久久97超碰国产精品超碰| 成人午夜免费视频| 欧美日韩国产a| 中文字幕不卡在线| 亚洲18影院在线观看| 国产成人亚洲综合a∨婷婷| 在线观看亚洲精品| 久久综合丝袜日本网| 亚洲精品免费播放| 激情文学综合网| 欧美在线一区二区三区| 久久综合网色—综合色88| 一区二区久久久久久| 国产一区二区三区美女| 欧美午夜精品电影| 国产目拍亚洲精品99久久精品| 亚洲午夜三级在线| 国产白丝网站精品污在线入口| 欧美日韩精品电影| 国产精品久久久久久妇女6080| 青青草原综合久久大伊人精品优势 | 91麻豆精品国产自产在线| 国产拍揄自揄精品视频麻豆| 午夜影院在线观看欧美| 成人综合婷婷国产精品久久| 91精品国产综合久久精品app| 欧美国产日韩在线观看| 日本成人超碰在线观看| 色综合久久中文综合久久97| 26uuu欧美| 日本女人一区二区三区| 99r国产精品| 欧美极品xxx| 免费看日韩精品| 在线观看亚洲a| 中文字幕综合网| 国产69精品一区二区亚洲孕妇| 91麻豆精品91久久久久久清纯| 一区二区三区色| 99r国产精品| 中文在线资源观看网站视频免费不卡| 蜜芽一区二区三区| 7777精品久久久大香线蕉| 亚洲美女电影在线| 99久久精品免费看| 国产精品久久久久久久久免费丝袜 | 色婷婷综合五月| 中文字幕一区二区三区av| 国产福利91精品| 国产精品成人免费| 国产在线精品一区二区不卡了| 在线播放国产精品二区一二区四区| 一级日本不卡的影视| 91在线免费看| 亚洲美女视频在线| 99久久99久久精品国产片果冻| 中文字幕av免费专区久久| 国产成人一级电影| 国产欧美一区二区在线观看| 国产福利视频一区二区三区| 国产亚洲一区二区在线观看| 狠狠色综合色综合网络| 欧美tickling网站挠脚心| 麻豆成人91精品二区三区| 欧美日韩成人综合天天影院| 亚洲高清一区二区三区| 欧美日韩国产一区| 一区二区三区精品在线观看| 色婷婷精品久久二区二区蜜臂av| 欧美一区二区精品在线| 日本欧美一区二区在线观看| 欧美性xxxxxx少妇| 亚洲综合精品自拍| 欧美日韩激情一区二区| 亚洲制服丝袜在线| 在线不卡中文字幕| 日本亚洲最大的色成网站www| 日韩免费观看高清完整版在线观看| 视频一区二区三区在线| 欧美一二三区在线观看| 日韩**一区毛片| 欧美成人午夜电影| 日韩avvvv在线播放| 精品成a人在线观看| 国产剧情av麻豆香蕉精品| 久久综合精品国产一区二区三区| 国产 欧美在线| 国产精品免费视频网站| 日本高清不卡一区| 亚洲国产日韩在线一区模特 | 久久综合九色综合97_久久久| 国产传媒日韩欧美成人| 国产精品国产三级国产普通话99| 色婷婷综合在线| 午夜婷婷国产麻豆精品| 精品99久久久久久| 成人亚洲一区二区一| 亚洲免费在线观看视频| 欧美日韩精品电影| 国产激情视频一区二区三区欧美| 久久久久亚洲综合| 一本一道久久a久久精品| 视频一区免费在线观看| 日韩欧美一级片| 成人免费毛片app| 亚洲另类在线视频| 精品乱码亚洲一区二区不卡| 成人高清免费在线播放| 五月天视频一区| 久久天堂av综合合色蜜桃网| 色婷婷av一区二区三区gif| 日韩国产精品久久久| 国产精品午夜在线| 在线播放亚洲一区| 高清成人在线观看| 婷婷中文字幕一区三区| 精品99久久久久久| 欧美三区在线观看| 激情综合一区二区三区| 亚洲已满18点击进入久久| 欧美三级乱人伦电影| 国产主播一区二区| 亚洲va韩国va欧美va精品| 国产亚洲欧洲一区高清在线观看| 欧美日韩中字一区| 国产盗摄一区二区| 日韩精品电影在线| 国产精品乱人伦中文| 日韩视频一区在线观看| 国产69精品久久久久777| 亚洲图片欧美色图| 中文字幕在线免费不卡| 国产精品美女久久久久久久久久久| 9191久久久久久久久久久| 成人毛片视频在线观看| 久久爱www久久做| 亚洲福利视频一区二区| 欧美高清在线精品一区| 久久久亚洲欧洲日产国码αv| 欧美视频一区二区| 99久久久久久| 国产麻豆午夜三级精品| 麻豆一区二区在线| 综合欧美一区二区三区| 久久精品一区蜜桃臀影院| 欧美变态tickling挠脚心| 91黄色免费版| 99久免费精品视频在线观看 | 欧美日韩视频一区二区| 99久久久久免费精品国产| 极品少妇xxxx偷拍精品少妇| 麻豆成人av在线| 婷婷久久综合九色综合伊人色| 亚洲精品免费在线观看| 国产精品福利影院| 久久久久高清精品| 一个色在线综合|