亚洲欧美第一页_禁久久精品乱码_粉嫩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一区二区三区免费野_久草精品视频
国产亚洲一区二区三区四区| 狠狠色综合播放一区二区| 午夜精品久久久久久久久久久| 麻豆久久久久久| 色妞www精品视频| 国产婷婷色一区二区三区| 亚洲动漫第一页| 91麻豆视频网站| 国产欧美日本一区二区三区| 免费成人在线观看| 欧美日韩一级片网站| 国产精品国产精品国产专区不片| 一区av在线播放| 99麻豆久久久国产精品免费| 久久色视频免费观看| 看片的网站亚洲| 欧美午夜电影在线播放| 国产精品成人一区二区三区夜夜夜| 国产一区二区三区高清播放| 欧美成人三级电影在线| 免费精品视频最新在线| 91精品国产综合久久精品图片| 亚洲三级在线播放| 99精品国产热久久91蜜凸| 亚洲国产精品ⅴa在线观看| 国产精品亚洲а∨天堂免在线| 日韩欧美123| 精品一区二区在线观看| 日韩视频永久免费| 精品在线播放免费| 欧美一级二级三级乱码| 亚洲国产sm捆绑调教视频 | 国产成人av电影在线播放| 日韩欧美国产成人一区二区| 日本成人在线不卡视频| 日韩欧美国产一区二区三区| 美国欧美日韩国产在线播放| 欧美成人一区二区| 国产在线一区观看| 欧美激情自拍偷拍| 色综合久久九月婷婷色综合| 亚洲精品老司机| 欧美日韩高清不卡| 久久99久久精品| 欧美激情一区在线| 色国产综合视频| 亚洲第一主播视频| 日韩亚洲欧美在线| 国产成人在线影院| 亚洲精选一二三| 678五月天丁香亚洲综合网| 免费成人在线视频观看| 久久精品一区二区三区不卡| 成人av影视在线观看| 亚洲日本va午夜在线影院| 欧美无砖砖区免费| 久久99精品国产麻豆婷婷洗澡| 欧美激情一区二区三区不卡 | 国产成人8x视频一区二区 | 中文字幕av一区二区三区| 成人91在线观看| 香蕉影视欧美成人| 久久久久国产精品厨房| 91论坛在线播放| 蜜臀久久99精品久久久久宅男 | 肉丝袜脚交视频一区二区| 久久久精品国产免大香伊| 色呦呦日韩精品| 久久成人av少妇免费| 亚洲视频一区在线观看| 日韩欧美亚洲国产另类 | 亚洲视频小说图片| 欧美成人三级电影在线| 91色|porny| 国产精品一区二区在线观看不卡| 亚洲激情男女视频| 久久久三级国产网站| 欧美无乱码久久久免费午夜一区| 国产一区二区精品久久| 香蕉久久一区二区不卡无毒影院| 国产欧美一区二区三区沐欲| 91精品视频网| 日本乱码高清不卡字幕| 国产超碰在线一区| 蜜臀a∨国产成人精品| 一区二区三区日本| 中文字幕在线不卡一区| 精品久久久久99| 欧美久久久影院| 福利一区二区在线| 麻豆久久一区二区| 五月婷婷激情综合| 专区另类欧美日韩| 国产欧美日韩久久| 精品国产sm最大网站免费看| 欧美三区在线视频| 在线精品亚洲一区二区不卡| 99国产一区二区三精品乱码| 国产精品一色哟哟哟| 久久99九九99精品| 老司机免费视频一区二区| 日日摸夜夜添夜夜添亚洲女人| 亚洲欧美色一区| 国产精品二三区| 国产精品久久久久久福利一牛影视 | 日韩一区二区三区视频| 欧美日韩一二区| 色天使色偷偷av一区二区| 99热这里都是精品| 97久久超碰国产精品电影| 成人污视频在线观看| 成人毛片在线观看| 不卡电影一区二区三区| 粉嫩久久99精品久久久久久夜| 国产精品资源网站| 高清久久久久久| av亚洲精华国产精华精| 成人av免费观看| 91电影在线观看| 欧美精品成人一区二区三区四区| 欧美男女性生活在线直播观看| 欧美乱妇23p| 日韩精品中文字幕在线一区| 精品少妇一区二区三区在线播放| 久久久久综合网| 亚洲日本在线看| 午夜一区二区三区在线观看| 午夜视频在线观看一区二区| 麻豆成人免费电影| 国产一区在线观看视频| 成人激情动漫在线观看| 色婷婷国产精品久久包臀| 91精品在线一区二区| 久久久久久97三级| 日韩毛片在线免费观看| 日日嗨av一区二区三区四区| 国模冰冰炮一区二区| 成人18视频日本| 欧美另类久久久品| 精品捆绑美女sm三区| 中文字幕一区二区视频| 婷婷国产在线综合| 国产一区二区日韩精品| 91丨porny丨国产入口| 91.xcao| 成人免费小视频| 日韩中文字幕av电影| 国产精品综合一区二区三区| 99久久免费视频.com| 日韩三级视频在线观看| 中文字幕一区二区三区在线不卡| 亚洲一区二区三区四区中文字幕| 久久精品国产99国产精品| 91在线小视频| 久久综合色播五月| 亚洲人123区| 国产精品一区二区三区四区| 91精品国产丝袜白色高跟鞋| 国产片一区二区| 日欧美一区二区| 91丨九色porny丨蝌蚪| 欧美不卡一区二区三区| 亚洲精品久久久蜜桃| 国内精品久久久久影院一蜜桃| 色先锋资源久久综合| 国产无遮挡一区二区三区毛片日本| 亚洲一区二区三区中文字幕| 国产电影精品久久禁18| 911精品国产一区二区在线| 国产精品国产自产拍高清av王其| 日韩高清不卡一区| 色菇凉天天综合网| 中文字幕av免费专区久久| 老司机精品视频导航| 欧美日韩电影在线| 亚洲色图制服诱惑| 成人av在线一区二区| 久久综合999| 麻豆免费精品视频| 91精品啪在线观看国产60岁| 亚洲亚洲精品在线观看| 99国产精品99久久久久久| 国产色婷婷亚洲99精品小说| 久久精品国产第一区二区三区 | av资源网一区| 久久久久久久久久久久久久久99| 蜜臀av国产精品久久久久| 欧美精品一二三| 亚洲综合丁香婷婷六月香| 91在线视频18| 国产精品护士白丝一区av| 成人一道本在线| 国产精品毛片a∨一区二区三区| 国产精品亚洲午夜一区二区三区| 欧美成人精品二区三区99精品| 免费在线观看一区二区三区| 制服丝袜亚洲播放| 日韩av电影免费观看高清完整版在线观看 | 欧美一区二区三区四区视频| 亚洲国产精品麻豆|