<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>哈默博客 &#187; MFC</title>
	<atom:link href="http://www.satwe.com/tag/mfc/feed" rel="self" type="application/rss+xml" />
	<link>http://www.satwe.com</link>
	<description>心随所致，梦想为开。Follow the Dreams &#38; Heart.</description>
	<lastBuildDate>Fri, 03 Feb 2012 12:28:10 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>ADO连接SQL Server的问题解决</title>
		<link>http://www.satwe.com/archives/594.html</link>
		<comments>http://www.satwe.com/archives/594.html#comments</comments>
		<pubDate>Tue, 06 Nov 2007 02:55:49 +0000</pubDate>
		<dc:creator>hamo</dc:creator>
				<category><![CDATA[随心所记]]></category>
		<category><![CDATA[Database]]></category>
		<category><![CDATA[MFC]]></category>
		<category><![CDATA[program]]></category>

		<guid isPermaLink="false">http://www.satwe.com/archives/594.html</guid>
		<description><![CDATA[这是在Hexapod项目中遇到的头疼了很久的问题，今天终于得到了解决。回头看来，其实都非常简单。 使用ADO进行数据库操作可以有许多便利之处，比如兼容多种数据库，速度快等，在此不再赘述。 在项目中使用了A set of ADO classes &#8211; version 2.20提供的ADO封装类，ADO的connection string参考了ADO Connection Strings。 其中遇到的问题主要和这几个问题有关： SQLServer的身份验证方式 SQLServer的实例名称 先说第一个，身份验证有两种方式：windows账户验证和SQLServer本身的验证。如果使用SQLServer的身份验证，链接字符串为： &#8220;Provider=sqloledb;Data Source=(local);&#8221;&#8220;Initial Catalog=master;User Id=sa;Password=123456;&#8221; 如果使用Windows账户验证，则为： &#8220;Provider=sqloledb;Data Source=(local);&#8221;&#8220;Initial Catalog=master;Integrated Security=SSPI;&#8221; 第二个，从SQLServer2000开始，支持一台服务器上运行多个SQLServer实例，互不影响。如果不是默认的实例名称，则需要在Data Source中提供，如： &#8220;Data Source=(local)\HexaDatabase;&#8221; 点破的就简单了，第一次用的时候还是真头疼，以此备忘。 &#160; 本文标签: Database, MFC, program]]></description>
			<content:encoded><![CDATA[<p>这是在<a href="http://www.satwe.com/archives/520.html">Hexapod</a>项目中遇到的头疼了很久的问题，今天终于得到了解决。回头看来，其实都非常简单。</p>
<p>使用ADO进行数据库操作可以有许多便利之处，比如兼容多种数据库，速度快等，在此不再赘述。</p>
<p>在项目中使用了<a href="http://www.codeproject.com/database/caaadoclass1.asp">A set of ADO classes &#8211; version 2.20</a>提供的ADO封装类，ADO的connection string参考了<a href="http://www.codeproject.com/database/connectionstrings.asp">ADO Connection Strings</a>。</p>
<p>其中遇到的问题主要和这几个问题有关：</p>
<ul>
<li>SQLServer的身份验证方式
<li>SQLServer的实例名称</li>
</ul>
<p>先说第一个，身份验证有两种方式：windows账户验证和SQLServer本身的验证。如果使用SQLServer的身份验证，链接字符串为：</p>
<p>&#8220;Provider=sqloledb;Data Source=(local);&#8221;<br />&#8220;Initial Catalog=master;User Id=sa;Password=123456;&#8221;
<p>如果使用Windows账户验证，则为：</p>
<p>&#8220;Provider=sqloledb;Data Source=(local);&#8221;<br />&#8220;Initial Catalog=master;Integrated Security=SSPI;&#8221;</p>
<p>第二个，从SQLServer2000开始，支持一台服务器上运行多个SQLServer实例，互不影响。如果不是默认的实例名称，则需要在Data Source中提供，如：</p>
<p>&#8220;Data Source=(local)\HexaDatabase;&#8221;</p>
<p>点破的就简单了，第一次用的时候还是真头疼，以此备忘。</p>
<p>&nbsp;</p>
<p><!--adsense--></p>

	<br /><strong> 本文标签: <a href="http://www.satwe.com/tag/database" title="Database" rel="tag">Database</a>, <a href="http://www.satwe.com/tag/mfc" title="MFC" rel="tag">MFC</a>, <a href="http://www.satwe.com/tag/program" title="program" rel="tag">program</a></strong><br />
]]></content:encoded>
			<wfw:commentRss>http://www.satwe.com/archives/594.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>让MFC程序具有XP的风格(style)</title>
		<link>http://www.satwe.com/archives/587.html</link>
		<comments>http://www.satwe.com/archives/587.html#comments</comments>
		<pubDate>Tue, 30 Oct 2007 09:16:07 +0000</pubDate>
		<dc:creator>hamo</dc:creator>
				<category><![CDATA[技术讨论]]></category>
		<category><![CDATA[MFC]]></category>
		<category><![CDATA[program]]></category>

		<guid isPermaLink="false">http://www.satwe.com/archives/587.html</guid>
		<description><![CDATA[有两种方法可以使vc6或者vc2003编译出来的MFC程序具有XP的风格，当然这需要在Windows XP系统下运行。 方法一，使用外置的manifest描述文件 在exe文件所在目录中建立一个同名的.manifest文件。假设你有一个可执行文件app1.exe，则建立app1.exe.manifest。注意该文件的文件名是在exe的完整文件名后加.manifest。该文件的内容如下： Code: Your app description here 方法二，使用内置的manifest描述文件 这种方法可以将manifest文件编译到exe文件当中，发布的时候不需要额外增加一个.manifest文件。 步骤如下： 首先，在程序的RES目录下建一个文件,命名xp.manifest，文件内容为： Your app description here 然后，在VC中导入资源，导入xp.manifest，类型为24，并且修改ID为IDR_MANIFEST。 最后，通过菜单View-Resources Symbol &#8230;或者直接修改resource.h，将IDR_MANIFEST的值改为1。 编译后运行，程序就有xp的风格了。 本文标签: MFC, program]]></description>
			<content:encoded><![CDATA[<p>有两种方法可以使vc6或者vc2003编译出来的MFC程序具有XP的风格，当然这需要在Windows XP系统下运行。</p>
<p><strong> 方法一，使用外置的manifest描述文件</strong><br />
在exe文件所在目录中建立一个同名的.manifest文件。假设你有一个可执行文件app1.exe，则建立app1.exe.manifest。注意该文件的文件名是在exe的完整文件名后加.manifest。该文件的内容如下：</p>
<p><strong>Code:</strong><br />
<coolcode lang="xml" linenum="no"><br />
<?xml version="1.0" encoding="UTF-8" standalone="yes"?><br />
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0"><br />
<assemblyIdentity<br />
    version="1.0.0.0"<br />
    processorArchitecture="X86"<br />
    name="Microsoft.Windows.dummy"<br />
    type="win32"<br />
/><br />
<description>Your app description here</description><br />
<dependency><br />
    <dependentAssembly><br />
        <assemblyIdentity<br />
            type="win32"<br />
            name="Microsoft.Windows.Common-Controls"<br />
            version="6.0.0.0"<br />
            processorArchitecture="X86"<br />
            publicKeyToken="6595b64144ccf1df"<br />
            language="*"<br />
        /><br />
    </dependentAssembly><br />
</dependency><br />
</assembly><br />
</coolcode><br />
<!--adsense--><br />
<strong> 方法二，使用内置的manifest描述文件</strong><br />
这种方法可以将manifest文件编译到exe文件当中，发布的时候不需要额外增加一个.manifest文件。<br />
步骤如下：<br />
<span id="more-587"></span><br />
首先，在程序的RES目录下建一个文件,命名xp.manifest，文件内容为：<br />
<coolcode lang="xml" linenum="no"><br />
<?xml version="1.0" encoding="UTF-8" standalone="yes"?><br />
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0"><br />
<assemblyIdentity<br />
    version="1.0.0.0"<br />
    processorArchitecture="X86"<br />
    name="Microsoft.Windows.dummy"<br />
    type="win32"<br />
/><br />
<description>Your app description here</description><br />
<dependency><br />
    <dependentAssembly><br />
        <assemblyIdentity<br />
            type="win32"<br />
            name="Microsoft.Windows.Common-Controls"<br />
            version="6.0.0.0"<br />
            processorArchitecture="X86"<br />
            publicKeyToken="6595b64144ccf1df"<br />
            language="*"<br />
        /><br />
    </dependentAssembly><br />
</dependency><br />
</assembly><br />
</coolcode><br />
然后，在VC中导入资源，导入xp.manifest，类型为24，并且修改ID为IDR_MANIFEST。<br />
最后，通过菜单View-Resources Symbol &#8230;或者直接修改resource.h，将IDR_MANIFEST的值改为1。</p>
<p>编译后运行，程序就有xp的风格了。</p>

	<br /><strong> 本文标签: <a href="http://www.satwe.com/tag/mfc" title="MFC" rel="tag">MFC</a>, <a href="http://www.satwe.com/tag/program" title="program" rel="tag">program</a></strong><br />
]]></content:encoded>
			<wfw:commentRss>http://www.satwe.com/archives/587.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Dive into PASSCAL call</title>
		<link>http://www.satwe.com/archives/419.html</link>
		<comments>http://www.satwe.com/archives/419.html#comments</comments>
		<pubDate>Mon, 25 Jun 2007 08:39:00 +0000</pubDate>
		<dc:creator>hamo</dc:creator>
				<category><![CDATA[技术讨论]]></category>
		<category><![CDATA[English]]></category>
		<category><![CDATA[MFC]]></category>

		<guid isPermaLink="false">http://www.satwe.com/2007/06/dive-into-passcal-call/419.html</guid>
		<description><![CDATA[It&#8217;s a thread on microsoft.public.vc.mfc group and the orial url is :old skool vc++ 1.0. I will take it as some English discussion material and I has no copyright of the following text. 从中可以看到和只懂C#的人交流寄存器，堆栈是多么困难的事情。Scott McPhilips 和Doug Harrison都是很有耐心的MVP. 最后Doug Harrison的总结似乎也不错。 RodChar said: Hi all, I&#8217;m looking at some old code here and was wondering what the&#8230;]]></description>
			<content:encoded><![CDATA[<p><em>It&#8217;s a thread on microsoft.public.vc.mfc group and the orial url is :</em><a href="http://groups.google.com/group/microsoft.public.vc.mfc/browse_thread/thread/d4a734c5f8295620/04e19c1e279b318f#04e19c1e279b318f"><em>old skool vc++ 1.0</em></a>.</p>
<p><em>I will take it as some English discussion material and I has no copyright of the following text.</em></p>
<p>从中可以看到和只懂C#的人交流寄存器，堆栈是多么困难的事情。Scott McPhilips 和Doug Harrison都是很有耐心的MVP. 最后Doug Harrison的总结似乎也不错。</p>
<p><span id="more-419"></span></p>
<p>RodChar said:</p>
<blockquote><p>Hi all,</p>
<p>I&#8217;m looking at some old code here and was wondering what the keyword PASCAL was for?</p>
<p>int PASCAL WinMain(HANDLE hInstance,HANDLE hPrevInstance, LPSTR lpszCmdParam,int nCmdShow)</p>
<p>Thanks,</p>
<p>RodChar</p></blockquote>
<p>Scott McPhilips said:</p>
<blockquote><p>It is(was) a calling convention used with most Windows APIs. As I recall, it means parameters are pushed onto the stack in the opposite order than the standard C convention.</p>
<p>Today it is defined as __stdcall.</p></blockquote>
<p>RodChar:</p>
<blockquote><p>After doing further research based on your reply I ran into yet another unfamilar place. I was trying to read what sounded like a basic article but I think here may be some implied understanding involved.</p>
<p>Here&#8217;s the aticle link:</p>
<p><a href="http://blogs.msdn.com/oldnewthing/archive/2004/01/02/47184.aspx">http://blogs.msdn.com/oldnewthing/archive/2004/01/02/47184.aspx</a></p>
<p>After just reading the first few sentenses I became lost:</p>
<p>The history of calling conventions, part 1</p>
<p>The great thing about calling convention was fixed by the instruction set: The BP register defaults to the SS selector, whereas the other registers default to the DS selector. So the BP register was necessarily the register used for accessing stack-based parameters.</p>
<p>So is there a place or article I can read that will help me understand this one? BP register? Huh?</p>
<p>thanks,</p>
<p>rodchar</p></blockquote>
<p>Scott McPhillips:</p>
<blockquote><p>If you became lost perhaps that you have never learned an accembly language? Very old skool, but lots of fun. Learn how computers really work!</p>
<p>The BP register(Base Pointer) saves a copy of the stack pointer on entry into a function. So all parameters passed in the stack are accessed with BP plus an offset.</p>
<p>Articles on the x86 Intel architecture would be really dusty by now, but you can go straight to the source &#8211; Intel programmer&#8217;s reference manual:</p>
<p><a href="http://www.intel.com/design/processor/manuals">http://www.intel.com/design/processor/manuals</a></p></blockquote>
<p>Doug Harrison:</p>
<blockquote><p>The 16-bit stuff I&#8217;d just ignore. The 32-bit stuff can be usefule, especially when debugging, and to that end, see:</p>
<p>&#8220;Matt&#8217;s Just Enough Assembly Language to Get By&#8221;</p>
<p><a href="http://www.microsoft.com/msj/0298/hood0298.aspx">http://www.microsoft.com/msj/0298/hood0298.aspx</a><br />
<a href="http://www.microsoft.com/msj/0698/hood0698.aspx">http://www.microsoft.com/msj/0698/hood0698.aspx</a></p>
<p>For a lot more detail, there is:</p>
<p>The Art of Assembly Language<br />
<a href="http://webster.cs.ucr.edu/">http://webster.cs.ucr.edu/</a></p></blockquote>
<p>RodChar:</p>
<blockquote><p>Question from the article:</p>
<p>Since so much of what I&#8217;ll describe depends on the registers, a quick review of the commonly used Intel x86 register set is in order. In Figure 1, all registers are 32 bits except where noted. &#8220;Multipurpose&#8221; means the register can hold any arbitrary 32-bit value (for example, literal values, addresses, and bit flags).</p>
<p>Please forgive me for this ahead of time, but what is an Intel X86 register set in lamen&#8217;s terms? What is a register?</p></blockquote>
<p>Scott McPhillips:</p>
<blockquote><p>A register is a storage element, much like memory but located within the CPU. It is very fast storage bucause of its intimate connection to the arithmetic/logic unit and to other registers. Some registers may have built in  capabilities to shift and perform other primitive operations.</p></blockquote>
<p>Doug Harrison:</p>
<blockquote><p><a href="http://en.wikipedia.org/wiki/Processor_register">http://en.wikipedia.org/wiki/Processor_register</a></p></blockquote>
<p>RodChar:</p>
<blockquote><p>How far will I have to go back in order for this to make sense? What&#8217;s the best way to relate this stuff to what I think I understand and have some work experience in C#.net?</p></blockquote>
<p>Doug Harrison:</p>
<blockquote><p>Your original question was about the PASCAL macro. Calling convenstions for native code has no relevance in .NET, unless perhaps you&#8217;re trying to write P/Invoke declarations. If you want to understand it anyway, you need to have a basic understanding of how function are called at the assembly level, including how arguments are passed, which is typically through registers and/or on the stack, return addresses are stored, stack frames are specified, etc. Since you&#8217;ve susequently asked what a &#8220;register&#8221; is, I&#8217;d say you need to start with Assembly Language 101.</p></blockquote>

	<br /><strong> 本文标签: <a href="http://www.satwe.com/tag/english" title="English" rel="tag">English</a>, <a href="http://www.satwe.com/tag/mfc" title="MFC" rel="tag">MFC</a></strong><br />
]]></content:encoded>
			<wfw:commentRss>http://www.satwe.com/archives/419.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MFC group上一个有意思的讨论</title>
		<link>http://www.satwe.com/archives/164.html</link>
		<comments>http://www.satwe.com/archives/164.html#comments</comments>
		<pubDate>Tue, 20 Mar 2007 09:38:05 +0000</pubDate>
		<dc:creator>hamo</dc:creator>
				<category><![CDATA[快乐每一天]]></category>
		<category><![CDATA[MFC]]></category>
		<category><![CDATA[microsoft]]></category>
		<category><![CDATA[program]]></category>

		<guid isPermaLink="false">http://www.satwe.com/2007/03/a-funny-discussion-in-mfc-group/164.html</guid>
		<description><![CDATA[今天看了一个比较有意思的灌水，好玩。 1. 某君提了一个问题，归纳一下就说，我的程序有问题（具体有价值的材料没有），怎么解决呢？ ermutarra Mar 20, 4:00 am Newsgroups: microsoft.public.vc.mfc Subject: Can&#8217;t change content of edit box !? Hi all, I have a dialog window for the user to enter some data and then the program goes and does something with it. The edit controls used for the data are initialised to some default values&#8230;]]></description>
			<content:encoded><![CDATA[<p>今天看了一个比较有意思的灌水，好玩。</p>
<p>1. 某君提了一个问题，归纳一下就说，我的程序有问题（具体有价值的材料没有），怎么解决呢？</p>
<p>ermutarra Mar 20, 4:00 am</p>
<p>Newsgroups: <strong>microsoft.public.vc.mfc</strong></p>
<p>Subject: <strong>Can&#8217;t change content of edit box !?</strong></p>
<p>Hi all,</p>
<p>I have a dialog window for the user to enter some data and then the program goes and does something with it. The edit controls used for the data are initialised to some default values but then I don&#8217;t seem to be able to change the value (these have NOT been disabled and are NOT read-only). Can anybody tell me what&#8217;s going on and how to fix it so that I can change the values?</p>
<p>Thank you very much in advance.</p>
<p>Noelia</p>
<p>2. 这样的问题肯定是没法回答的，不过一位MVP这样RE的<span id="more-164"></span></p>
<p>AliR (VC++ MVP) Mar 20, 4:05 am</p>
<p>Newsgroups: <strong>microsoft.public.vc.mfc</strong></p>
<p>Subject: <strong>Re: Can&#8217;t change content of edit box !?</strong></p>
<p>This reminds me, my toaster stopped working this morning, and just doesn&#8217;t<br />
toast anymore, any ideas?</p>
<p>AliR.</p>
<p>3. 然后lz说问题解决了，原来是..</p>
<p>ermutarra Mar 20, 4:23 am</p>
<p>Newsgroups: <strong>microsoft.public.vc.mfc</strong></p>
<p>Subject: <strong>Re: Can&#8217;t change content of edit box !?</strong></p>
<p>Fixed it. It was because the member variable attached to it was of  integer type instead of CEdit.</p>
<p>4. 然后，AliR回答说..</p>
<p>AliR (VC++ MVP) Mar 20, 4:27 am</p>
<p>Newsgroups: <strong>microsoft.public.vc.mfc</strong></p>
<p>Subject: <strong>Re: Can&#8217;t change content of edit box !?</strong></p>
<p>&gt; Fixed it. It was because the member variable attached to it was of<br />
&gt; integer type instead of CEdit.</p>
<p>Me too, I forgot to plug in my toaster.</p>
<p>AliR.</p>

	<br /><strong> 本文标签: <a href="http://www.satwe.com/tag/mfc" title="MFC" rel="tag">MFC</a>, <a href="http://www.satwe.com/tag/microsoft" title="microsoft" rel="tag">microsoft</a>, <a href="http://www.satwe.com/tag/program" title="program" rel="tag">program</a></strong><br />
]]></content:encoded>
			<wfw:commentRss>http://www.satwe.com/archives/164.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>一个小故事</title>
		<link>http://www.satwe.com/archives/49.html</link>
		<comments>http://www.satwe.com/archives/49.html#comments</comments>
		<pubDate>Mon, 11 Dec 2006 15:59:47 +0000</pubDate>
		<dc:creator>hamo</dc:creator>
				<category><![CDATA[快乐每一天]]></category>
		<category><![CDATA[MFC]]></category>
		<category><![CDATA[microsoft]]></category>

		<guid isPermaLink="false">http://www.satwe.com/2007/01/49.html</guid>
		<description><![CDATA[这件事情已经过去几天了，但是回想起来总还是觉得比较有意思，所以发上来做个纪念。 事情发生在microsoft.public.vc.mfc新闻组上面，是一个英文的新闻组。然后在某天，有位叫“松竹”的同学发了一篇帖子，询问关于CEdit::GetSel的问题。这本来也很正常，不过唯一例外的是这篇帖子使用中文写的。于是故事开始了&#8230; 由于字符集的问题，老外看来肯定是乱码，于是有位叫Ajay Kalra的MVP就re了一句简单的“That&#8217;s all right”，或许就不想再离了，然后我们这位“松竹”就re Ajay Kalra的回帖，继续用中文写了很长一段描述。于是Ajay Kalra和Tom Serface开始讨论到底是自己的字体不对呢，还是怎么回事。其中有个建议说应该试一下UNICODE编码，另外一个同意，然后说了一句“I think you are right. I missed that completely. Next time I will put on my UNICODE glasses.”，很幽默的一句话。 当然故事并没有结束，因为这位同学根本就不是用的UNICODE的字符集，理所当然的这两位先生看到的还是乱码。直到2天之后，另外一位fiveight的看不下去了，re了一下，说“It is not your font&#8217;s fault, Tom.This artical is writen in Chinese,and uses GB2312 code.”，故事才告结束，否则还不知道那两位老外要研究多久。 : ) 本文标签: MFC, microsoft]]></description>
			<content:encoded><![CDATA[<p>这件事情已经过去几天了，但是回想起来总还是觉得比较有意思，所以发上来做个纪念。</p>
<p>事情发生在microsoft.public.vc.mfc新闻组上面，是一个英文的新闻组。然后在某天，有位叫“松竹”的同学发了一篇帖子，询问关于CEdit::GetSel的问题。这本来也很正常，不过唯一例外的是这篇帖子使用中文写的。于是故事开始了&#8230;</p>
<p>由于字符集的问题，老外看来肯定是乱码，于是有位叫Ajay Kalra的MVP就re了一句简单的“That&#8217;s all right”，或许就不想再离了，然后我们这位“松竹”就re Ajay Kalra的回帖，继续用中文写了很长一段描述。于是Ajay Kalra和Tom Serface开始讨论到底是自己的字体不对呢，还是怎么回事。其中有个建议说应该试一下UNICODE编码，另外一个同意，然后说了一句“<strong>I think you are right. I missed that completely. Next time I will put on my UNICODE glasses.</strong>”，很幽默的一句话。</p>
<p>当然故事并没有结束，因为这位同学根本就不是用的UNICODE的字符集，理所当然的这两位先生看到的还是乱码。直到2天之后，另外一位fiveight的看不下去了，re了一下，说“It is not your font&#8217;s fault, Tom.This artical is writen in Chinese,and uses GB2312 code.”，故事才告结束，否则还不知道那两位老外要研究多久。 : )</p>

	<br /><strong> 本文标签: <a href="http://www.satwe.com/tag/mfc" title="MFC" rel="tag">MFC</a>, <a href="http://www.satwe.com/tag/microsoft" title="microsoft" rel="tag">microsoft</a></strong><br />
]]></content:encoded>
			<wfw:commentRss>http://www.satwe.com/archives/49.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Displaying a Bitmap from a BMP File</title>
		<link>http://www.satwe.com/archives/377.html</link>
		<comments>http://www.satwe.com/archives/377.html#comments</comments>
		<pubDate>Wed, 13 Sep 2006 15:21:32 +0000</pubDate>
		<dc:creator>hamo</dc:creator>
				<category><![CDATA[技术讨论]]></category>
		<category><![CDATA[MFC]]></category>
		<category><![CDATA[program]]></category>

		<guid isPermaLink="false">http://www.satwe.com/2006/09/377.html</guid>
		<description><![CDATA[发件人: wangxl [mailto:hamo2k@163.com] 发送时间: 2006年9月13日 23:09 收件人: &#8216;wangxianlei@cabrtech.com&#8217; 主题: Displaying a Bitmap from a BMP File Displaying a Bitmap from a BMP File Rating: &#160; Ramakrishna Talla (view profile) April 3, 2003 Environment: MFC, Visual C++ 6.0, Windows 2000 (continued) The following code fragment shows how to read an image from a BMP file and&#8230;]]></description>
			<content:encoded><![CDATA[<p dir="ltr" align="left"><font face="宋体" size="2"><strong>发件人:</strong> wangxl [mailto:hamo2k@163.com]<br />
<strong>发送时间:</strong> 2006年9月13日 23:09<br />
<strong>收件人:</strong> &#8216;wangxianlei@cabrtech.com&#8217;<br />
<strong>主题:</strong> Displaying a Bitmap from a BMP File<br />
</font></p>
<p>Displaying a Bitmap from a BMP File<br />
<strong>Rating:</strong> <font color="#990000"><img src="http://www.codeguru.com/img/star.gif" height="12" width="13" /><img src="http://www.codeguru.com/img/star.gif" height="12" width="13" /><img src="http://www.codeguru.com/img/star.gif" height="12" width="13" /><img src="http://www.codeguru.com/img/star.gif" height="12" width="13" /><img src="http://www.codeguru.com/img/star-half.gif" height="12" width="13" /></font></p>
<table border="0" cellpadding="5" cellspacing="0">
<tr>
<td align="right">&nbsp;</td>
<td><strong>Ramakrishna Talla</strong> (<a href="http://www.codeguru.com/member.php/3055/">view profile</a>)<br />
April 3, 2003</td>
</tr>
</table>
<p><span><u>Environment:</u> MFC, Visual C++ 6.0, Windows 2000<br />
<a href="http://www.codeguru.com/cpp/g-m/bitmap/displayingandsizing/article.php/c4905/#more">(continued)</a> <img src="http://www.codeguru.com/RealMedia/ads/adstream_lx.cgi/ew/ewsoftware/www.codeguru.com/cpp/g-m/bitmap/displayingandsizing/article/c4905/i/267229731/flex/OasDefault/IBM_IOD_Conference_06_1b/ibmiodconfewronbob.html/64646439653264353435303831643930?_RM_EMPTY_" style="display: none" height="1" width="1" /> <img src="http://www.codeguru.com/RealMedia/ads/adstream_lx.cgi/ew/ewsoftware/www.codeguru.com/cpp/g-m/bitmap/displayingandsizing/article/c4905/i/688052200/accessunit/OasDefault/Devx_IBMSkillBuildingPortal_2j/IBM_SB_AU.html/64646439653264353435303831643930?_RM_EMPTY_" style="display: none" height="1" width="1" /> </span></p>
<p>The following code fragment shows how to read an image from a BMP file and display it in your MFC application window. You could see several articles on the same focus; the one I present here is very simple, with just a few lines of code. The code given below has been tested with Visual C++ 6.0 on Win 2000.</p>
<p>Create a single document interface application; select CFormView as the base class for the application&#8217;s view base class. Click on the resource tab on the project explorer to navigate to the resource editor and drag a button to the dialog resource. Double-click the button to add a handler to the application&#8217;s view class, as shown below.</p>
<pre><span>void</span> AppView::OnButton1()
{
}</pre>
<h3>Step 1: Load the Image File</h3>
<p>Call the following:</p>
<pre>CString szFilename ("C:\Talla\yourimg.bmp");
HBITMAP hBmp = (HBITMAP)::LoadImage(
                <span>NULL</span>,
                szFilename,
                IMAGE_BITMAP,
                0,
                0,
                LR_LOADFROMFILE|LR_CREATEDIBSECTION
                );</pre>
<h3>Step 2: Create a Bitmap Object and Attach It to the Object</h3>
<pre>CBitmap bmp;
bmp.Attach(hBmp);</pre>
<h3>Step 3: Create a Memory DC and Select the BMP to It</h3>
<p>You also need to store the old BMP pointer:</p>
<pre>CClientDC dc(<span>this</span>);
CDC bmDC;
bmDC.CreateCompatibleDC(&amp;dc);
CBitmap *pOldbmp = bmDC.SelectObject(&amp;bmp);</pre>
<h3>Step 4: Get the BMP Height and Width</h3>
<p>Obtain this from CBitmap&#8217;s GetBitmap function.</p>
<pre>BITMAP  bi;
  bmp.GetBitmap(&amp;bi);</pre>
<h3>Step 5: Get the Block of Pixels from memoryDC to the Screen</h3>
<p>Use CClientDC&#8217;s BitBlt function. Next, re-select the old BMP. The complete code is as follows:</p>
<pre><span>void</span> AppView::OnButton1()
{
   CString szFilename("C:\Talla\yourimg.bmp");
   HBITMAP hBmp = (HBITMAP)::LoadImage(<span>NULL</span>,szFilename,
                             IMAGE_BITMAP,0,0,
                             LR_LOADFROMFILE|LR_CREATEDIBSECTION);

   CBitmap bmp;
   bmp.Attach(hBmp);

   CClientDC dc(<span>this</span>);
   CDC bmDC;
   bmDC.CreateCompatibleDC(&amp;dc);
   CBitmap *pOldbmp = bmDC.SelectObject(&amp;bmp);

   BITMAP  bi;
   bmp.GetBitmap(&amp;bi);

   dc.BitBlt(0,0,bi.bmWidth,bi.bmHeight,&amp;bmDC,0,0,SRCCOPY);

   bmDC.SelectObject(pOldbmp);
}</pre>
<p><img src="http://www.codeguru.com/icom_includes/headers/earthweb/jw_devsol.gif" /></p>
<p><img src="http://www.codeguru.com/RealMedia/ads/Creatives/OasDefault/MS_Extensibility_GEMS_1za/arrow.gif" style="display: none" align="bottom" /> <a href="http://www.codeguru.com/RealMedia/ads/click_lx.cgi/ew/ewsoftware/www.codeguru.com/cpp/g-m/bitmap/displayingandsizing/article/c4905/i/1010247900/fl1/OasDefault/MS_Extensibility_GEMS_1za/FeaturedLink_BorlandCaliberRM.html/64646439653264353435303831643930">Borland CaliberRM Integrates with Visual Studio to Bring Sophistication to Requirements Management </a><img src="http://www.codeguru.com/RealMedia/ads/adstream_lx.cgi/ew/ewsoftware/www.codeguru.com/cpp/g-m/bitmap/displayingandsizing/article/c4905/i/1010247900/fl1/OasDefault/MS_Extensibility_GEMS_1za/FeaturedLink_BorlandCaliberRM.html/64646439653264353435303831643930?_RM_EMPTY_" style="display: none" height="1" width="1" /><br />
<img src="http://www.codeguru.com/RealMedia/ads/Creatives/OasDefault/DevX_IBM_DB2_Portal_2o/arrow.gif" style="display: none" align="bottom" /> <a href="http://www.codeguru.com/RealMedia/ads/click_lx.cgi/ew/ewsoftware/www.codeguru.com/cpp/g-m/bitmap/displayingandsizing/article/c4905/i/264422512/fl2/OasDefault/DevX_IBM_DB2_Portal_2o/FeaturedLink_GetDB2Express.html/64646439653264353435303831643930">Get DB2 Express-C 9. Free to Develop, Deploy, Distribute. No limits&#8211;just data. Download Now! </a><img src="http://www.codeguru.com/RealMedia/ads/adstream_lx.cgi/ew/ewsoftware/www.codeguru.com/cpp/g-m/bitmap/displayingandsizing/article/c4905/i/264422512/fl2/OasDefault/DevX_IBM_DB2_Portal_2o/FeaturedLink_GetDB2Express.html/64646439653264353435303831643930?_RM_EMPTY_" style="display: none" height="1" width="1" /><br />
<img src="http://www.codeguru.com/RealMedia/ads/Creatives/OasDefault/AMD_Webcast_GEMS_2e/arrow.gif" style="display: none" align="bottom" /> <a href="http://www.codeguru.com/RealMedia/ads/click_lx.cgi/ew/ewsoftware/www.codeguru.com/cpp/g-m/bitmap/displayingandsizing/article/c4905/i/1481698303/fl3/OasDefault/AMD_Webcast_GEMS_2e/FeaturedLink_WebcastLinux.html/64646439653264353435303831643930">Webcast: Linux on Multi-Core&#8211;WAS CE and the Open Stack Appliance </a><img src="http://www.codeguru.com/RealMedia/ads/adstream_lx.cgi/ew/ewsoftware/www.codeguru.com/cpp/g-m/bitmap/displayingandsizing/article/c4905/i/1481698303/fl3/OasDefault/AMD_Webcast_GEMS_2e/FeaturedLink_WebcastLinux.html/64646439653264353435303831643930?_RM_EMPTY_" style="display: none" height="1" width="1" /><br />
<img src="http://www.codeguru.com/RealMedia/ads/Creatives/OasDefault/Cingular_SC_GEMS_1g/arrow.gif" style="display: none" align="bottom" /> <a href="http://www.codeguru.com/RealMedia/ads/click_lx.cgi/ew/ewsoftware/www.codeguru.com/cpp/g-m/bitmap/displayingandsizing/article/c4905/i/1884187226/fl4/OasDefault/Cingular_SC_GEMS_1g/FeaturedLink_Learnhow.html/64646439653264353435303831643930">Learn how to navigate the key issues that affect developing and deploying mobile applications. </a><img src="http://www.codeguru.com/RealMedia/ads/adstream_lx.cgi/ew/ewsoftware/www.codeguru.com/cpp/g-m/bitmap/displayingandsizing/article/c4905/i/1884187226/fl4/OasDefault/Cingular_SC_GEMS_1g/FeaturedLink_Learnhow.html/64646439653264353435303831643930?_RM_EMPTY_" style="display: none" height="1" width="1" /><br />
<img src="http://www.codeguru.com/RealMedia/ads/Creatives/OasDefault/Devcom_WC_9_19_GEMS_1e/arrow.gif" style="display: none" align="bottom" /> <a href="http://www.codeguru.com/RealMedia/ads/click_lx.cgi/ew/ewsoftware/www.codeguru.com/cpp/g-m/bitmap/displayingandsizing/article/c4905/i/688340453/fl5/OasDefault/Devcom_WC_9_19_GEMS_1e/FeaturedLink_DevelopercomWebcast.html/64646439653264353435303831643930">Developer.com Webcast: Defining Your Own Software Development Methodology.</a></p>

	<br /><strong> 本文标签: <a href="http://www.satwe.com/tag/mfc" title="MFC" rel="tag">MFC</a>, <a href="http://www.satwe.com/tag/program" title="program" rel="tag">program</a></strong><br />
]]></content:encoded>
			<wfw:commentRss>http://www.satwe.com/archives/377.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>由定义消息引起的Debug版正常而Release版异常的问题及解决方案</title>
		<link>http://www.satwe.com/archives/374.html</link>
		<comments>http://www.satwe.com/archives/374.html#comments</comments>
		<pubDate>Fri, 01 Sep 2006 02:56:55 +0000</pubDate>
		<dc:creator>hamo</dc:creator>
				<category><![CDATA[技术讨论]]></category>
		<category><![CDATA[MFC]]></category>
		<category><![CDATA[program]]></category>

		<guid isPermaLink="false">http://www.satwe.com/2006/09/374.html</guid>
		<description><![CDATA[在使用了自定义消息的程序中，有可能出现Debug版正常而Release版非法操作的问题。 下面是一种原因以及其解决办法： 问题的描述： ================ 定了了自定义消息： #define WM_DEMOWORK WM_USER+1 消息相应函数： afx_msg void OnDemoWork(); 消息映射： ON_MESSAGE(WM_DEMOWORK,OnDemoWork) 上述代码编译没有任何错误，并且在Debug版中运行正常，但是在Release版中会报非法 操作。 原因： ================ 在MFC中，ON_MESSAGE宏的定义如下： #define ON_MESSAGE(message, memberFxn) { message, 0, 0, 0, AfxSig_lwl, (AFX_PMSG)(AFX_PMSGW)(LRESULT (AFX_MSG_CALL CWnd::*)(WPARAM, LPARAM))&#38;memberFxn }, 可见，在ON_MESSAGE宏中认为消息相应函数memberFxn的原型为 LRESULT (*pProc)(WPARAM, LPARAM)的形式，它有两个参数， 分别为WPARAM, LPARAM。 解决方案 =============== 了解具体的原因后，解决就非常容易。有两个方案： 方案1： 修改消息相应函数的定义，增加函数参数。如： afx_msg void OnDemoWork(WPARAM wParam, LPARAM lParam); 方案2： 如果消息相应函数中不需要消息参数，可以利用另外一个消息映射宏ON_MESSAGE_VOID 即可。如 ON_MESSAGE_VOID(WM_DEMOWORK,OnDemoWork) 其中ON_MESSAGE_VOID的宏定义为：&#8230;]]></description>
			<content:encoded><![CDATA[<p><span id="BlogViewId" be:sortmode="Archive" be:firsthandle="cns!42B80124FE3ED55A!246" be:lasthandle="cns!42B80124FE3ED55A!242">在使用了自定义消息的程序中，有可能出现Debug版正常而Release版非法操作的问题。</span></p>
<p>下面是一种原因以及其解决办法：</p>
<p>问题的描述：<br />
================</p>
<p>定了了自定义消息： #define WM_DEMOWORK WM_USER+1<br />
消息相应函数： afx_msg void OnDemoWork();<br />
消息映射： ON_MESSAGE(WM_DEMOWORK,OnDemoWork)</p>
<p>上述代码编译没有任何错误，并且在Debug版中运行正常，但是在Release版中会报非法<br />
操作。</p>
<p>原因：<br />
================<br />
在MFC中，ON_MESSAGE宏的定义如下：<br />
#define ON_MESSAGE(message, memberFxn) { message, 0, 0, 0, AfxSig_lwl,<br />
(AFX_PMSG)(AFX_PMSGW)(LRESULT (AFX_MSG_CALL CWnd::*)(WPARAM,<br />
LPARAM))&amp;memberFxn },</p>
<p>可见，在ON_MESSAGE宏中认为消息相应函数memberFxn的原型为 LRESULT<br />
(*pProc)(WPARAM, LPARAM)的形式，它有两个参数，<br />
分别为WPARAM, LPARAM。</p>
<p>解决方案<br />
===============<br />
了解具体的原因后，解决就非常容易。有两个方案：</p>
<p>方案1：<br />
修改消息相应函数的定义，增加函数参数。如：<br />
afx_msg void OnDemoWork(WPARAM wParam, LPARAM lParam);</p>
<p>方案2：<br />
如果消息相应函数中不需要消息参数，可以利用另外一个消息映射宏ON_MESSAGE_VOID<br />
即可。如<br />
ON_MESSAGE_VOID(WM_DEMOWORK,OnDemoWork)</p>
<p>其中ON_MESSAGE_VOID的宏定义为：<br />
#define ON_MESSAGE_VOID(message, memberFxn) { message, 0, 0, 0, AfxSig_vv,<br />
(AFX_PMSG)(AFX_PMSGW)(void (AFX_MSG_CALL CWnd::*)(void))&amp;memberFxn },</p>
<p>其中消息相应函数原型为void (*pProc)(void)。<br />
;</p>

	<br /><strong> 本文标签: <a href="http://www.satwe.com/tag/mfc" title="MFC" rel="tag">MFC</a>, <a href="http://www.satwe.com/tag/program" title="program" rel="tag">program</a></strong><br />
]]></content:encoded>
			<wfw:commentRss>http://www.satwe.com/archives/374.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>用VC纯资源dll解决国际化问题</title>
		<link>http://www.satwe.com/archives/373.html</link>
		<comments>http://www.satwe.com/archives/373.html#comments</comments>
		<pubDate>Tue, 22 Aug 2006 08:14:08 +0000</pubDate>
		<dc:creator>hamo</dc:creator>
				<category><![CDATA[技术讨论]]></category>
		<category><![CDATA[MFC]]></category>
		<category><![CDATA[program]]></category>

		<guid isPermaLink="false">http://www.satwe.com/2006/08/373.html</guid>
		<description><![CDATA[由于MFC应用程序也有自己的资源文件，当你调用MFC函数比如 CString::LoadString 或其它 LoadIcon 时，MFC应用程序框架首先跟踪搜索EXE文件的资源，然后才是DLL和 MFC的资源，因此在使用纯资源DLL时候，必须人为先改变资源的搜索顺序，可以通过使 用 AfxSetResourceHandle 函数来实现，具体实现如下： BOOL CMultilanguageApp::InitInstance() { AfxEnableControlContainer(); if (m_bChinese) { m_hLangDLL=::LoadLibrary(&#8220;chinese.dll&#8221;); } else { m_hLangDLL=::LoadLibrary(&#8220;english.dll&#8221;); } AfxSetResourceHandle(m_hLangDLL); …… } 本文标签: MFC, program]]></description>
			<content:encoded><![CDATA[<p><span id="BlogViewId" be:sortmode="Archive" be:firsthandle="cns!42B80124FE3ED55A!241" be:lasthandle="cns!42B80124FE3ED55A!234">由于MFC应用程序也有自己的资源文件，当你调用MFC函数比如 CString::LoadString<br />
或其它 LoadIcon 时，MFC应用程序框架首先跟踪搜索EXE文件的资源，然后才是DLL和<br />
MFC的资源，因此在使用纯资源DLL时候，必须人为先改变资源的搜索顺序，可以通过使<br />
用 AfxSetResourceHandle 函数来实现，具体实现如下：</span></p>
<p>BOOL CMultilanguageApp::InitInstance()<br />
{<br />
AfxEnableControlContainer();</p>
<p>if (m_bChinese)<br />
{<br />
m_hLangDLL=::LoadLibrary(&#8220;chinese.dll&#8221;);<br />
}<br />
else<br />
{<br />
m_hLangDLL=::LoadLibrary(&#8220;english.dll&#8221;);<br />
}</p>
<p>AfxSetResourceHandle(m_hLangDLL);</p>
<p>……<br />
}</p>

	<br /><strong> 本文标签: <a href="http://www.satwe.com/tag/mfc" title="MFC" rel="tag">MFC</a>, <a href="http://www.satwe.com/tag/program" title="program" rel="tag">program</a></strong><br />
]]></content:encoded>
			<wfw:commentRss>http://www.satwe.com/archives/373.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
<!-- WP Super Cache is installed but broken. The path to wp-cache-phase1.php in wp-content/advanced-cache.php must be fixed! -->
