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

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

?? ch10.htm

?? 24小時精通VC
?? HTM
?? 第 1 頁 / 共 3 頁
字號:
	bar when the menu item is highlighted.</UL><H3><FONT COLOR="#000077"><B>Adding a Message-Handling Function</B></FONT></H3><P>After adding a menu item to the application's menu, the next step is to add amessage-handling function to handle the new menu item. As discussed in Hour 8, ClassWizardis used to create message-handling functions for MFC-based Windows programs. To adda message-handling function for the <TT>ID_FILE_HELLO</TT> menu item, follow thesesteps:<DL>	<DD>1. Open ClassWizard by pressing Ctrl+W or by right-clicking in a source code	window and selecting ClassWizard from the menu.<BR>	<BR>	2. Select the Message Maps tab and select the class that will handle the message	from the Class Name combo box--in this case, <TT>CMainFrame</TT>.<BR>	<BR>	3. Select the object that is generating the message from the Object ID list box--in	this case, <TT>ID_FILE_HELLO</TT>. Two message-handling functions are displayed in	the Messages list box.<BR>	<BR>	4. Select the <TT>COMMAND</TT> message from the Messages list box and click the Add	Function button. Accept the default name suggested by ClassWizard for the function	name--<TT>OnFileHello</TT>.<BR>	<BR>	5. Click OK to close ClassWizard.</DL><P>Edit the <TT>CMainFrame::OnFileHello</TT> function so that it looks like the functionprovided in Listing 10.1.<H4><FONT COLOR="#000077">TYPE: Listing 10.1. The CMainFrame::OnFileHello message-handlingfunction.</FONT></H4><PRE><FONT COLOR="#0066FF"><TT>void CMainFrame::OnFileHello()</TT><TT>{</TT><TT>    AfxMessageBox( &quot;Hello from the File menu&quot; );</TT><TT>}</TT></FONT></PRE><BLOCKQUOTE>	<P><HR><B> </B><FONT COLOR="#000077"><B>Just a Minute:</B></FONT><B> </B>These basic steps	are used to add all the menu items used in examples for the remaining hours in this	book. The Developer Studio tools are so easy to use that adding a new menu item will	be second nature in no time. <HR></BLOCKQUOTE><H2><FONT COLOR="#000077"><B>Creating a Shortcut Menu</B></FONT></H2><P><FONT COLOR="#000077"><B>New Term:</B></FONT><B> </B>A <I>shortcut menu</I>, sometimescalled a pop-up or context menu, is displayed by right-clicking on a window. Shortcutmenus provide a list of commonly used actions.</P><P>Creating a shortcut menu is similar to modifying an existing menu except thata new menu resource must be created as the first step. Most shortcut menus are displayedin response to the <TT>WM_CONTEXTMENU</TT> message, which is sent when the rightmouse button is pressed.<H3><FONT COLOR="#000077"><B>Creating the Resource</B></FONT></H3><P>Use the Developer Studio resource editor to create the context menu. To createthe new menu resource, use one of the following techniques:<UL>	<LI>Select Resource from the Insert menu and then select Menu from the Insert Resource	dialog box.<BR>	<BR>		<LI>Right-click the Menu folder in the ResourceView and then select Insert Menu from	the pop-up menu.</UL><P>Both of these methods opens a new menu resource for editing. Add a dummy captionfor the first top-level item on the menu bar. This caption is not displayed by themenu; it is used only as a placeholder.</P><P>Open the Properties dialog box for the menu resource by double-clicking the edgeof the menu resource, and change the resource ID to <TT>ID_POPUP</TT>. Using thevalues from Table 10.1, add three menu items under the dummy label.<H4><FONT COLOR="#000077">Table 10.1. Menu items added to the ID_POPUP menu resource.</FONT></H4><P><TABLE BORDER="1">	<TR ALIGN="LEFT" rowspan="1">		<TD ALIGN="LEFT" VALIGN="TOP"><B>Menu ID</B></TD>		<TD ALIGN="LEFT" VALIGN="TOP"><B>Caption</B></TD>	</TR>	<TR ALIGN="LEFT" rowspan="1">		<TD ALIGN="LEFT" VALIGN="TOP"><TT>ID_LIONS</TT></TD>		<TD ALIGN="LEFT" VALIGN="TOP">&amp;Lions</TD>	</TR>	<TR ALIGN="LEFT" rowspan="1">		<TD ALIGN="LEFT" VALIGN="TOP"><TT>ID_TIGERS</TT></TD>		<TD ALIGN="LEFT" VALIGN="TOP">&amp;Tigers</TD>	</TR>	<TR ALIGN="LEFT" rowspan="1">		<TD ALIGN="LEFT" VALIGN="TOP"><TT>ID_BEARS</TT></TD>		<TD ALIGN="LEFT" VALIGN="TOP">&amp;Bears</TD>	</TR></TABLE><H3><FONT COLOR="#000077"><B>Adding Message-Handling Functions</B></FONT></H3><P>The new context menu is displayed when a right mouse click is detected on theapplication's view. After a menu item has been selected, a message is displayed atthe menu's location, similar to the message displayed in the MouseTst example fromHour 8.</P><P>You must add two new variables to the <TT>CMenuView</TT> class: a <TT>CString</TT>variable that stores the message and a <TT>CPoint</TT> variable that stores the locationof the pop-up menu. Add the source code provided in Listing 10.2 to the <TT>CMenuView</TT>class after the <TT>//Implementation</TT> comment.<H4><FONT COLOR="#000077">TYPE: Listing 10.2. New member variables for the CMenuViewclass.</FONT></H4><PRE><FONT COLOR="#0066FF"><TT>// Implementation</TT><TT>protected:</TT><TT>    CPoint  m_ptMsg;</TT></FONT></PRE><P><TT>CString m_szMsg;</TT> The constructor for <TT>CMenuView</TT> must initializethe <TT>m_ptMsg</TT> variable. Edit the constructor for <TT>CMenuView</TT>, foundin <TT>MenuView.cpp</TT>, so it looks like the source code in Listing 10.3.<H4><FONT COLOR="#000077">TYPE: Listing 10.3. The constructor for CMenuView.</FONT></H4><PRE><FONT COLOR="#0066FF"><TT>CMenuView::CMenuView()</TT><TT>{</TT><TT>    m_ptMsg = CPoint(0,0);</TT></FONT></PRE><P><TT>}</TT> The <TT>CMenuView::OnDraw</TT> member function resembles the <TT>OnDraw</TT>member function from <TT>CMouseTestView</TT> in Hour 8. Both functions use the <TT>TextOut</TT>function to display a message at a certain point in the view. Edit the <TT>CMenuView::OnDraw</TT>function so that it looks like the function provided in Listing 10.4. You must removea few lines of AppWizard-supplied code.<H4><FONT COLOR="#000077">TYPE: Listing 10.4. The CMenuView::OnDraw member function.</FONT></H4><PRE><FONT COLOR="#0066FF"><TT>void CMenuView::OnDraw(CDC* pDC)</TT><TT>{</TT><TT>    pDC-&gt;TextOut( m_ptMsg.x, m_ptMsg.y, m_szMsg );</TT></FONT></PRE><P><TT>}</TT><H3><FONT COLOR="#000077"><B>Trapping Messages</B></FONT></H3><P>Use ClassWizard to add four new message-handling functions to the <TT>CMenuView</TT>class: three message-handling functions for the new menu items and one message-handlingfunction to detect the right-click from the mouse button. The steps used to add themessage-handling functions are similar to the ones used earlier when modifying anexisting menu, except these messages are handled by the <TT>CMenuView</TT> class.<DL>	<DD>1. Open ClassWizard by pressing Ctrl+W or right-clicking in a source code window	and selecting ClassWizard from the menu.<BR>	<BR>	2. Select the Message Maps tab and select the class that will handle the message	from the Class Name combo box--in this case, <TT>CMenuView</TT>.<BR>	<BR>	3. Select the object that is generating the message from the Object ID list box--in	this case, use one of the values from Table 10.2.<BR>	<BR>	4. Select a message from the Messages list box and click the Add Function button.	Accept the default name suggested by ClassWizard for the function name.<BR>	<BR>	5. Repeat this process for all entries in Table 10.2.<BR>	<BR>	6. Click OK to close ClassWizard.</DL><H4><FONT COLOR="#000077">Table 10.2. Values used to create message-handling functions.</FONT></H4><P><TABLE BORDER="1">	<TR ALIGN="LEFT" rowspan="1">		<TD ALIGN="LEFT" VALIGN="TOP"><B>Object ID</B></TD>		<TD ALIGN="LEFT" VALIGN="TOP"><B>Message</B></TD>		<TD ALIGN="LEFT" VALIGN="TOP"><B>Function</B></TD>	</TR>	<TR ALIGN="LEFT" rowspan="1">		<TD ALIGN="LEFT" VALIGN="TOP"><TT>CMenuView</TT></TD>		<TD ALIGN="LEFT" VALIGN="TOP"><TT>WM_CONTEXTMENU</TT></TD>		<TD ALIGN="LEFT" VALIGN="TOP"><TT>OnContextMenu</TT></TD>	</TR>	<TR ALIGN="LEFT" rowspan="1">		<TD ALIGN="LEFT" VALIGN="TOP"><TT>ID_LIONS</TT></TD>		<TD ALIGN="LEFT" VALIGN="TOP"><TT>COMMAND</TT></TD>		<TD ALIGN="LEFT" VALIGN="TOP"><TT>OnLions</TT></TD>	</TR>	<TR ALIGN="LEFT" rowspan="1">		<TD ALIGN="LEFT" VALIGN="TOP"><TT>ID_TIGERS</TT></TD>		<TD ALIGN="LEFT" VALIGN="TOP"><TT>COMMAND</TT></TD>		<TD ALIGN="LEFT" VALIGN="TOP"><TT>OnTigers</TT></TD>	</TR>	<TR ALIGN="LEFT" rowspan="1">		<TD ALIGN="LEFT" VALIGN="TOP"><TT>ID_BEARS</TT></TD>		<TD ALIGN="LEFT" VALIGN="TOP"><TT>COMMAND</TT></TD>		<TD ALIGN="LEFT" VALIGN="TOP"><TT>OnBears</TT></TD>	</TR></TABLE></P><P>The source code for the <TT>CMenuView::OnContextMenu</TT> message-handling functionis provided in Listing 10.5.<H4><FONT COLOR="#000077">TYPE: Listing 10.5. Popping up a menu when a right mousebutton is clicked.</FONT></H4><PRE><FONT COLOR="#0066FF"><TT>void CMenuView::OnContextMenu(UINT nFlags, CPoint point)</TT><TT>{</TT><TT>    CMenu   zooMenu;</TT><TT>    // Store popup point, and convert to client coordinates</TT><TT>    // for the drawing functions.</TT><TT>    m_ptMsg = point;</TT><TT>    ScreenToClient( &amp;m_ptMsg );</TT><TT>    zooMenu.LoadMenu( ID_POPUP );</TT><TT>    CMenu* pPopup = zooMenu.GetSubMenu( 0 );</TT><TT>    pPopup-&gt;TrackPopupMenu( TPM_LEFTALIGN|TPM_RIGHTBUTTON,</TT><TT>                            point.x,</TT><TT>                            point.y,</TT><TT>                            this );</TT></FONT></PRE><P><TT>}</TT> When a right mouse click is detected, the <TT>WM_CONTEXTMENU</TT> messageis sent to the application and the MFC framework calls the <TT>OnContextMenu</TT>message handler. The <TT>OnContextMenu</TT> function creates a <TT>CMenu</TT> objectand loads the <TT>ID_POPUP</TT> menu resource. The floating menu is displayed bycalling <TT>GetSubMenu</TT> and <TT>TrackPopupMenu</TT>.</P><P>The <TT>GetSubMenu</TT> function is used to skip past the dummy menu item at thetop of the <TT>ID_POPUP</TT> menu resource. The <TT>GetSubMenu</TT> function returnsa temporary pointer to the pop-up menu. Calling <TT>TrackPopupMenu</TT> causes thepop-up menu to be displayed and the menu item selection to automatically follow themouse cursor.</P><P>The source code for handling menu selection messages sent to the <TT>CMenuView</TT>class is provided in Listing 10.6.<H4><FONT COLOR="#000077">TYPE: Listing 10.6. Message-handling functions for floatingmenu items.</FONT></H4><PRE><FONT COLOR="#0066FF"><TT>void CMenuView::OnLions()</TT><TT>{</TT><TT>    m_szMsg = &quot;Lions are out&quot;;</TT><TT>    InvalidateRect( NULL );</TT><TT>}</TT><TT>void CMenuView::OnTigers()</TT><TT>{</TT><TT>    m_szMsg = &quot;Tigers are afoot&quot;;</TT><TT>    InvalidateRect( NULL );</TT><TT>}</TT>

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
久久精品国产成人一区二区三区 | 精品国产成人系列| 一区在线播放视频| 另类小说一区二区三区| 欧美专区亚洲专区| 国产精品久久久久久久久久久免费看| 日本亚洲电影天堂| 色婷婷av一区二区三区大白胸| 久久久久国产精品麻豆ai换脸| 天天综合色天天综合| 99久久久免费精品国产一区二区| 欧美变态tickle挠乳网站| 亚洲第一会所有码转帖| 99国产精品久久久久久久久久| 26uuu精品一区二区三区四区在线 26uuu精品一区二区在线观看 | 不卡在线观看av| 久久天堂av综合合色蜜桃网| 日韩精品一二三区| 在线一区二区视频| 亚洲女同一区二区| 不卡欧美aaaaa| 久久久精品综合| 激情综合色播激情啊| 欧美性大战久久久久久久| 亚洲国产成人一区二区三区| 国产在线播精品第三| 视频一区二区三区入口| 欧美一区二区三区在线看| 久久久久久电影| 色综合久久99| 久久精品水蜜桃av综合天堂| 91丨porny丨户外露出| 亚洲国产日韩综合久久精品| 国产激情一区二区三区四区| 亚洲天堂中文字幕| av电影在线不卡| 欧美亚洲一区二区在线观看| 蜜臀国产一区二区三区在线播放| 97久久精品人人爽人人爽蜜臀| 亚洲国产中文字幕在线视频综合| 国产精品一二二区| 亚洲黄色小视频| 久久久久久**毛片大全| 亚洲激情五月婷婷| 91精品午夜视频| 国产一区二区三区黄视频| 欧美日韩大陆一区二区| 成人一区二区视频| 偷偷要91色婷婷| 国产精品高清亚洲| 91精品国产91久久综合桃花 | 久久精品久久久精品美女| 色就色 综合激情| 国产成人免费网站| 精品欧美一区二区久久 | 亚洲天堂中文字幕| 久久综合网色—综合色88| 欧美亚洲综合在线| 亚洲国产精品一区二区www在线| 日本一区二区三区四区在线视频 | 视频一区视频二区中文| 91国偷自产一区二区三区成为亚洲经典 | 欧美一级日韩一级| 日韩中文字幕91| 欧美在线一区二区| 成人av在线播放网址| 久久精品视频在线看| 国产成人综合网| 美脚の诱脚舐め脚责91| 7777精品伊人久久久大香线蕉超级流畅| 成人三级在线视频| 六月丁香综合在线视频| 欧美日韩成人综合天天影院| 亚洲自拍偷拍九九九| 在线免费亚洲电影| 波多野结衣中文字幕一区二区三区 | 中文字幕一区二区三区精华液| 日韩欧美高清在线| 国产一区二区三区在线观看免费| 天使萌一区二区三区免费观看| 3atv一区二区三区| 在线观看日韩一区| 玉米视频成人免费看| 欧美唯美清纯偷拍| 色综合一区二区三区| 亚洲综合成人在线视频| 亚洲色图视频网| 99re在线精品| 成人性生交大片| 国产黄人亚洲片| 亚洲日本护士毛茸茸| 91黄色激情网站| 肉丝袜脚交视频一区二区| 亚洲成人第一页| 欧美一区二区视频在线观看| 欧美性猛交xxxxxx富婆| 五月婷婷激情综合网| 精品女同一区二区| 国产不卡在线一区| 亚洲免费三区一区二区| 国产欧美一区二区精品久导航| 不卡一区中文字幕| 亚洲成人激情社区| 天天影视网天天综合色在线播放| 久久在线观看免费| 成人国产精品免费观看视频| 一区二区三区不卡视频在线观看 | 欧美日韩一区视频| 精品一区二区免费看| 国产精品欧美一级免费| 国产精品网站一区| 欧美精品精品一区| 国产馆精品极品| 91在线国产观看| 在线视频国产一区| 国产在线播精品第三| 国产成人精品免费看| 亚洲国产一区二区三区青草影视| 26uuu国产在线精品一区二区| 精品久久久久一区| 色婷婷一区二区三区四区| 免费在线观看成人| 国产乱子伦一区二区三区国色天香| 最新欧美精品一区二区三区| 日韩免费高清电影| 中文成人综合网| 日韩一区二区三区在线视频| 久久先锋资源网| 欧美午夜精品免费| 欧美成人vr18sexvr| eeuss国产一区二区三区| 午夜在线成人av| 精品一区二区日韩| 亚洲综合一区在线| 水野朝阳av一区二区三区| 中文成人av在线| 亚洲精品国产第一综合99久久| 久久久国产午夜精品| 国产精品不卡在线| 亚洲一区二区三区中文字幕| 久久精品人人做人人综合| 亚洲色图丝袜美腿| 国产欧美综合色| 亚洲国产另类精品专区| 国产精品日韩精品欧美在线| 亚洲欧美国产高清| 日韩三级视频在线看| 国产精品日产欧美久久久久| 欧美va天堂va视频va在线| 中文字幕免费观看一区| 欧美老肥妇做.爰bbww| 日韩免费成人网| 欧美一区二区三区色| 国产精品乱人伦一区二区| 亚洲电影一区二区| 亚洲丝袜制服诱惑| 蜜臀av一级做a爰片久久| 午夜电影久久久| 国产iv一区二区三区| 欧美日韩国产小视频在线观看| 成人在线一区二区三区| 3d成人h动漫网站入口| 中文字幕av资源一区| 精品国产制服丝袜高跟| 日韩美女精品在线| 美女国产一区二区三区| 日韩高清一级片| 99久久99久久综合| 成人免费观看av| 欧美大胆人体bbbb| 一区二区三区四区不卡视频| 亚洲精品久久久蜜桃| 国产精品自产自拍| 在线电影欧美成精品| 在线一区二区三区四区五区 | 亚洲欧美另类小说| 亚洲男人电影天堂| 亚洲嫩草精品久久| 国产精品一二三| 大白屁股一区二区视频| 精品日韩99亚洲| 久久久久久久久一| 麻豆精品视频在线观看视频| 久久 天天综合| 欧美一区二区三区日韩视频| 欧美一区二区二区| 婷婷激情综合网| 一本大道av伊人久久综合| 日本二三区不卡| 国产精品黄色在线观看| 亚洲免费观看在线视频| 成人一级视频在线观看| 成人动漫中文字幕| 国产无遮挡一区二区三区毛片日本| 国产欧美一区二区在线观看| 一色桃子久久精品亚洲| 成人综合在线观看| 在线观看日产精品| 亚洲精品一二三| 色乱码一区二区三区88|