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

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

?? ch13.htm

?? 21天學會VC的英文版
?? HTM
?? 第 1 頁 / 共 5 頁
字號:
<PRE>1: void CSerializeDoc::Serialize(CArchive&amp; ar)2: {3:     // Pass the serialization on to the object array4:     m_oaPeople.Serialize(ar);5: }</PRE><P><H4>Cleaning Up</H4><P>Now you need to add the code to clean up the document once the document is closedor a new document is opened. This consists of looping through all objects in theobject array and deleting each and every one. Once all the objects are deleted, theobject array can be reset when you call its RemoveAll function.</P><P>To implement this functionality in your sample application, add an event-handlerfunction to the document class on the DeleteContents event message using the ClassWizard. When editing the function, add the code in Listing 13.19.</P><P><H4>LISTING 13.19. THE CSerializeDoc.DeleteContents FUNCTION.</H4><PRE> 1: void CSerializeDoc::DeleteContents() 2: { 3:     // TODO: Add your specialized code here and/or call the base class 4:  5:     /////////////////////// 6:     // MY CODE STARTS HERE 7:     /////////////////////// 8:  9:     // Get the number of lines in the object array10:     int liCount = m_oaPeople.GetSize();11:     int liPos;12: 13:     // Are there any objects in the array?14:     if (liCount)15:     {16:         // Loop through the array, deleting each object17:         for (liPos = 0; liPos &lt; liCount; liPos++)18:             delete m_oaPeople[liPos];19:         // Reset the array20:         m_oaPeople.RemoveAll();21:     }22: 23:     ///////////////////////24:     // MY CODE ENDS HERE25:     ///////////////////////26: 27:     CDocument::DeleteContents();28: }</PRE><BLOCKQUOTE>	<P><HR><STRONG>NOTE:</STRONG> One thing to keep in mind when writing this code is that you need	to cast the pointer to the view as a pointer of the class of your view object. The	GetNextView function returns a pointer of type CView, so you will not be able to	call any of your additions to the view class until you cast the pointer to your view	class. Casting the pointer tells the compiler that the pointer is really a pointer	to your view object class and thus does contain all the functions that you have added.	If you don't cast the pointer, the compiler will assume that the view object does	not contain any of the functions that you have added and will not allow you to compile	your application.<HR></BLOCKQUOTE><H4>Opening a New Document</H4><P>When a new document is started, you need to present the user with an empty form,ready for new information. To make that empty record ready to accept new information,you need to add a new record into the object array, which is otherwise empty. Thisresults in only one record in the object array. Once the new record is added to thearray, you must modify the view to show that a new record exists; otherwise, theview will continue to display the last record edited from the previous record set(and the user will probably wonder why your application didn't start a new recordset).</P><P>To implement this functionality, you will need to edit the OnNewDocument functionin your document class. This function is already in the document class, so you donot need to add it through the Class Wizard. The first thing that you do in thisfunction is add a new record to the object array. Once the new record is added, youneed to get a pointer to the view object. You use the GetFirstViewPosition functionto get the position of the view object. Using the position returned for the viewobject, you can use the GetNextView function to retrieve a pointer to the view object.Once you have a valid pointer, you can use it to call a function that you will createin the view class to tell the view to refresh the current record information beingdisplayed in the form.</P><P>Locate the OnNewDocument function in the document class source code, and add thecode in Listing 13.20. Before you will be able to compile your application, you willneed to add the NewDataSet function to the view class.</P><P><H4>LISTING 13.20. THE CSerializeDoc.OnNewDocument FUNCTION.</H4><PRE> 1: BOOL CSerializeDoc::OnNewDocument() 2: { 3:     if (!CDocument::OnNewDocument()) 4:         return FALSE; 5:  6:     // TODO: add reinitialization code here 7:     // (SDI documents will reuse this document) 8:  9:     ///////////////////////10:     // MY CODE STARTS HERE11:     ///////////////////////12: 13:     // If unable to add a new record, return FALSE14:     if (!AddNewRecord())15:         return FALSE;16: 17:     // Get a pointer to the view18:     POSITION pos = GetFirstViewPosition();19:     CSerializeView* pView = (CSerializeView*)GetNextView(pos);20:     // Tell the view that it's got a new data set21:     if (pView)22:         pView-&gt;NewDataSet();23: 24:     ///////////////////////25:     // MY CODE ENDS HERE26:     ///////////////////////27: 28:     return TRUE;29: }</PRE><P>When opening an existing data set, you don't need to add any new records, butyou still need to let the view object know that it needs to refresh the record beingdisplayed for the user. As a result, you can add the same code to the OnOpenDocumentfunction as you added to the OnNewDocument, only leaving out the first part whereyou added a new record to the object array.</P><P>Add an event-handler function to the document class for the OnOpenDocument eventusing the Class Wizard. Once you add the function, edit it adding the code in Listing13.21.</P><P><H4>LISTING 13.21. THE CSerializeDoc.OnOpenDocument FUNCTION.</H4><PRE> 1: BOOL CSerializeDoc::OnOpenDocument(LPCTSTR lpszPathName) 2: { 3:     if (!CDocument::OnOpenDocument(lpszPathName)) 4:         return FALSE; 5:  6:     // TODO: Add your specialized creation code here 7:  8:     /////////////////////// 9:     // MY CODE STARTS HERE10:     ///////////////////////11: 12:     // Get a pointer to the view13:     POSITION pos = GetFirstViewPosition();14:     CSerializeView* pView = (CSerializeView*)GetNextView(pos);15:     // Tell the view that it's got a new data set16:     if (pView)17:         pView-&gt;NewDataSet();18: 19:     ///////////////////////20:     // MY CODE ENDS HERE21:     ///////////////////////22: 23:     return TRUE;24: }</PRE><P><H3><A NAME="Heading10"></A>Adding Navigating and Editing Support in the View Class</H3><P>Now that you've added support for the record set to your document class, you needto add the functionality into the view class to navigate, display, and update therecords. When you first designed your view class, you placed a number of controlson the window for viewing and editing the various data elements in each record. Youalso included controls for navigating the record set. Now you need to attach functionalityto those controls to perform the record navigation and to update the record withany data changes the user makes.</P><P>Because of the amount of direct interaction that the form will have with the recordobject--reading variable values from the record and writing new values to the record--itmakes sense that you want to add a record pointer to the view class as a privatevariable. For your example, add a new member variable to the view class, specifythe type as CPerson*, give it a name such as m_pCurPerson, and specify the accessas private. Next, edit the view source code file and include the header file forthe person class, as in Listing 13.22.</P><P><H4>LISTING 13.22. INCLUDING THE CUSTOM OBJECT HEADER IN THE VIEW CLASS SOURCE CODE.</H4><PRE> 1: // SerializeView.cpp : implementation of the CSerializeView class 2: // 3:  4: #include &quot;stdafx.h&quot; 5: #include &quot;Serialize.h&quot; 6:  7: #include &quot;Person.h&quot; 8: #include &quot;SerializeDoc.h&quot; 9: #include &quot;SerializeView.h&quot;10: 11: #ifdef _DEBUG12: .13: .14: .</PRE><P><H4>Displaying the Current Record</H4><P>The first functionality that you will want to add to the view class is the functionalityto display the current record. Because this functionality will be used in severaldifferent places within the view class, it makes the most sense to create a separatefunction to perform this duty. In this function, you get the current values of allthe variables in the record object and place those values in the view class variablesthat are attached to the controls on the window. The other thing that you want todo is get the current record number and the total number of records in the set anddisplay those for the user so that the user knows his or her relative position withinthe record set.</P><P>In your sample application, add a new member function, specify the function typeas void, give the function a name that makes sense, such as PopulateView, and specifythe access as private. In the function, get a pointer to the document object. Onceyou have a valid pointer to the document, format the position text display with thecurrent record number and the total number of records in the set, using the GetCurRecordNbrand GetTotalRecords functions that you added to the document class earlier. Next,if you have a valid pointer to a record object, set all the view variables to thevalues of their respective fields in the record object. Once you set the values ofall of the view class variables, update the window with the variable values, as shownin Listing 13.23.</P><P><H4>LISTING 13.23. THE CSerializeView.PopulateView FUNCTION.</H4><PRE> 1: void CSerializeView::PopulateView() 2: { 3:     // Get a pointer to the current document 4:     CSerializeDoc* pDoc = GetDocument(); 5:     if (pDoc) 6:     { 7:         // Display the current record position in the set 8:         m_sPosition.Format(&quot;Record %d of %d&quot;, pDoc-&gt;GetCurRecordNbr(), 9:                 pDoc-&gt;GetTotalRecords());10:     }11:     // Do we have a valid record object?12:     if (m_pCurPerson)13:     {14:         // Yes, get all of the record values15:         m_bEmployed = m_pCurPerson-&gt;GetEmployed();16:         m_iAge = m_pCurPerson-&gt;GetAge();17:         m_sName = m_pCurPerson-&gt;GetName();18:         m_iMaritalStatus = m_pCurPerson-&gt;GetMaritalStatus();19:     }20:     // Update the display21:     UpdateData(FALSE); 22: }</PRE><P><H4>Navigating the Record Set</H4><P>If you added navigation buttons to your window when you were designing the form,then adding navigation functionality is a simple matter of adding event-handler functionsfor each of these navigation buttons and calling the appropriate navigation functionin the document. Once the document navigates to the appropriate record in the set,you need to call the function you just created to display the current record. Ifthe document navigation functions are returning pointers to the new current recordobject, you should capture that pointer before calling the function to display thecurrent record.</P><P>To add this functionality to your sample application, add an event handler tothe clicked event for the First button using the Class Wizard. In the function, geta pointer to the document object. Once you have a valid pointer to the document,call the document object's GetFirstRecord function, capturing the returned objectpointer in the view CPerson pointer variable. If you receive a valid pointer, callthe PopulateView function to display the record data, as in Listing 13.24.</P><P><H4>LISTING 13.24. THE CSerializeView.OnBfirst FUNCTION.</H4><PRE> 1: void CSerializeView::OnBfirst() 2: { 3:     // TODO: Add your control notification handler code here 4:  5:     // Get a pointer to the current document 6:     CSerializeDoc * pDoc = GetDocument(); 7:     if (pDoc) 8:     { 9:         // Get the first record from the document10:         m_pCurPerson = pDoc-&gt;GetFirstRecord();11:         if (m_pCurPerson)12:         {13:             // Display the current record14:             PopulateView();15:         }16:     }17: }</PRE><P>For the Last button, perform the same steps as for the First button, but callthe document object's GetLastRecord function, as in Listing 13.25.</P><P><H4>LISTING 13.25. THE CSerializeView.OnBlast FUNCTION.</H4><PRE> 1: void CSerializeView::OnBlast() 2: { 3:     // TODO: Add your control notification handler code here 4:  5:     // Get a pointer to the current document 6:     CSerializeDoc * pDoc = GetDocument(); 7:     if (pDoc) 8:     { 9:         // Get the last record from the document10:         m_pCurPerson = pDoc-&gt;GetLastRecord();11:         if (m_pCurPerson)12:         {13:             // Display the current record14:             PopulateView();15:         }16:     }17: }</PRE><P>For the Previous and Next buttons, repeat the same steps again, but call the documentobject's GetPrevRecord and GetNextRecord functions. This final step provides yourapplication with all the navigation functionality necessary to move through the recordset. Also, because calling the document's GetNextRecord on the last record in theset automatically adds a new record to the set, you also have the ability to addnew records to the set as needed.</P><P><H4>Saving Edits and Changes</H4><P>When the user enters changes to the data in the controls on the screen, thesechanges somehow need to make their way into the current record in the document. Ifyou are maintaining a pointer in the view

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
激情久久五月天| 日韩欧美黄色影院| 91女厕偷拍女厕偷拍高清| 国产在线精品一区二区不卡了| 日韩福利电影在线| 五月天一区二区| 视频一区视频二区在线观看| 日韩av电影天堂| 开心九九激情九九欧美日韩精美视频电影 | 视频精品一区二区| 亚洲超碰97人人做人人爱| 亚洲成人福利片| 蜜臀国产一区二区三区在线播放| 蜜臀av性久久久久蜜臀aⅴ四虎| 免费成人在线播放| 国产在线精品一区在线观看麻豆| 国产精品99久久久久久久女警 | 色综合一个色综合亚洲| 欧美优质美女网站| 欧美精品乱码久久久久久按摩 | 国产欧美一区二区精品性| 国产欧美日韩另类视频免费观看| 中文字幕一区在线| 一二三四区精品视频| 日本亚洲最大的色成网站www| 久久不见久久见中文字幕免费| 成人永久看片免费视频天堂| 99视频一区二区三区| 欧美四级电影在线观看| 欧美一区二区三区在线看| 久久久精品一品道一区| 亚洲精品视频自拍| 视频一区欧美日韩| 国产不卡在线播放| 91搞黄在线观看| 精品卡一卡二卡三卡四在线| 国产精品久久毛片a| 亚洲成人动漫精品| 色综合天天综合狠狠| 欧美日韩1区2区| 国产日本一区二区| 亚洲综合色网站| 国产一区免费电影| 在线视频综合导航| 日韩午夜激情免费电影| 欧美韩日一区二区三区| 丝袜诱惑亚洲看片| 成人高清视频在线| 欧美一级久久久| 亚洲欧洲av另类| 美女www一区二区| 91欧美一区二区| 精品国产sm最大网站免费看| 亚洲蜜臀av乱码久久精品| 久久精品国产99国产精品| 91视视频在线直接观看在线看网页在线看| 欧美日韩中文一区| 国产欧美日韩精品一区| 石原莉奈在线亚洲三区| 色综合天天综合网天天狠天天| 欧美成人艳星乳罩| 亚洲成人激情av| 色综合天天综合狠狠| 国产亚洲精品中文字幕| 日本不卡的三区四区五区| 91国产福利在线| 国产精品国产三级国产有无不卡 | 一区二区三区日韩精品| 国产精品18久久久久久久久 | 精品福利一区二区三区| 亚洲精品国久久99热| 国产精品亚洲专一区二区三区 | 欧美久久久一区| 亚洲色欲色欲www| 国产aⅴ精品一区二区三区色成熟| 欧美性色黄大片| 亚洲美女偷拍久久| 成人亚洲一区二区一| 日韩亚洲欧美一区| 亚洲综合av网| 91女厕偷拍女厕偷拍高清| 国产欧美日韩亚州综合| 精品一区二区在线免费观看| 91精品国产综合久久国产大片| 国产精品电影院| 精品一区二区综合| 欧美电影免费提供在线观看| 丝袜美腿亚洲一区| 欧美视频一区二区在线观看| 日韩美女视频一区| 国产一区二区在线电影| 欧美一区二区三区四区五区| 亚洲国产精品欧美一二99| 色欧美乱欧美15图片| 中文字幕精品在线不卡| 国产91清纯白嫩初高中在线观看| 精品久久久久久久久久久久久久久久久| 五月天一区二区三区| 精品视频在线视频| 亚洲制服丝袜一区| 在线观看国产精品网站| 成人免费在线观看入口| jvid福利写真一区二区三区| 久久精品日产第一区二区三区高清版| 久久99精品国产91久久来源| 日韩一区二区在线观看| 麻豆国产精品视频| 91精品蜜臀在线一区尤物| 亚洲成人资源网| 欧美日韩一区三区| 香蕉影视欧美成人| 欧美色窝79yyyycom| 亚洲一区电影777| 欧美午夜片在线观看| 日韩vs国产vs欧美| 日韩欧美亚洲另类制服综合在线| 极品少妇xxxx精品少妇偷拍| 久久精品一区二区三区四区| 成人一区二区三区在线观看| 亚洲欧洲国产日韩| 欧美性做爰猛烈叫床潮| 亚洲国产aⅴ天堂久久| 欧美乱妇20p| 麻豆成人综合网| 欧美激情一区在线观看| 色久优优欧美色久优优| 蜜臀av亚洲一区中文字幕| 久久久99久久| 在线精品视频一区二区| 日本不卡123| 日韩视频免费观看高清完整版在线观看 | 亚洲人成网站影音先锋播放| 欧美午夜精品理论片a级按摩| 午夜国产不卡在线观看视频| 精品欧美黑人一区二区三区| 粗大黑人巨茎大战欧美成人| 亚洲一区二区视频在线观看| 欧美成人性福生活免费看| 成人动漫一区二区在线| 亚洲午夜久久久| 亚洲精品在线电影| 91蜜桃在线免费视频| 日韩精品电影在线| 国产精品三级av在线播放| 精品视频一区 二区 三区| 激情久久五月天| 亚洲一区二区不卡免费| 久久久www成人免费无遮挡大片| 色先锋aa成人| 国产精品乡下勾搭老头1| 亚洲第一在线综合网站| 日本一区二区免费在线| 欧美日本国产视频| 成人免费黄色大片| 日本aⅴ亚洲精品中文乱码| 中文字幕av一区二区三区免费看 | 日韩一区二区三区视频| 成人av资源下载| 青青草伊人久久| 亚洲黄色片在线观看| 久久久国产综合精品女国产盗摄| 欧美日韩一二三| 国产69精品久久久久毛片| 日韩高清不卡一区| 亚洲精品中文字幕乱码三区| www欧美成人18+| 欧美日韩激情一区| 99免费精品在线观看| 国产剧情一区二区| 天天综合色天天| 亚洲综合精品自拍| 中文字幕一区在线观看视频| 精品国产91久久久久久久妲己| 欧美色图激情小说| 91免费版在线| 不卡一二三区首页| 国产麻豆午夜三级精品| 免费在线观看一区二区三区| 亚洲午夜精品17c| 亚洲欧美成人一区二区三区| 国产亚洲一区二区在线观看| 日韩片之四级片| 欧美日韩一区二区三区四区| 91污片在线观看| 成人黄色在线网站| 国产精品亚洲人在线观看| 久久精品国产澳门| 蜜桃久久av一区| 天天免费综合色| 亚洲第一电影网| 亚洲成人综合在线| 亚洲大尺度视频在线观看| 一区二区三区欧美久久| 亚洲精品欧美综合四区| 日韩一区在线看| 亚洲免费看黄网站| 亚洲天堂av老司机| 亚洲视频在线一区| 亚洲欧美电影一区二区| 亚洲精品国产品国语在线app|