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.

254 Day 7<br />

NOTE<br />

1. Choose Edit | Cut from the ma<strong>in</strong> menu. The Code Editor comes to the top, and<br />

the EditCutClick() event handler is displayed.<br />

2. Type the follow<strong>in</strong>g at the cursor:<br />

Memo->CutToClipboard();<br />

And that’s all there is to that particular menu item! You may not fully realize it, but VCL does<br />

a lot for you beh<strong>in</strong>d the scenes. The whole idea of a framework is to take the burden of the<br />

low-level details off the programmer’s back. Life is good.<br />

One of the <strong>in</strong>terest<strong>in</strong>g aspects of a program like <strong>C++</strong>Builder is that you rarely view your<br />

program as a whole. <strong>C++</strong>Builder conveniently takes you to the section of code you need to<br />

work on to deal with a particular event, so you usually only see your program <strong>in</strong> small chunks.<br />

List<strong>in</strong>g 7.1 conta<strong>in</strong>s the header for the ScratchPad program up to this po<strong>in</strong>t. The header is<br />

entirely <strong>C++</strong>Builder generated. The entire SPMAIN.CPP program is shown <strong>in</strong> List<strong>in</strong>g 7.2.<br />

Follow the examples you’ve just worked through to write code for each of the rema<strong>in</strong><strong>in</strong>g<br />

menu items. Copy the code for each of the menu OnClick handlers from List<strong>in</strong>g 7.2. (The<br />

comment l<strong>in</strong>es are there to expla<strong>in</strong> to you what the code is do<strong>in</strong>g. You don’t have to <strong>in</strong>clude<br />

them when you type the code.)<br />

List<strong>in</strong>g 7.1. SPMAIN.H.<br />

The event handlers appear <strong>in</strong> the source file <strong>in</strong> the order <strong>in</strong> which they<br />

were created. Don’t be concerned if the order of the event handlers <strong>in</strong><br />

your source file does not exactly match List<strong>in</strong>g 7.2. The order <strong>in</strong> which<br />

the functions appear makes no difference to the compiler.<br />

1: //------------------------------------------------------------<br />

2: #ifndef SPMa<strong>in</strong>H<br />

3: #def<strong>in</strong>e SPMa<strong>in</strong>H<br />

4: //------------------------------------------------------------<br />

5: #<strong>in</strong>clude <br />

6: #<strong>in</strong>clude <br />

7: #<strong>in</strong>clude <br />

8: #<strong>in</strong>clude <br />

9: #<strong>in</strong>clude <br />

10: #<strong>in</strong>clude <br />

11: #<strong>in</strong>clude <br />

12: #<strong>in</strong>clude <br />

13: #<strong>in</strong>clude <br />

<strong>14</strong>: //------------------------------------------------------------<br />

15: class TScratchPad : public TForm<br />

16: {

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

Saved successfully!

Ooh no, something went wrong!