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.

256 Day 7<br />

List<strong>in</strong>g 7.2. SPMAIN.CPP.<br />

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

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

3: #pragma hdrstop<br />

4: #<strong>in</strong>clude “SPMa<strong>in</strong>.h”<br />

5: //------------------------------------------------------------<br />

6: #pragma resource “*.dfm”<br />

7: TScratchPad *ScratchPad;<br />

8: //------------------------------------------------------------<br />

9: __fastcall TScratchPad::TScratchPad(TComponent* Owner)<br />

10: : TForm(Owner)<br />

11: {<br />

12: }<br />

13: //------------------------------------------------------------<br />

<strong>14</strong>: void __fastcall TScratchPad::FileNewClick(TObject *Sender)<br />

15: {<br />

16: //<br />

17: // Open a file. First check to see if the current file<br />

18: // needs to be saved.<br />

19: //<br />

20: if (Memo->Modified) {<br />

21: //<br />

22: // Display a message box.<br />

23: //<br />

24: <strong>in</strong>t result = Application->MessageBox(<br />

25: “The current file has changed. Save changes?”,<br />

26: “ScratchPad Message”, MB_YESNOCANCEL);<br />

27: //<br />

28: // If Yes was clicked then save the current file.<br />

29: //<br />

30: if (result == IDYES) FileSaveClick(Sender);<br />

31: //<br />

32: // If No was clicked then do noth<strong>in</strong>g.<br />

33: //<br />

34: if (result == IDCANCEL) return;<br />

35: }<br />

36: //<br />

37: // Delete the str<strong>in</strong>gs <strong>in</strong> the memo, if any.<br />

38: //<br />

39: if (Memo->L<strong>in</strong>es->Count > 0) Memo->Clear();<br />

40: //<br />

41: // Set the FileName property of the Save Dialog to a<br />

42: // blank str<strong>in</strong>g. This lets us know that the file has<br />

43: // not yet been saved.<br />

44: //<br />

45: SaveDialog->FileName = “”;<br />

46: }<br />

47: //---------------------------------------------------- -- -- -- --<br />

48: void __fastcall TScratchPad::FileOpenClick(TObject *Sender)<br />

49: {<br />

50: //<br />

51: // Open a file. First check to see if the current file needs<br />

52: // to be saved. Same logic as <strong>in</strong> FileNewClick() above.<br />

53: //

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

Saved successfully!

Ooh no, something went wrong!