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

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

?? ch22.htm

?? 24小時學會vc++
?? HTM
?? 第 1 頁 / 共 3 頁
字號:
22.2.<H4><FONT COLOR="#000077">Table 22.2. New CString member variables for the CUsersDlgclass.</FONT></H4><P><TABLE BORDER="1">	<TR ALIGN="LEFT" rowspan="1">		<TD ALIGN="LEFT" VALIGN="TOP"><B>Resource ID</B></TD>		<TD ALIGN="LEFT" VALIGN="TOP"><B>Name</B></TD>		<TD ALIGN="LEFT" VALIGN="TOP"><B>Category</B></TD>		<TD ALIGN="LEFT" VALIGN="TOP"><B>Variable Type</B></TD>	</TR>	<TR ALIGN="LEFT" rowspan="1">		<TD ALIGN="LEFT" VALIGN="TOP"><TT>IDC_EDIT_NAME</TT></TD>		<TD ALIGN="LEFT" VALIGN="TOP"><TT>m_szName</TT></TD>		<TD ALIGN="LEFT" VALIGN="TOP"><TT>Value</TT></TD>		<TD ALIGN="LEFT" VALIGN="TOP"><TT>CString</TT></TD>	</TR>	<TR ALIGN="LEFT" rowspan="1">		<TD ALIGN="LEFT" VALIGN="TOP"><TT>IDC_EDIT_ADDR</TT></TD>		<TD ALIGN="LEFT" VALIGN="TOP"><TT>m_szAddr</TT></TD>		<TD ALIGN="LEFT" VALIGN="TOP"><TT>Value</TT></TD>		<TD ALIGN="LEFT" VALIGN="TOP"><TT>CString</TT></TD>	</TR></TABLE><H4><FONT COLOR="#000077">Adding a Menu Item</FONT></H4><P>Use the values from Table 22.3 to add a menu item and message-handling functionto the <TT>CCustomersDoc</TT> class. Add the new menu item, labeled New User...,to the Edit menu in the <TT>IDR_CUSTOMTYPE</TT> menu resource. To reduce the amountof source code required for this example, handle the menu item directly with thedocument class. However, the dialog box can also be handled by a view class or <TT>CMainFrame</TT>.<H4><FONT COLOR="#000077">Table 22.3. New member functions for the CCustomersDocclass.</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>		<TD ALIGN="LEFT" VALIGN="TOP"><B>Event</B></TD>		<TD ALIGN="LEFT" VALIGN="TOP"><B>Function Name</B></TD>	</TR>	<TR ALIGN="LEFT" rowspan="1">		<TD ALIGN="LEFT" VALIGN="TOP"><TT>ID_EDIT_USER</TT></TD>		<TD ALIGN="LEFT" VALIGN="TOP">Add User...</TD>		<TD ALIGN="LEFT" VALIGN="TOP"><TT>COMMAND</TT></TD>		<TD ALIGN="LEFT" VALIGN="TOP"><TT>OnEditUser</TT></TD>	</TR></TABLE></P><P>Listing 22.8 contains the complete source code for the <TT>OnEditUser</TT> function,which handles the message sent when the user selects the new menu item. If the userclicks OK, the contents of the dialog box are used to create a new <TT>CUser</TT>object, and a pointer to the new object is added to the <TT>m_setOfUsers</TT> collection.The <TT>SetModifiedFlag</TT> function is called to mark the document as changed.Add the source code provided in Listing 22.8 to the <TT>CCustomersDoc::OnEditUser</TT>member function.<H4><FONT COLOR="#000077">TYPE: Listing 22.8. Adding a new CUser object to the documentclass.</FONT></H4><PRE><FONT COLOR="#0066FF"><TT>void CCustomersDoc::OnEditUser()</TT><TT>{</TT><TT>    CUsersDlg    dlg;</TT><TT>    if( dlg.DoModal() == IDOK )</TT><TT>    {</TT><TT>        CUser*  pUser = new CUser( dlg.m_szName, dlg.m_szAddr );</TT><TT>        m_setOfUsers.Add( pUser );</TT><TT>        UpdateAllViews( NULL );</TT><TT>        SetModifiedFlag();</TT><TT>    }</TT><TT>}</TT></FONT></PRE><P>Add the source code provided in Listing 22.9 to the <TT>CustomersDoc.cpp</TT>source file. These functions provide access to the data contained by the document.The view class, <TT>CCustomerView</TT>, calls the two <TT>CCustomersDoc</TT> memberfunctions provided in Listing 22.9 when updating the view window.<H4><FONT COLOR="#000077">TYPE: Listing 22.9. Document class member functions usedfor data access.</FONT></H4><PRE><FONT COLOR="#0066FF"><TT>int CCustomersDoc::GetCount() const</TT><TT>{</TT><TT>    return m_setOfUsers.GetSize();</TT><TT>}</TT><TT>CUser* CCustomersDoc::GetUser( int nUser ) const</TT><TT>{</TT><TT>    CUser* pUser = 0;</TT><TT>    if( nUser &lt; m_setOfUsers.GetSize() )</TT><TT>       pUser = m_setOfUsers.GetAt( nUser );</TT><TT>    return pUser;</TT><TT>}</TT></FONT></PRE><P>Every document needs a <TT>Serialize</TT> member function. The <TT>CCustomersDoc</TT>class has only one data member so its <TT>Serialize</TT> function deals only with<TT>m_setOfUsers</TT>, as shown in Listing 22.10. Add this source code to the <TT>CCustomersDoc::Serialize</TT>member function.<H4><FONT COLOR="#000077">TYPE: Listing 22.10. Serializing the contents of the documentclass.</FONT></H4><PRE><FONT COLOR="#0066FF"><TT>void CCustomersDoc::Serialize(CArchive&amp; ar)</TT><TT>{</TT><TT>    m_setOfUsers.Serialize( ar );</TT><TT>}</TT></FONT></PRE><P>As discussed earlier in this hour, the <TT>CArray</TT> class uses the <TT>SerializeElements</TT>helper function when the collection is serialized. Add the <TT>SerializeElements</TT>function that was provided earlier in Listing 22.5 to the <TT>CustomersDoc.cpp</TT>source file.</P><P>Add two <TT>#include</TT> statements to the <TT>CustomersDoc.cpp</TT> file sothat the <TT>CCustomersDoc</TT> class can have access to declarations of classesused by <TT>CCustomersDoc</TT>. Add the source code from Listing 22.11 near the topof the <TT>CustomersDoc.cpp</TT> file, just after the other <TT>#include</TT> statements.<H4><FONT COLOR="#000077">TYPE: Listing 22.11. Include statements used by the CCustomersDocclass.</FONT></H4><PRE><FONT COLOR="#0066FF"><TT>#include &quot;Users.h&quot;</TT><TT>#include &quot;UsersDlg.h&quot;</TT></FONT></PRE><H4><FONT COLOR="#000077">Modifying the View</FONT></H4><P>The view class, <TT>CCustomersView</TT>, displays the current contents of thedocument. When the document is updated, the view is repainted and displays the updatedcontents. You must update two functions in the <TT>CCustomersView</TT> class: <TT>OnDraw</TT>and <TT>OnUpdate</TT>.</P><P>AppWizard creates a skeleton version of the <TT>CCustomersView::OnDraw</TT> function.Add the source code from Listing 22.12 to <TT>OnDraw</TT> so that the current documentcontents are displayed in the view. Because this isn't a scrolling view, a limitednumber of items from the document can be displayed.<H4><FONT COLOR="#000077">TYPE: Listing 22.12. Using OnDraw to display the currentdocument's contents.</FONT></H4><PRE><FONT COLOR="#0066FF"><TT>void CCustomersView::OnDraw(CDC* pDC)</TT><TT>{</TT><TT>    CCustomersDoc* pDoc = GetDocument();</TT><TT>    ASSERT_VALID(pDoc);</TT><TT>    // Calculate the space required for a single</TT><TT>    // line of text, including the inter-line area.</TT><TT>    TEXTMETRIC  tm;</TT><TT>    pDC-&gt;GetTextMetrics( &amp;tm );</TT><TT>    int nLineHeight = tm.tmHeight + tm.tmExternalLeading;</TT><TT>    CPoint  ptText( 0, 0 );</TT><TT>    for( int nIndex = 0; nIndex &lt; pDoc-&gt;GetCount(); nIndex++ )</TT><TT>    {</TT><TT>        CString szOut;</TT><TT>        CUser* pUser = pDoc-&gt;GetUser( nIndex );</TT><TT>        szOut.Format( &quot;User = %s, email = %s&quot;,</TT><TT>                      pUser-&gt;GetName(),</TT><TT>                      pUser-&gt;GetAddr() );</TT><TT>        pDC-&gt;TextOut( ptText.x, ptText.y, szOut );</TT><TT>        ptText.y += nLineHeight;</TT><TT>    }</TT><TT>}</TT></FONT></PRE><P>As with most documents, the <TT>CCustomersDoc</TT> class calls <TT>UpdateAllViews</TT>when it is updated. The MFC framework then calls the <TT>OnUpdate</TT> function foreach view connected to the document.</P><P>Use ClassWizard to add a message-handling function for <TT>CCustomersView::OnUpdate</TT>and add the source code from Listing 22.13 to it. The <TT>OnUpdate</TT> functioninvalidates the view; as a result, the view is redrawn with the updated contents.<H4><FONT COLOR="#000077">TYPE: Listing 22.13. Invalidating the view during OnUpdate.</FONT></H4><PRE><FONT COLOR="#0066FF"><TT>void CCustomersView::OnUpdate( CView* pSender,</TT><TT>                               LPARAM lHint,</TT><TT>                               CObject* pHint)</TT><TT>{</TT><TT>    InvalidateRect( NULL );</TT><TT>}</TT></FONT></PRE><P>Add an <TT>#include</TT> statement to the <TT>CustomersView.cpp</TT> file so thatthe view can use the <TT>CUser</TT> class. Add the include statement beneath theother include statements in <TT>CustomersView.cpp</TT>.</P><PRE><FONT COLOR="#0066FF"><TT>#include &quot;Users.h&quot;</TT></FONT></PRE><P>Compile and run the Customers project. Add names to the document by selectingAdd User from the Edit menu. Figure 22.7 shows an example of the Customers projectrunning with a few email addresses.</P><P><A NAME="07"></A><A HREF="07.htm"><B>Figure 22.7.</B> </A><I><BR>The Customers example with some email addresses.</I></P><P>Serialize the contents of the document by saving it to a file, and close the document.You can reload the document by opening the file.<H2><FONT COLOR="#000077"><B>Summary</B></FONT></H2><P>In this hour, you learned about serialization and persistence and how they areused in a Document/View application. You also learned about the <TT>CDocument</TT>functions used for serialization and created a small Document/View serializationexample.<H2><FONT COLOR="#000077"><B>Q&amp;A</B></FONT></H2><DL>	<DD><B>Q I'm having a problem using serialization with classes that have an abstract	base class. What's wrong?</B><BR>	<BR>	<B>A</B> The MFC serialization process is incompatible with abstract base classes.	You can never have an instance of an abstract class; because each serialized object	is created as it is read from an instance of <TT>CArchive</TT>, MFC will attempt	to create an abstract class. This isn't allowed by the C++ language definition.<BR>	<BR>	<B>Q Does it matter where I put the <TT>DECLARE_SERIAL</TT> macro in my class declaration?	I added the macro to my source file, and now I receive compiler errors.</B><BR>	<BR>	<B>A</B> The serialization macros can go anywhere, but you must be sure to specify	the access allowed for the class declaration after the macro. Place a <TT>public</TT>,	<TT>private</TT>, or <TT>protected</TT> label immediately after the macro and your	code should be fine.</DL><H2><FONT COLOR="#000077"><B>Workshop</B></FONT></H2><P>The Workshop is designed to help you anticipate possible questions, review whatyou've learned, and begin thinking ahead to putting your knowledge into practice.The answers to the quiz are in Appendix B, &quot;Quiz Answers.&quot;<H3><FONT COLOR="#000077"><B>Quiz</B></FONT></H3><DL>	<DD>1. What is persistence?<BR>	<BR>	2. What is serialization?<BR>	<BR>	3. What is the difference between serialization and deserialization?<BR>	<BR>	4. What MFC class is used to represent a storage object?<BR>	<BR>	5. What virtual function is implemented by all persistent classes?<BR>	<BR>	6. What is the name of the helper function that assists in serializing a template	collection that contains pointers?</DL><H3><FONT COLOR="#000077"><B>Exercises</B></FONT></H3><DL>	<DD>1. Modify the <TT>CUser</TT> class so that it also contains the postal address	for a user persistently. Modify the Customers project to use the new version of the	<TT>CUsers</TT> class.<BR>	<BR>	2. Modify the Customers project so that the number of items stored in a document	is displayed when the application starts or a file is opened.<FONT COLOR="#000077"></FONT></DL><CENTER><P><HR><A HREF="../ch21/ch21.htm"><IMG SRC="../button/previous.gif" WIDTH="128" HEIGHT="28"ALIGN="BOTTOM" ALT="Previous chapter" BORDER="0"></A><A HREF="../ch23/ch23.htm"><IMGSRC="../button/next.gif" WIDTH="128" HEIGHT="28" ALIGN="BOTTOM" ALT="Next chapter"BORDER="0"></A><A HREF="../index.htm"><IMG SRC="../button/contents.gif" WIDTH="128"HEIGHT="28" ALIGN="BOTTOM" ALT="Contents" BORDER="0"></A> <BR><BR><BR><IMG SRC="../button/corp.gif" WIDTH="284" HEIGHT="45" ALIGN="BOTTOM" ALT="Macmillan Computer Publishing USA"BORDER="0"></P><P>&copy; <A HREF="../copy.htm">Copyright</A>, Macmillan Computer Publishing. Allrights reserved.</CENTER></BODY></HTML>

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
久久 天天综合| 91精品国产综合久久精品app| 亚洲已满18点击进入久久| 国产欧美一区二区三区在线老狼| 91精品免费在线观看| 日本黄色一区二区| 色天使久久综合网天天| www.久久精品| 色综合久久久网| 91网站最新地址| 不卡的av在线播放| 色天天综合色天天久久| 色婷婷av一区二区三区软件| 91久久免费观看| 欧美日韩亚洲综合在线 欧美亚洲特黄一级| 不卡在线观看av| 色综合中文字幕国产 | 91免费国产在线观看| gogogo免费视频观看亚洲一| 色婷婷久久久久swag精品| 欧洲在线/亚洲| 67194成人在线观看| 精品国产91洋老外米糕| 中文字幕国产一区二区| 亚洲已满18点击进入久久| 婷婷一区二区三区| 国产一区二区三区视频在线播放| 国产在线观看免费一区| 99久久伊人网影院| 欧美视频一区二区三区在线观看| 欧美日韩午夜精品| 精品国产伦一区二区三区观看体验| 久久久蜜桃精品| 一区二区不卡在线视频 午夜欧美不卡在| 夜夜嗨av一区二区三区| 麻豆91在线播放免费| 成人一级片网址| 欧美精品在线观看播放| 国产亚洲综合色| 亚洲一卡二卡三卡四卡| 国产黄色成人av| 欧美色倩网站大全免费| 2021国产精品久久精品| 一区二区三区中文在线观看| 国产在线精品一区二区夜色| 色八戒一区二区三区| 久久日一线二线三线suv| 一区二区三区四区av| 国产一区二区三区在线观看免费| 在线观看视频91| 国产亚洲精品7777| 青娱乐精品视频在线| 91丨九色porny丨蝌蚪| 日韩午夜在线播放| 亚洲一区二区精品久久av| 成人丝袜18视频在线观看| 欧美一区二区三区男人的天堂| 国产精品色噜噜| 国产乱子伦视频一区二区三区| 欧美日韩中文国产| 一区二区三区不卡视频在线观看| 国产成人激情av| ww亚洲ww在线观看国产| 日本欧美久久久久免费播放网| 色综合久久久久综合99| 国产精品国产三级国产普通话三级| 久久不见久久见中文字幕免费| 欧美吞精做爰啪啪高潮| 一区二区国产视频| 欧美色爱综合网| 亚洲午夜精品在线| 日本精品裸体写真集在线观看| 亚洲色图视频免费播放| 91麻豆福利精品推荐| 最新成人av在线| 91网页版在线| 亚洲国产欧美日韩另类综合 | 宅男噜噜噜66一区二区66| 一区二区三区91| 欧美日韩精品免费观看视频| 亚洲综合男人的天堂| 欧美午夜视频网站| 天天综合色天天综合色h| 在线播放国产精品二区一二区四区 | 欧美精品一区二区三区高清aⅴ| 天天av天天翘天天综合网色鬼国产| 在线观看日韩毛片| 一区二区三区四区在线免费观看| 成人精品国产免费网站| 国产精品传媒入口麻豆| 九一九一国产精品| 日韩久久久久久| 国产精品性做久久久久久| 久久―日本道色综合久久| 成人美女在线观看| 国产精品久久久久久亚洲毛片 | 日韩一区二区精品| 麻豆91精品91久久久的内涵| 精品国产乱码久久久久久免费 | av在线播放成人| 性久久久久久久久久久久| 555夜色666亚洲国产免| 国产精品一区二区不卡| 国产欧美日韩中文久久| 欧美中文字幕一二三区视频| 视频一区二区不卡| 久久久久久久久久久99999| 国产成人高清在线| 亚洲午夜精品在线| 日韩一级片在线播放| 成人免费看的视频| 亚洲黄色av一区| 精品动漫一区二区三区在线观看 | 国产精品美日韩| 91麻豆视频网站| 国产乱淫av一区二区三区| 亚洲欧洲成人自拍| 欧美日韩精品电影| 首页国产欧美日韩丝袜| 亚洲精品一区二区三区影院| 国产成人精品aa毛片| 蜜臀av国产精品久久久久| 国产欧美一区视频| 欧美一区二区久久久| 欧美亚洲国产怡红院影院| 欧美丝袜丝交足nylons图片| 欧美日韩在线精品一区二区三区激情| 欧美日韩成人高清| 亚洲国产精品影院| 青青草精品视频| 欧美日韩在线免费视频| 国内精品伊人久久久久av影院| 免费在线成人网| 91老师片黄在线观看| 天堂va蜜桃一区二区三区漫画版| 欧美一级日韩一级| 91黄色激情网站| 国产一区在线视频| 老司机精品视频导航| 中文字幕av一区二区三区高| 精品三级av在线| 国产成人免费视频网站| 蜜臀99久久精品久久久久久软件| 日韩色视频在线观看| 欧美系列在线观看| 91激情在线视频| 国产不卡在线视频| 国产成人aaaa| 国产一区 二区| 136国产福利精品导航| 在线观看欧美精品| 婷婷国产v国产偷v亚洲高清| 久久精品欧美一区二区三区麻豆| 91麻豆免费看| 亚洲成av人片观看| 日日欢夜夜爽一区| 在线欧美日韩国产| 午夜日韩在线电影| 日韩免费视频一区| 最新日韩在线视频| 看片网站欧美日韩| 中文字幕日韩欧美一区二区三区| 99亚偷拍自图区亚洲| 亚洲第一久久影院| 欧美tickling网站挠脚心| 欧美中文字幕亚洲一区二区va在线 | 欧美性大战久久久| 国产一区二区三区精品欧美日韩一区二区三区 | ww亚洲ww在线观看国产| 国产69精品久久777的优势| 亚洲蜜臀av乱码久久精品蜜桃| 欧美日韩aaa| 欧美视频中文字幕| 成熟亚洲日本毛茸茸凸凹| 国产美女久久久久| 国产尤物一区二区在线| 国产精品66部| 国产成人av一区| 欧美日本视频在线| 日韩国产一二三区| 美女视频一区在线观看| 成人福利视频在线| 91国在线观看| 91麻豆精品国产综合久久久久久| 狠狠久久亚洲欧美| 久久99精品国产.久久久久| 一区二区三区欧美日韩| 秋霞午夜av一区二区三区| 国产精品久久久久影院| 欧美日韩国产小视频在线观看| 亚洲国产精品久久人人爱| 国产精品美女久久久久久久 | 国产婷婷色一区二区三区| 国产亚洲va综合人人澡精品| 亚洲欧美另类小说| 天天色天天爱天天射综合| 成人午夜精品在线| 色婷婷综合中文久久一本| 亚洲一区二区精品3399| 三级久久三级久久|