📄 resnotes.html
字号:
<HTML><LINK HREF="style.css" REL="STYLESHEET" TYPE="text/css"><HEAD><TITLE>Win32 Tutorial - Resource file notes</TITLE></HEAD><BODY><FONT SIZE="-1">[ <A HREF="./index.html">contents</A>| <A HREF="http://www.winprog.org/">#winprog</A>]</FONT><HR><H1>Resource file notes</H1><H2>Argh!</H2>The one thing I really hated when I switched my primary development environment from Borland C++ to MS Visual C++was the way VC++ handles resource scripts (.rc files).<P>In BC++ was free to control the layout and content of the .rc files, and when using the resource editor, only the things that I specifically changed in the editor got changed in the resource file. Much to my dismay, the VC++ resource editor will completely rewrite your .rc file, and possibly destroy or ignore any changes that you personally make. <P>This was terribly frustrating at first, but I basically learned to deal with it and it's not SO bad after a while, since in general I don't write any amount of my resources by hand, but reserve that forminor changes that perhaps I can't quite accomplish in the editor.<H2>Compatibility</H2>One small challange for this tutorial was to make the resource files compile properly under VC++ and BC++ without changes. In the original tutorial I used the Borland naming convention for the resource header, which was <CODE>project_name.rh</CODE>. However by default in VC++ this header is ALWAYS called <CODE>resource.h</CODE>,so for simplicity I've adopted this for the current tutorial revision, as it doesn't impact BC++ at all. <P>For the curious, it is possible to change the name of the resource that VC++ uses by editing the .rc file manuallyand changing the name in two places, once where it is <CODE>#include</CODE>d, and second where it is contained in a <CODE>TEXTINCLUDE</CODE> resource.<P>The next problem is that by default VC++ requires the file <CODE>afxres.h</CODE> to be included in it's .rc files,whereas BC++ has all the necessary preprocessor macros defined automatically and requires no such include. Anotherdumb thing about this is that <CODE>afxres.h</CODE> is only installed when you insall MFC which not everyone does,even when you are creating an API application which only requires <CODE>winres.h</CODE> which is always installed.<P>Since I work in VC++ and use it's resource editor I've solved this problem by slightly altering each .rc file thatis generated to include the following:<PRE CLASS="SNIP">#ifndef __BORLANDC__#include "winres.h"#endif</PRE>Which under default circumstances would usually read:<PRE CLASS="SNIP">#include "afxres.h"</PRE>For those of you that are using VC++ you can find the option to change this text within the IDE under "View > Resource Includes". There is generally no need to ever use this in normal practice, it's simplya way I used to work around the problem of making things work with BC++ and VC++.<P>To those of you using BC++, I'm sorry about the extra mess in the .rc files that are generate by the VC++ editor, butit shouldn't interfere with anything.<H2>Compiling resources under BC++</H2>Try as I might I couldn't find a simple way to compile a program with BC++ that included RC files, and ultimately hadto settle on the non-optimal configuration that you will find in the makefiles included with the source for this tutorial.You can find the notes for the BC++ compiler in <A HREF="bcpp.html">Free Borland C++ Command Line Tools<A>.<HR><FONT SIZE="-1">Copyright © 1998-2003, Brook Miles (<A HREF="mailto:forger(nospam)winprog.org">theForger</A>). All rights reserved.</FONT><SCRIPT language="JavaScript"><!-- var re = /\(nospam\)/ig; var str; for(i = 0;i < document.links.length;i++) { str = "" + document.links(i).href; if(str.search(re) != -1) document.links(i).href = str.replace(re, "@"); str = "" + document.links(i).innerHTML; if(str.search(re) != -1) document.links(i).innerHTML = str.replace(re, "@"); }--></SCRIPT></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -