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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

6<br />

188 Day 6<br />

Figure 6.10.<br />

A typical About<br />

dialog box.<br />

Figure 6.10 represents a typical About dialog box. It conta<strong>in</strong>s the program name, the<br />

copyright <strong>in</strong>formation, and the application’s icon. The resource script def<strong>in</strong>ition for the<br />

dialog box is shown <strong>in</strong> List<strong>in</strong>g 6.2.<br />

List<strong>in</strong>g 6.2. A dialog box resource def<strong>in</strong>ition.<br />

1: IDD_ABOUT DIALOG 58, 53, 194, 119<br />

2: STYLE DS_MODALFRAME | WS_POPUP |<br />

3: WS_VISIBLE | WS_CAPTION | WS_SYSMENU<br />

4: CAPTION “About TMMPlayer Example Program”<br />

5: FONT 8, “MS Sans Serif”<br />

6: {<br />

7: DEFPUSHBUTTON “OK”, IDOK, 72, 96, 50, <strong>14</strong><br />

8: CTEXT “TMMPlayer Example Program”, -1, 48, 22, 128, 8<br />

9: CTEXT “Copyright © 1996, by Kent Reisdorph”, -1, 32, 47, 136, 8<br />

10: CTEXT “March 15, 1996”, -1, 24, 59, <strong>14</strong>6, 8<br />

11: CONTROL “”, 99, “button”, BS_GROUPBOX |<br />

12: WS_CHILD | WS_VISIBLE | WS_GROUP, 12, 4, 176, 70<br />

13: CONTROL 1, 1, “static”, SS_ICON |<br />

<strong>14</strong>: SS_SUNKEN | WS_CHILD | WS_VISIBLE, 24, 17, 20, 20<br />

15: }<br />

The resource script conta<strong>in</strong>s <strong>in</strong>formation that W<strong>in</strong>dows uses to build the dialog box at<br />

runtime. This <strong>in</strong>formation <strong>in</strong>cludes the number and type of controls on the dialog box, as<br />

well as their size, position, text, options, and so on. Of course, the resource script also <strong>in</strong>cludes<br />

the same type of <strong>in</strong>formation for the dialog box itself.<br />

Some W<strong>in</strong>dows programmers don’t use a dialog box editor at all, but prefer to write the dialog<br />

box def<strong>in</strong>ition from scratch with a text editor. While I can’t fault those programmers for<br />

creat<strong>in</strong>g dialog boxes <strong>in</strong> this manner, I can say that for most programmers to take that<br />

approach would be, er, less than 100 percent efficient. It would take many times longer to<br />

create a dialog box <strong>in</strong> that manner than with the visual approach.<br />

Usually all of the application’s dialog box def<strong>in</strong>itions are conta<strong>in</strong>ed <strong>in</strong> a s<strong>in</strong>gle resource script<br />

file that has the filename extension .RC. At some po<strong>in</strong>t <strong>in</strong> the program-creation process, the

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

Saved successfully!

Ooh no, something went wrong!