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

? 歡迎來(lái)到蟲(chóng)蟲(chóng)下載站! | ?? 資源下載 ?? 資源專(zhuān)輯 ?? 關(guān)于我們
? 蟲(chóng)蟲(chóng)下載站

?? ch07.htm

?? Learning language of Visual C++6
?? HTM
?? 第 1 頁(yè) / 共 4 頁(yè)
字號(hào):
</PRE>
<PRE>}
</PRE>
<P>There's nothing tricky about the SetMessage() and GetMessage() functions, which
perform their assigned tasks precisely. The Serialize() function, however, may inspire
a couple of questions. First, note that the first line of the body of the function
calls the base class's Serialize() function. This is a standard practice for many
functions that override functions of a base class. In this case, the call to CObject::Serialize()
doesn't do much because the CObject class's Serialize() function is empty. Still,
calling the base class's Serialize() function is a good habit to get into because
you may not always be working with classes derived directly from CObject.</P>
<P>After calling the base class's version of the function, Serialize() saves and
loads its data in much the same way a document object does. Because the data members
that must be serialized are CString objects, the program can use the &gt;&gt; and
&lt;&lt; operators to write the strings to the disk.</P>
<P>Towards the top of messages.cpp, after the include statements, add this line:</P>
<P>
<PRE>IMPLEMENT_SERIAL(CMessages, CObject, 0)
</PRE>
<P>The IMPLEMENT_SERIAL() macro is partner to the DECLARE_SERIAL() macro, providing
implementation for the functions that give the class its persistent capabilities.
The macro's three arguments are the name of the class, the name of the immediate
base class, and a schema number, which is like a version number. In most cases, you
use 0 or 1 for the schema number.</P>
<P>
<H3><A NAME="Heading8"></A>Using the CMessages Class in the Program</H3>
<P>Now that CMessages is defined and implemented, member functions of the MultiString
document and view classes can work with it. First, expand CMultiStringDoc and double-click
OnNewDocument() to edit it. Add these lines in place of the TODO comments.</P>
<P>
<PRE>    m_messages.SetMessage(1, &quot;Default Message 1&quot;);
    m_messages.SetMessage(2, &quot;Default Message 2&quot;);
    m_messages.SetMessage(3, &quot;Default Message 3&quot;);
</PRE>
<P>Because the document class can't directly access the data object's protected data
members, it initializes each string by calling the CMessages class's SetMessage()
member function.</P>
<P>Expand CMultiStringView and double-click OnDraw() to edit it. Here's how it should
look when you're finished:</P>
<P>
<PRE>void CMultiStringView::OnDraw(CDC* pDC)
{
        CMultiStringDoc* pDoc = GetDocument();
        ASSERT_VALID(pDoc);
    pDC-&gt;TextOut(20, 20, pDoc-&gt;m_messages.GetMessage(1));
    pDC-&gt;TextOut(20, 40, pDoc-&gt;m_messages.GetMessage(2));
    pDC-&gt;TextOut(20, 60, pDoc-&gt;m_messages.GetMessage(3));
}
</PRE>
<P>As you did for File Demo, add a &quot;Change Messages&quot; item to the Edit menu.
Connect it to a view function called OnEditChangemessages. This function will change
the data by calling the CMessages object's member functions, as in Listing 7.7. The
view class's OnDraw() function also calls the GetMessage() member function to access
the CMessages class's strings.</P>
<P>
<H4>Listing 7.7&#160;&#160;Editing the Data Strings</H4>
<PRE>void CMultiStringView::OnEditChangemessages() 
{
   CMultiStringDoc* pDoc = GetDocument();
   CTime now = CTime::GetCurrentTime();
   CString changetime = now.Format(&quot;Changed at %B %d %H:%M:%S&quot;);
   pDoc-&gt;m_messages.SetMessage(1, CString(&quot;String 1 &quot;) + changetime);
   pDoc-&gt;m_messages.SetMessage(2, CString(&quot;String 2 &quot;) + changetime);
   pDoc-&gt;m_messages.SetMessage(3, CString(&quot;String 3 &quot;) + changetime);
   pDoc-&gt;SetModifiedFlag();
   Invalidate();
</PRE>
<PRE>}
</PRE>
<P>All that remains is to write the document class's Serialize() function, where
the m_messages data object is serialized out to disk. You just delegate the work
to the data object's own Serialize() function, as in Listing 7.8.</P>
<P>
<H4>Listing 7.8&#160;&#160; Serializing the Data Object</H4>
<PRE>void CMultiStringDoc::Serialize(CArchive&amp; ar)
{
    m_messages.Serialize(ar);
        if (ar.IsStoring())
        {
        }
        else
        {
        }
</PRE>
<PRE>}
</PRE>
<P>As you can see, after serializing the m_messages data object, not much is left
to do in the document class's Serialize() function. Notice that the call to m_messages.Serialize()
passes the archive object as its single parameter. Build MultiString now and test
it as you tested File Demo. It should do everything you expect.</P>
<P>
<H2><A NAME="Heading9"></A>Reading and Writing Files Directly</H2>
<P>Although using MFC's built-in serialization capabilities is a handy way to save
and load data, sometimes you need more control over the file-handling process. For
example, you might need to deal with your files nonsequentially, something the Serialize()
function and its associated CArchive object can't handle because they do stream I/O.
In this case, you can handle files almost exactly as they're handled by non-Windows
programmers: creating, reading, and writing files directly. Even when you need to
dig down to this level of file handling, MFC offers help. Specifically, you can use
the CFile class and its derived classes to handle files directly.</P>
<P>
<H3><A NAME="Heading10"></A>The CFile Class</H3>
<P>MFC's CFile class encapsulates all the functions you need to handle any type of
file. Whether you want to perform common sequential data saving and loading or construct
a random access file, the CFile class gets you there. Using the CFile class is a
lot like handling files the old-fashioned C-style way, except that the class hides
some of the busy-work details from you so that you can get the job done quickly and
easily. For example, you can create a file for reading with only a single line of
code. Table 7.1 shows the CFile class's member functions and their descriptions.</P>
<P>
<H4>Table 7.1&#160;&#160;Member Functions of the CFile Class</H4>
<P>
<TABLE BORDER="1">
	<TR ALIGN="LEFT" VALIGN="TOP">
		<TD ALIGN="LEFT"><B>Function</B></TD>
		<TD ALIGN="LEFT"><B>Description</B></TD>
	</TR>
	<TR ALIGN="LEFT" VALIGN="TOP">
		<TD ALIGN="LEFT">CFile</TD>
		<TD ALIGN="LEFT">Creates the CFile object. If passed a filename, it opens the file.</TD>
	</TR>
	<TR ALIGN="LEFT" VALIGN="TOP">
		<TD ALIGN="LEFT">Destructor</TD>
		<TD ALIGN="LEFT">Cleans up a CFile object that's going out of scope. If the file is open, it closes
			that file.</TD>
	</TR>
	<TR ALIGN="LEFT" VALIGN="TOP">
		<TD ALIGN="LEFT">Abort()</TD>
		<TD ALIGN="LEFT">Immediately closes the file with no regard for errors.</TD>
	</TR>
	<TR ALIGN="LEFT" VALIGN="TOP">
		<TD ALIGN="LEFT">Close()</TD>
		<TD ALIGN="LEFT">Closes the file.</TD>
	</TR>
	<TR ALIGN="LEFT" VALIGN="TOP">
		<TD ALIGN="LEFT">Duplicate()</TD>
		<TD ALIGN="LEFT">Creates a duplicate file object.</TD>
	</TR>
	<TR ALIGN="LEFT" VALIGN="TOP">
		<TD ALIGN="LEFT">Flush()</TD>
		<TD ALIGN="LEFT">Flushes data from the stream.</TD>
	</TR>
	<TR ALIGN="LEFT" VALIGN="TOP">
		<TD ALIGN="LEFT">GetFileName()</TD>
		<TD ALIGN="LEFT">Gets the file's filename.</TD>
	</TR>
	<TR ALIGN="LEFT" VALIGN="TOP">
		<TD ALIGN="LEFT">GetFilePath()</TD>
		<TD ALIGN="LEFT">Gets the file's full path.</TD>
	</TR>
	<TR ALIGN="LEFT" VALIGN="TOP">
		<TD ALIGN="LEFT">GetFileTitle()</TD>
		<TD ALIGN="LEFT">Gets the file's title (the filename without the extension).</TD>
	</TR>
	<TR ALIGN="LEFT" VALIGN="TOP">
		<TD ALIGN="LEFT">GetLength()</TD>
		<TD ALIGN="LEFT">Gets the file's length.</TD>
	</TR>
	<TR ALIGN="LEFT" VALIGN="TOP">
		<TD ALIGN="LEFT">GetPosition()</TD>
		<TD ALIGN="LEFT">Gets the current position within the file.</TD>
	</TR>
	<TR ALIGN="LEFT" VALIGN="TOP">
		<TD ALIGN="LEFT">GetStatus()</TD>
		<TD ALIGN="LEFT">Gets the file's status.</TD>
	</TR>
	<TR ALIGN="LEFT" VALIGN="TOP">
		<TD ALIGN="LEFT">LockRange()</TD>
		<TD ALIGN="LEFT">Locks a portion of the file.</TD>
	</TR>
	<TR ALIGN="LEFT" VALIGN="TOP">
		<TD ALIGN="LEFT">Open()</TD>
		<TD ALIGN="LEFT">Opens the file.</TD>
	</TR>
	<TR ALIGN="LEFT" VALIGN="TOP">
		<TD ALIGN="LEFT">Read()</TD>
		<TD ALIGN="LEFT">Reads data from the file.</TD>
	</TR>
	<TR ALIGN="LEFT" VALIGN="TOP">
		<TD ALIGN="LEFT">Remove()</TD>
		<TD ALIGN="LEFT">Deletes a file.</TD>
	</TR>
	<TR ALIGN="LEFT" VALIGN="TOP">
		<TD ALIGN="LEFT">Rename()</TD>
		<TD ALIGN="LEFT">Renames the file.</TD>
	</TR>
	<TR ALIGN="LEFT" VALIGN="TOP">
		<TD ALIGN="LEFT">Seek()</TD>
		<TD ALIGN="LEFT">Sets the position within the file.</TD>
	</TR>
	<TR ALIGN="LEFT" VALIGN="TOP">
		<TD ALIGN="LEFT">SeekToBegin()</TD>
		<TD ALIGN="LEFT">Sets the position to the beginning of the file.</TD>
	</TR>
	<TR ALIGN="LEFT" VALIGN="TOP">
		<TD ALIGN="LEFT">SeekToEnd()</TD>
		<TD ALIGN="LEFT">Sets the position to the end of the file.</TD>
	</TR>
	<TR ALIGN="LEFT" VALIGN="TOP">
		<TD ALIGN="LEFT">SetFilePath()</TD>
		<TD ALIGN="LEFT">Sets the file's path.</TD>
	</TR>
	<TR ALIGN="LEFT" VALIGN="TOP">
		<TD ALIGN="LEFT">SetLength()</TD>
		<TD ALIGN="LEFT">Sets the file's length.</TD>
	</TR>
	<TR ALIGN="LEFT" VALIGN="TOP">
		<TD ALIGN="LEFT">SetStatus()</TD>
		<TD ALIGN="LEFT">Sets the file's status.</TD>
	</TR>
	<TR ALIGN="LEFT" VALIGN="TOP">
		<TD ALIGN="LEFT">UnlockRange()</TD>
		<TD ALIGN="LEFT">Unlocks a portion of the file.</TD>
	</TR>
	<TR ALIGN="LEFT" VALIGN="TOP">
		<TD ALIGN="LEFT">Write()</TD>
		<TD ALIGN="LEFT">Writes data to the file.</TD>
	</TR>
</TABLE>
</P>
<P>As you can see from Table 7.1, the CFile class offers plenty of file-handling
power. This section demonstrates how to call a few of the CFile class's member functions.
However, most of the other functions are just as easy to use.</P>
<P>Here's a sample snippet of code that creates and opens a file, writes a string
to it, and then gathers some information about the file:</P>
<P>
<PRE>    // Create the file.
    CFile file(&quot;TESTFILE.TXT&quot;, CFile::modeCreate | CFile::modeWrite);
    // Write data to the file.
    CString message(&quot;Hello file!&quot;);
    int length = message.GetLength();
    file.Write((LPCTSTR)message, length);
    // Obtain information about the file.
    CString filePath = file.GetFilePath();
    Int fileLength = file.GetLength();
</PRE>
<P>Notice that you don't have to explicitly open the file when you pass a filename
to the constructor, whose arguments are the name of the file and the file access
mode flags. You can use several flags at a time simply by ORing their values together,
as in the little snippet above. These flags, which describe how to open the file
and which specify the types of valid operations, are defined as part of the CFile
class and are described in Table 7.2.</P>
<P>
<H4>Table 7.2&#160;&#160;The File Mode Flags</H4>
<P>
<TABLE BORDER="1">
	<TR ALIGN="LEFT" VALIGN="TOP">
		<TD ALIGN="LEFT"><B>Flag</B></TD>
		<TD ALIGN="LEFT"><B>Description</B></TD>
	</TR>
	<TR ALIGN="LEFT" VALIGN="TOP">
		<TD ALIGN="LEFT">CFile::modeCreate</TD>
		<TD ALIGN="LEFT">Creates a new file or truncates an existing file to length 0</TD>
	</TR>

?? 快捷鍵說(shuō)明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲一区二区五区| 亚洲精品亚洲人成人网在线播放| 国产精品一区专区| 中文字幕第一区第二区| 在线观看视频欧美| 精品一二三四区| 亚洲欧美偷拍卡通变态| 日韩欧美亚洲国产另类| 白白色亚洲国产精品| 日韩有码一区二区三区| 中文字幕不卡在线| 久久久三级国产网站| 欧美精品18+| 在线视频观看一区| 成人av在线影院| 国产乱码精品一区二区三区av| 日日欢夜夜爽一区| 亚洲图片欧美视频| 综合分类小说区另类春色亚洲小说欧美| 欧美一级国产精品| 欧美高清你懂得| 欧美在线看片a免费观看| 粉嫩蜜臀av国产精品网站| 毛片av中文字幕一区二区| 污片在线观看一区二区| 亚洲一级二级三级| 亚洲综合区在线| 中文字幕在线不卡视频| 亚洲国产成人自拍| 日本一区二区电影| 久久久午夜精品理论片中文字幕| 欧美tickle裸体挠脚心vk| 欧美一区二区三区婷婷月色| 欧美日韩dvd在线观看| 欧美色老头old∨ideo| 欧美自拍丝袜亚洲| 欧美色综合久久| 日本乱人伦一区| 91久久精品一区二区三| 色婷婷综合中文久久一本| av一区二区久久| 一本到一区二区三区| 一本久久a久久精品亚洲| 色狠狠色狠狠综合| 欧美日韩精品一区二区三区| 欧美日韩免费不卡视频一区二区三区 | 欧美videossexotv100| 日韩午夜激情免费电影| 精品精品国产高清一毛片一天堂| 精品国产91洋老外米糕| 国产无一区二区| 国产精品高潮久久久久无| 亚洲精品v日韩精品| 亚洲午夜av在线| 免费欧美高清视频| 国产精品一区一区三区| 成人免费观看视频| 色婷婷久久综合| 欧美一区二区三区四区五区| 久久久久青草大香线综合精品| 国产日韩欧美一区二区三区乱码| 亚洲人成在线观看一区二区| 亚洲不卡一区二区三区| 免费成人美女在线观看| 国产综合色精品一区二区三区| 国产99久久久国产精品潘金| 91小宝寻花一区二区三区| 欧美精品亚洲一区二区在线播放| 精品久久国产老人久久综合| 国产精品成人免费在线| 亚洲成精国产精品女| 国产在线观看一区二区| 91麻豆精东视频| 日韩精品中文字幕在线不卡尤物| 中文字幕 久热精品 视频在线| 亚洲一区二区精品视频| 久久99国产精品麻豆| 99re热这里只有精品免费视频| 欧美美女喷水视频| 国产午夜精品久久久久久久| 亚洲图片自拍偷拍| 国产91清纯白嫩初高中在线观看| 欧美性淫爽ww久久久久无| 欧美精品一区二区三| 亚洲一区在线视频| 国产精品综合av一区二区国产馆| 欧美白人最猛性xxxxx69交| 亚洲欧洲成人精品av97| 日韩av在线免费观看不卡| 国产不卡视频在线观看| 欧美高清一级片在线| 国产精品乱人伦一区二区| 天天亚洲美女在线视频| 91香蕉视频污在线| 久久久一区二区三区捆绑**| 亚洲一区二区三区四区五区中文| 国产精品一区二区在线播放 | 国产精品毛片无遮挡高清| 香蕉久久夜色精品国产使用方法| 成人精品高清在线| 欧美成人三级在线| 亚洲va国产天堂va久久en| 成人av动漫在线| 久久嫩草精品久久久精品| 天天亚洲美女在线视频| 一本色道久久加勒比精品| 亚洲国产成人午夜在线一区| 久久成人18免费观看| 欧美肥大bbwbbw高潮| 亚洲久本草在线中文字幕| 高清成人免费视频| 欧美哺乳videos| 日本成人超碰在线观看| 欧美视频中文字幕| 日韩理论电影院| 福利一区二区在线| 2020国产精品| 麻豆91在线看| 日韩你懂的在线播放| 三级影片在线观看欧美日韩一区二区| 色综合一区二区三区| 中文字幕在线播放不卡一区| 成人免费毛片高清视频| 国产喂奶挤奶一区二区三区| 国产一区二区三区在线看麻豆| 日韩美女一区二区三区| 日本午夜精品视频在线观看| 欧美精品vⅰdeose4hd| 午夜精品久久久久久久 | 国产精品久久久久一区| 国模少妇一区二区三区| 精品电影一区二区| 国产在线一区二区综合免费视频| 精品久久久久久综合日本欧美| 久久成人羞羞网站| 精品国产精品一区二区夜夜嗨| 久久99最新地址| 久久久久久久久久久黄色| 国产麻豆成人传媒免费观看| 久久久国产精品麻豆| 国产高清在线精品| 中文字幕一区二区三区在线不卡 | 国产一本一道久久香蕉| 久久一区二区三区四区| 风间由美一区二区av101| 国产精品久久影院| 91网站在线播放| 亚洲成人一区二区在线观看| 欧美一区日韩一区| 国内精品伊人久久久久av影院| 国产欧美va欧美不卡在线| 波多野结衣在线一区| 亚洲伦在线观看| 欧美日韩国产片| 久久er99精品| 欧美激情综合五月色丁香 | 处破女av一区二区| 亚洲美女偷拍久久| 欧美丰满一区二区免费视频| 久草中文综合在线| 国产精品你懂的在线| 欧美色视频一区| 久久99精品国产麻豆婷婷洗澡| 国产精品毛片高清在线完整版| 日本精品一区二区三区高清 | 2024国产精品| gogogo免费视频观看亚洲一| 亚洲二区在线观看| 久久网这里都是精品| www.亚洲精品| 日韩不卡一区二区三区| 国产午夜亚洲精品午夜鲁丝片 | 久久精品国内一区二区三区| 欧美经典一区二区| 精品视频资源站| 国产福利不卡视频| 亚洲精品中文在线影院| 精品久久五月天| 欧美在线高清视频| 狠狠v欧美v日韩v亚洲ⅴ| 亚洲综合区在线| 国产亚洲欧美在线| 欧美日韩国产美| av一二三不卡影片| 蜜臀av性久久久久av蜜臀妖精| 中文字幕日韩一区| 日韩精品一区二区在线| 91啦中文在线观看| 极品美女销魂一区二区三区| 亚洲综合一区二区精品导航| 国产日产欧美一区| 91精品国产一区二区三区香蕉| 91亚洲永久精品| 国产一区二区三区电影在线观看| 一区二区三区国产精华| 国产拍欧美日韩视频二区 | 一区二区三区四区在线免费观看| 日韩欧美在线123| 欧美日韩精品欧美日韩精品一| 成人爱爱电影网址|