﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>C++博客-CPLUSPLUS</title><link>http://www.cppblog.com/CPLUSPLUS/</link><description /><language>zh-cn</language><lastBuildDate>Fri, 10 Apr 2026 04:17:31 GMT</lastBuildDate><pubDate>Fri, 10 Apr 2026 04:17:31 GMT</pubDate><ttl>60</ttl><item><title>关于CStdioFile</title><link>http://www.cppblog.com/CPLUSPLUS/archive/2006/04/29/6457.html</link><dc:creator>伏羲</dc:creator><author>伏羲</author><pubDate>Sat, 29 Apr 2006 08:01:00 GMT</pubDate><guid>http://www.cppblog.com/CPLUSPLUS/archive/2006/04/29/6457.html</guid><wfw:comment>http://www.cppblog.com/CPLUSPLUS/comments/6457.html</wfw:comment><comments>http://www.cppblog.com/CPLUSPLUS/archive/2006/04/29/6457.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/CPLUSPLUS/comments/commentRss/6457.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/CPLUSPLUS/services/trackbacks/6457.html</trackback:ping><description><![CDATA[
		<p>CStdioFile继承自CFile，一个CStdioFile 对象代表一个用运行时函数fopen 打开的C 运行时流式文件。<br />流式文件是被缓冲的，而且可以以文本方式（缺省）或二进制方式打开。文本方式提供对硬回车—换行符对的特殊处理。当你将一个换行符（0x0A）写入一个文本方式的CStdioFile 对象时，字节对（0x0D，0x0A）被发送给该文件。当你读一个文件时，字节对（0x0D，0x0A）被翻译为一个字节（0x0A）。<br />CStdioFile 不支持Duplicate，LockRange，和UnlockRange 这几个CFile 函数。如果在CStdioFile 中调用了这几个函数，将会出现CNoSupported 异常。<br /><br />CStdioFile::ReadString(LPTSTR lpsz, UINT nMax);<br />读取一行文本到缓冲区，遇到“0x0D,0x0A”时停止读取，并且去掉硬回车“0x0D”,保留换行符“0x0A”,在字符串末尾添加“\0”(0x00)。nMax个字符里包含0x00这个字符。分析如下：<br />1）如果nMax &lt;= 字符数，读取(nMax－1)个字符 + 0x00<br />2）如果nMax  = 字符数 + 1，读取nMax个字符 + 0x00<br />3）如果nMax  &gt; 字符数，读取nMax个字符 + 0x0A + 0x00</p>
		<p>CStdioFile::ReadString(CString &amp;rString);（重载）<br />读取一行文本到rString，遇到回车换行符停止读取。回车和换行符不读到rString，而且末尾也没有添加“\0”。</p>
		<p>CStdioFile::WriteString( LPCTSTR lpsz );（不支持CString直接写入）<br />将一个缓冲区中的数据写入与CStdioFile 对象关联的文件中。结束的空字符（“\0”）不被写入该文件。lpsz 中的所有换行符都被以一个硬回车换行符对写入该文件，即“\n”被转化成“\r\n”写入到文件里。</p>
<img src ="http://www.cppblog.com/CPLUSPLUS/aggbug/6457.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/CPLUSPLUS/" target="_blank">伏羲</a> 2006-04-29 16:01 <a href="http://www.cppblog.com/CPLUSPLUS/archive/2006/04/29/6457.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>编辑控件和微调控件</title><link>http://www.cppblog.com/CPLUSPLUS/archive/2006/04/15/5624.html</link><dc:creator>伏羲</dc:creator><author>伏羲</author><pubDate>Sat, 15 Apr 2006 11:07:00 GMT</pubDate><guid>http://www.cppblog.com/CPLUSPLUS/archive/2006/04/15/5624.html</guid><wfw:comment>http://www.cppblog.com/CPLUSPLUS/comments/5624.html</wfw:comment><comments>http://www.cppblog.com/CPLUSPLUS/archive/2006/04/15/5624.html#Feedback</comments><slash:comments>2</slash:comments><wfw:commentRss>http://www.cppblog.com/CPLUSPLUS/comments/commentRss/5624.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/CPLUSPLUS/services/trackbacks/5624.html</trackback:ping><description><![CDATA[把编辑控件设为微调控件的伙伴（<font color="#ff0000">Buddy</font>）后，可以用微调控件的函数(<span lang="EN-US" style="FONT-SIZE: 10.5pt; COLOR: #5e5e5e; FONT-FAMILY: 'Times New Roman'; mso-bidi-font-size: 8.0pt; mso-fareast-font-family: 宋体; mso-font-kerning: 1.0pt; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA"><font color="#ff0000">int SetBase(int nBase);</font>)</span>很方便地显示十六进制数据。<span lang="EN-US" style="FONT-SIZE: 10.5pt; COLOR: #5e5e5e; FONT-FAMILY: 'Times New Roman'; mso-bidi-font-size: 8.0pt; mso-fareast-font-family: 宋体; mso-font-kerning: 1.0pt; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA"><font color="#ff0000"><br /></font></span><img src ="http://www.cppblog.com/CPLUSPLUS/aggbug/5624.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/CPLUSPLUS/" target="_blank">伏羲</a> 2006-04-15 19:07 <a href="http://www.cppblog.com/CPLUSPLUS/archive/2006/04/15/5624.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>MFC程序的诞生与死亡</title><link>http://www.cppblog.com/CPLUSPLUS/archive/2006/03/13/4087.html</link><dc:creator>伏羲</dc:creator><author>伏羲</author><pubDate>Mon, 13 Mar 2006 06:55:00 GMT</pubDate><guid>http://www.cppblog.com/CPLUSPLUS/archive/2006/03/13/4087.html</guid><wfw:comment>http://www.cppblog.com/CPLUSPLUS/comments/4087.html</wfw:comment><comments>http://www.cppblog.com/CPLUSPLUS/archive/2006/03/13/4087.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.cppblog.com/CPLUSPLUS/comments/commentRss/4087.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/CPLUSPLUS/services/trackbacks/4087.html</trackback:ping><description><![CDATA[注：摘抄自候捷的《深入浅出MFC》第二版。<BR><BR>程序的诞生：<BR>1.&nbsp; CWinApp theApp;<BR>&nbsp;&nbsp;&nbsp;&nbsp; Application object产生，内存获得配置，初值也设立了。<BR>2. AfxWinMain执行AfxWinInit，后者又调用AfxInitThread，把消息队列尽量加大到96。<BR>3. AfxWinMain执行InitApplication。这是CWinApp的虚函数，但我们通常不改写它。<BR>4. AfxWinMain执行InitInstance。这是CWinApp的虚函数，但我们必须改写它。<BR>5. CMyWinApp::InitInstance‘new’了一个CMyFrameWnd对象。<BR>6. CMyFrameWnd构造函数调用Create，产生窗口种类，自行为我们注册一个名为“AfxFrameOrView42d”的窗口类。<BR>7. 回到InitInstance中继续执行ShowWindow，显示窗口。<BR>8. 执行UpdateWindow，于是发出WM_PAINT。<BR>9. 回到AfxWinMain，执行Run，进入消息循环。<BR><BR>程序开始运行：<BR>1. 程序获得WM_PAINT消息（藉由CWinApp::Run中的::GetMessage循环）。<BR>2. WM_PAINT经由::DispatchMessage送到窗口函数Cwnd::DefWindowProc中。<BR>3. CWnd::DefWindowProc将消息传递国消息映射表格（Message Map）。<BR>4. 传递过程中发现有相符项目，于是调用项目中对应的函数。此函数是应用程序利用BEGIN_MESSAGE_MAP和END_MESSAGE_MAP之间的宏设立起来的。<BR>5. 标准消息的处理程序也有标准命名。例如WM_PAINT必然由OnPaint处理。<BR><BR>程序的死亡：<BR>1. 使用者单击〔File/Close〕，于是发出WM_CLOSE。<BR>2. CMyFrameWnd并没有设置WM_CLOSE处理程序，于是交给默认的处理程序。<BR>3. 默认函数对于WM_CLOSE的处理方式是调用::DestroyMessage，并因而发出WM_DESTROY。<BR>4. 默认的WM_DESTROY处理方式是调用::PostQuitMessage，因此发出WM_QUIT。<BR>5. CWinApp::Run收到WM_QUIT后会结束其内部之消息循环，然后调用ExitInstance，这是CWinApp的一个虚拟函数。<BR>6. 如果是CMyWinApp改写了ExitInstance，那么CWinApp::Run所调用的就是CMyWinApp::ExitInstance，否则就是CWinApp::ExitInstance。<BR>7. 最后回到AfxWinMain，执行AfxWinTerm，结束程序。<BR><img src ="http://www.cppblog.com/CPLUSPLUS/aggbug/4087.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/CPLUSPLUS/" target="_blank">伏羲</a> 2006-03-13 14:55 <a href="http://www.cppblog.com/CPLUSPLUS/archive/2006/03/13/4087.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>