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

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

?? ch13.htm

?? 21天學會VC的英文版
?? HTM
?? 第 1 頁 / 共 5 頁
字號:
	<TR ALIGN="LEFT" VALIGN="TOP">		<TD ALIGN="LEFT">			<H4>Name		</TD>		<TD ALIGN="LEFT">			<H4>Type		</TD>	</TR>	<TR ALIGN="LEFT" VALIGN="TOP">		<TD ALIGN="LEFT">m_iCurPosition		</TD>		<TD ALIGN="LEFT">int		</TD>	</TR>	<TR ALIGN="LEFT" VALIGN="TOP">		<TD ALIGN="LEFT">m_oaPeople		</TD>		<TD ALIGN="LEFT">CObArray		</TD>	</TR></TABLE></P><P>The other thing that you need to do to the document class to provide support forthe record objects is make sure that the document knows about and understands therecord object that it will be holding. You do this by including the custom classheader file before the header file for the document class is included in the documentclass source code file. Because the document class needs to trigger actions in theview class, it's a good idea to also include the header file for the view class inthe document class.</P><P>To include these header files in your sample application, open the source-codefile for the document class and add the two #include statements as shown in Listing13.9.</P><P><H4>LISTING 13.9. INCLUDING THE CUSTOM AND VIEW CLASSES IN THE DOCUMENT CLASS IMPLEMENTATION.</H4><PRE> 1: // SerializeDoc.cpp : implementation of the CSerializeDoc 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: #define new DEBUG_NEW13: #undef THIS_FILE14: static char THIS_FILE[] = __FILE__;15: #endif16: 17: //////////////////////////////////////////////////////////////////////18: // CSerializeDoc</PRE><P><H4>Adding New Records</H4><P>Before you can navigate the record set, you need to be able to add new recordsto the object array. If you add a private function for adding new records, you canadd new records to the set dynamically as new records are needed. Because new recordsshould be presenting the user with blank or empty data fields, you don't need toset any of the record variables when adding a new record to the object array, soyou can use the default constructor.</P><P>Following the same logic that you used to add new line records on Day 10, youshould add a new person record to the object array in your document class in today'ssample application. Once you add a new record, you can return a pointer to the newrecord so that the view class can directly update the variables in the record object.</P><P>Once the new record is added, you will want to set the current record positionmarker to the new record in the array. This way, the current record number can easilybe determined by checking the position counter.</P><P>If there are any problems in creating the new person record object, let the userknow that the application has run out of available memory and delete the allocatedobject, just as you did on Day 10.</P><P>To add this functionality to your sample application, add a new member functionto the document class. Specify the type as a pointer to your custom class. If younamed your custom class CPerson, the function type is CPerson*. This function needsno arguments. Give the function a name that reflects what it does, such as AddNewRecord.Specify the access for this function as private because it will only be accessedfrom other functions within the document class. You can edit the resulting function,adding the code in Listing 13.10.</P><P><H4>LISTING 13.10. THE CSerializeDoc.AddNewRecord FUNCTION.</H4><PRE> 1: CPerson * CSerializeDoc::AddNewRecord() 2: { 3:     // Create a new CPerson object 4:     CPerson *pPerson = new CPerson(); 5:     try 6:     { 7:         // Add the new person to the object array 8:         m_oaPeople.Add(pPerson); 9:         // Mark the document as dirty10:         SetModifiedFlag();11:         // Set the new position mark12:         m_iCurPosition = (m_oaPeople.GetSize() - 1);13:     }14:     // Did we run into a memory exception?15:     catch (CMemoryException* perr)16:     {17:         // Display a message for the user, giving them the18:         // bad news19:         AfxMessageBox(&quot;Out of memory&quot;, MB_ICONSTOP | MB_OK);20:         // Did we create a line object?21:         if (pPerson)22:         {23:             // Delete it24:             delete pPerson;25:             pPerson = NULL;26:         }27:         // Delete the exception object28:         perr-&gt;Delete();29:     }30:     return pPerson;31: }</PRE><P><H4>Getting the Current Position</H4><P>To aid the user in navigating the record set, it's always helpful to provide aguide about where the user is in the record set. To provide this information, youneed to be able to get the current record number and the total number of recordsfrom the document to display for the user.</P><P>The functions to provide this information are both fairly simple. For the totalnumber of records in the object array, all you need to do is get the size of thearray and return that to the caller.</P><P>For your sample application, add a new member function to the document class.Specify the function type as int, the function name as GetTotalRecords, and the accessas public. Once you add the function, edit it using the code in Listing 13.11.</P><P><H4>LISTING 13.11. THE CSerializeDoc.GetTotalRecords FUNCTION.</H4><PRE>1: int CSerializeDoc::GetTotalRecords()2: {3:     // Return the array count4:     return m_oaPeople.GetSize();5: }</PRE><P>Getting the current record number is almost just as simple. If you are maintaininga position counter in the document class, this variable contains the record numberthat the user is currently editing. As a result, all you need to do is return thevalue of this variable to the calling routine. Because the object array begins withposition 0, you probably need to add 1 to the current position before returning todisplay for the user.</P><P>To add this function to your sample application, add another new member functionto the document class. Specify the type as int, the function name as GetCurRecordNbr,and the access as public. Edit the function using the code in Listing 13.12.</P><P><H4>LISTING 13.12. THE CSerializeDoc.GetCurRecordNbr FUNCTION.</H4><PRE>1: int CSerializeDoc::GetCurRecordNbr()2: {3:     // Return the current position4:     return (m_iCurPosition + 1);5: }</PRE><P><H4>Navigating the Record Set</H4><P>To make your application really useful, you will need to provide the user withsome way of navigating the record set. A base set of functionality for performingthis navigation is a set of functions in the document class to get pointers to specificrecords in the record set. First is a function to get a pointer to the current record.Next are functions to get pointers to the first and last records in the set. Finally,you need functions to get the previous record in the set and the next record in theset. If the user is already editing the last record in the set and attempts to moveto the next record, you can automatically add a new record to the set and providethe user with this new, blank record.</P><P>To add all this functionality, start with the function to return the current record.This function needs to check the value in the position marker to make sure that thecurrent record is a valid array position. Once it has made sure that the currentposition is valid, the function can return a pointer to the current record in thearray.</P><P>To add this function to your sample application, add a new member function tothe document class. Specify the function type as CPerson* (a pointer to the customclass), the function name as GetCurRecord, and the access as public. Edit the function,adding the code in Listing 13.13.</P><P><H4>LISTING 13.13. THE CSerializeDoc.GetCurRecord FUNCTION.</H4><PRE> 1: CPerson* CSerializeDoc::GetCurRecord() 2: { 3:     // Are we editing a valid record number? 4:     if (m_iCurPosition &gt;= 0) 5:         // Yes, return the current record 6:         return (CPerson*)m_oaPeople[m_iCurPosition]; 7:     else 8:         // No, return NULL 9:         return NULL;10: }</PRE><P>The next function you might want to tackle is the function to return the firstrecord in the array. In this function, you need to first check to make sure thatthe array has records. If there are records in the array, set the current positionmarker to 0 and return a pointer to the first record in the array.</P><P>To add this function to your sample application, add a new member function tothe document class. Specify the function type as CPerson* (a pointer to the customclass), the function name as GetFirstRecord, and the access as public. Edit the function,adding the code in Listing 13.14.</P><P><H4>LISTING 13.14. THE CSerializeDoc.GetFirstRecord FUNCTION.</H4><PRE> 1: CPerson* CSerializeDoc::GetFirstRecord() 2: { 3:     // Are there any records in the array? 4:     if (m_oaPeople.GetSize() &gt; 0) 5:     { 6:         // Yes, move to position 0 7:         m_iCurPosition = 0; 8:         // Return the record in position 0 9:         return (CPerson*)m_oaPeople[0];10:     }11:     else12:         // No records, return NULL13:         return NULL;14: }</PRE><P>For the function to navigate to the next record in the set, you need to incrementthe current position marker and then check to see if you are past the end of thearray. If you are not past the end of the array, you need to return a pointer tothe current record in the array. If you are past the end of the array, you need toadd a new record to the end of the array.</P><P>To add this function to your sample application, add a new member function tothe document class. Specify the function type as CPerson* (a pointer to the customclass), the function name as GetNextRecord, and the access as public. Edit the function,adding the code in Listing 13.15.</P><P><H4>LISTING 13.15. THE CSerializeDoc.GetNextRecord FUNCTION.</H4><PRE> 1: CPerson * CSerializeDoc::GetNextRecord() 2: { 3:     // After incrementing the position marker, are we 4:     // past the end of the array? 5:     if (++m_iCurPosition &lt; m_oaPeople.GetSize()) 6:         // No, return the record at the new current position 7:         return (CPerson*)m_oaPeople[m_iCurPosition]; 8:     else 9:         // Yes, add a new record10:         return AddNewRecord();11: }</PRE><P>For the function to navigate to the previous record in the array, you need tomake several checks. First, you need to verify that the array has records. If thereare records in the array, you need to decrement the current position marker. If themarker is less than zero, you need to set the current position marker to equal zero,pointing at the first record in the array. Once you've made it through all of this,you can return a pointer to the current record in the array.</P><P>To add this function to your sample application, add a new member function tothe document class. Specify the function type as CPerson* (a pointer to the customclass), the function name as GetPrevRecord, and the access as public. Edit the function,adding the code in Listing 13.16.</P><P><H4>LISTING 13.16. THE CSerializeDoc.GetPrevRecord FUNCTION.</H4><PRE> 1: CPerson * CSerializeDoc::GetPrevRecord() 2: { 3:     // Are there any records in the array? 4:     if (m_oaPeople.GetSize() &gt; 0) 5:     { 6:         // Once we decrement the current position, 7:         // are we below position 0? 8:         if (--m_iCurPosition &lt; 0) 9:             // If so, set the record to position 010:             m_iCurPosition = 0;11:         // Return the record at the new current position12:         return (CPerson*)m_oaPeople[m_iCurPosition];13:     }14:     else15:         // No records, return NULL16:         return NULL;17: }</PRE><P>For the function that navigates to the last record in the array, you still needto check to make sure that there are records in the array. If the array does haverecords, you can get the current size of the array and set the current position markerto one less than the number of records in the array. This is actually the last recordin the array because the first record in the array is record 0. Once you set thecurrent position marker, you can return a pointer to the last record in the array.</P><P>To add this function to your sample application, add a new member function tothe document class. Specify the function type as CPerson* (a pointer to the customclass), the function name as GetLastRecord, and the access as public. Edit the function,adding the code in Listing 13.17.</P><P><H4>LISTING 13.17. THE CSerializeDoc.GetLastRecord FUNCTION.</H4><PRE> 1: CPerson * CSerializeDoc::GetLastRecord() 2: { 3:     // Are there any records in the array? 4:     if (m_oaPeople.GetSize() &gt; 0) 5:     { 6:         // Move to the last position in the array 7:         m_iCurPosition = (m_oaPeople.GetSize() - 1); 8:         // Return the record in this position 9:         return (CPerson*)m_oaPeople[m_iCurPosition];10:     }11:     else12:         // No records, return NULL13:         return NULL;14: }</PRE><P><H4>Serializing the Record Set</H4><P>When filling in the Serialize functionality in the document class, there's littleto do other than pass the CArchive object to the object array's Serialize function,just as you did on Day 10.</P><P>When reading data from the archive, the object array will query the CArchive objectto determine what object type it needs to create and how many it needs to create.The object array will then create each object in the array and call its Serializefunction, passing the CArchive object to each in turn. This enables the objects inthe object array to read their own variable values from the CArchive object in thesame order that they were written.</P><P>When writing data to the file archive, the object array will call each object'sSerialize function in order, passing the CArchive object (just as when reading fromthe archive). This allows each object in the array to write its own variables intothe archive as necessary.</P><P>For the sample application, edit the document class's Serialize function to passthe CArchive object to the object array's Serialize function, as in Listing 13.18.</P><P><H4>Listing 13.18. THE CSerializeDoc.Serialize FUNCTION.</H4>

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲电影一级片| 中文字幕不卡一区| 日本中文一区二区三区| 欧美丰满嫩嫩电影| 久久se精品一区精品二区| 亚洲免费高清视频在线| 日韩精品电影在线观看| 制服丝袜激情欧洲亚洲| 久久99日本精品| 国产性天天综合网| 99精品视频在线播放观看| 亚洲影院久久精品| 日韩一级片在线观看| 国产成人精品一区二区三区四区| 国产精品视频第一区| 色婷婷综合五月| 另类成人小视频在线| 国产免费观看久久| 欧美色综合天天久久综合精品| 五月天精品一区二区三区| 欧美精品一区二区三区在线播放| 国产精品一区二区男女羞羞无遮挡 | 久久人人97超碰com| 成人av资源下载| 午夜精品一区二区三区电影天堂| 精品国产麻豆免费人成网站| 95精品视频在线| 日本午夜精品视频在线观看| 中文字幕av一区二区三区| 欧美日韩小视频| 国产v综合v亚洲欧| 午夜精品视频在线观看| 国产精品丝袜91| 91精品国产综合久久国产大片| 国产91清纯白嫩初高中在线观看| 亚洲一区二区三区视频在线播放| 欧美mv和日韩mv的网站| 欧美性受xxxx黑人xyx| 国产成人精品一区二区三区网站观看| 亚洲一区影音先锋| 国产精品丝袜一区| 精品国产一区二区三区忘忧草| 91免费视频大全| 国产一区二区三区日韩| 偷拍一区二区三区| 中文字幕亚洲一区二区va在线| 亚洲国产精品一区二区尤物区| 精品1区2区3区| 99国产一区二区三精品乱码| 另类综合日韩欧美亚洲| 亚洲国产一区二区三区青草影视| 国产日韩精品一区二区三区| 日韩欧美一区电影| 欧美日本在线看| 色天使色偷偷av一区二区| 成人黄色一级视频| 国产成人在线看| 精品一区二区日韩| 蜜臀av性久久久久蜜臀aⅴ流畅| 亚洲综合激情小说| 18成人在线观看| 亚洲色图欧洲色图婷婷| 国产日韩精品一区二区浪潮av| 精品少妇一区二区三区日产乱码| 88在线观看91蜜桃国自产| 欧美伊人久久大香线蕉综合69 | 国产91精品精华液一区二区三区| 卡一卡二国产精品| 蜜桃一区二区三区在线观看| 天堂一区二区在线| 香港成人在线视频| 亚洲成av人片一区二区| 亚洲国产日日夜夜| 亚洲综合免费观看高清在线观看| 亚洲欧美日韩国产中文在线| 亚洲婷婷在线视频| 尤物视频一区二区| 一区二区三区四区不卡视频| 亚洲精品国久久99热| 亚洲精品成人在线| 亚洲国产乱码最新视频| 日韩精品乱码av一区二区| 天堂久久一区二区三区| 欧美a一区二区| 激情综合网av| 丰满白嫩尤物一区二区| 国产91精品久久久久久久网曝门| 成人免费不卡视频| 一本色道久久综合精品竹菊| 欧美高清你懂得| 日韩一区二区在线看| 久久亚洲一区二区三区四区| 国产午夜三级一区二区三| 中文字幕日本不卡| 亚洲h动漫在线| 免费成人小视频| 国产成人精品影视| 在线欧美日韩精品| 日韩视频在线一区二区| 中文字幕欧美激情一区| 亚洲欧美一区二区三区孕妇| 亚洲精品国产视频| 美国毛片一区二区三区| 成人精品一区二区三区四区| 欧美主播一区二区三区美女| 欧美肥妇free| 国产欧美精品区一区二区三区 | 欧美va亚洲va国产综合| 日本一区二区三区四区在线视频| 一区二区三区在线免费视频| 日本在线不卡一区| 成人午夜激情在线| 欧美日韩精品免费观看视频| 久久免费看少妇高潮| 亚洲精品国产精品乱码不99 | 亚洲精品在线免费观看视频| 国产精品久久久久久户外露出| 天天爽夜夜爽夜夜爽精品视频| 国产乱码精品一区二区三区av| 一本久久a久久免费精品不卡| 日韩欧美精品在线视频| 97国产一区二区| 制服.丝袜.亚洲.另类.中文| 久久久久久久久久美女| 夜夜精品浪潮av一区二区三区| 激情丁香综合五月| 欧美午夜宅男影院| 国产日韩欧美麻豆| 日本成人在线不卡视频| 91亚洲大成网污www| 精品国产第一区二区三区观看体验| 亚洲欧美日韩在线不卡| 黄色日韩网站视频| 欧美日韩电影在线| 亚洲欧美日韩国产综合| 国产高清亚洲一区| 日韩欧美国产综合一区| 亚洲一区二区欧美日韩| 成人免费高清在线观看| 精品久久久久香蕉网| 亚洲成人中文在线| 色哟哟一区二区三区| 国产精品视频看| 国模娜娜一区二区三区| 欧美一区二区三区四区在线观看 | 日韩欧美在线观看一区二区三区| 亚洲摸摸操操av| 国产成人av电影在线观看| 欧美va日韩va| 免费看日韩a级影片| 欧美日韩一区在线观看| 亚洲狠狠丁香婷婷综合久久久| 成人午夜电影小说| 国产视频亚洲色图| 久久99国产精品免费| 制服丝袜在线91| 日日骚欧美日韩| 欧美午夜精品久久久久久超碰 | 午夜精品久久久久久不卡8050| 色综合久久中文综合久久牛| 国产精品麻豆欧美日韩ww| 懂色av中文一区二区三区| 久久精品欧美一区二区三区不卡| 狠狠色丁香婷综合久久| 久久综合狠狠综合久久综合88| 极品美女销魂一区二区三区| 精品国产乱码久久| 精品系列免费在线观看| 久久无码av三级| 高清久久久久久| 国产精品久久久99| 91影院在线观看| 一级中文字幕一区二区| 欧美手机在线视频| 日本怡春院一区二区| 欧美成人一区二区三区在线观看| 久久99久久99| 国产亚洲欧美在线| 成人激情免费电影网址| 亚洲欧美一区二区久久 | 蜜桃一区二区三区在线| 亚洲精品在线网站| 欧美日韩一区二区三区免费看| 亚洲影视在线观看| 9191国产精品| 国模大尺度一区二区三区| 欧美激情艳妇裸体舞| 91在线精品一区二区| 亚洲高清免费在线| 日韩精品最新网址| 成人app网站| 亚洲一区二区黄色| 精品国产网站在线观看| 成人高清免费在线播放| 亚洲精品成人天堂一二三| 欧美一区二区三区免费在线看| 国产高清在线观看免费不卡| 亚洲视频1区2区| 日韩欧美国产一二三区| 成人网在线播放|