12.12.2012 Views

Teach Yourself Borland C++ in 14 Days - portal

Teach Yourself Borland C++ in 14 Days - portal

Teach Yourself Borland C++ in 14 Days - portal

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

348 Day 9<br />

NOTE<br />

L<strong>in</strong>es 1 through 8 of List<strong>in</strong>g 9.4 illustrate how a str<strong>in</strong>g table looks <strong>in</strong> a resource script file.<br />

Creat<strong>in</strong>g str<strong>in</strong>g tables is very easy with any text editor. On l<strong>in</strong>es 10 and 11, a WAVE resource<br />

is created for each of the two wave files, which were previously recorded and reside <strong>in</strong> the<br />

project’s directory. When the resource compiler sees the WAVE declaration, it reads the<br />

<strong>in</strong>dividual sound files and compiles them <strong>in</strong>to the b<strong>in</strong>ary resource file.<br />

As you can see from List<strong>in</strong>g 9.4, you can create some resources easily<br />

with a text editor. If you have bitmaps or wave audio stored as external<br />

files, you can <strong>in</strong>clude them <strong>in</strong> an .rc file as illustrated <strong>in</strong> List<strong>in</strong>g 9.4<br />

and have them compiled <strong>in</strong>to the b<strong>in</strong>ary resource file us<strong>in</strong>g the resource<br />

compiler. Later, the b<strong>in</strong>ary resource file can be bound to your<br />

application’s executable file.<br />

List<strong>in</strong>g 9.4 is a partial list<strong>in</strong>g. Bitmaps are conta<strong>in</strong>ed <strong>in</strong> the resource file as numerical data.<br />

The resource descriptions for bitmaps can get very long. The rest of the bitmap resource<br />

descriptions for the Jump<strong>in</strong>g Jack bitmaps require about 200 l<strong>in</strong>es of resource code, so I<br />

decided not to list them all. Figure 9.12 shows Jump<strong>in</strong>g Jack <strong>in</strong> mid-stride.<br />

Figure 9.12.<br />

Jump<strong>in</strong>g Jack <strong>in</strong><br />

action.<br />

NOTE<br />

Creat<strong>in</strong>g additional resources for your programs is not rocket science, but it is not exactly<br />

trivial, either. It takes some time to realize how it all fits together. You may never need to add<br />

additional resources to your applications. If you do, though, it’s good to have an idea where<br />

to beg<strong>in</strong>. If this section left you a little dazed and confused, don’t worry. Over time, it all starts<br />

to make sense.<br />

Bitmaps, icons, and cursors found <strong>in</strong> other programs are usually<br />

copyrighted material. Do not use resources from any copyrighted<br />

program without permission. Further, assume that all programs are<br />

copyrighted unless they are specifically said to be freeware. You are free<br />

to use the bitmaps, icons, and cursors that are provided with

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!