ɎȿȾȿɊȺɅɖɇɈȿ ȺȽȿɇɌɋɌȼɈ ɉɈ ɈȻɊȺɁɈȼȺɇɂɘ ȽɈɋɍȾȺɊɋɌȼȿɇɇɈȿ ɈȻɊȺɁɈȼȺɌȿɅɖɇɈȿ ɍɑɊȿɀȾȿɇɂȿ ȼɕɋɒȿȽɈ ɉɊɈɎȿɋɋɂɈɇȺɅɖɇɈȽɈ ɈȻɊȺɁɈȼȺɇɂə «ȼɈɊɈɇȿɀɋɄɂɃ ȽɈɋɍȾȺɊɋɌȼȿɇɇɕɃ ɍɇɂȼȿɊɋɂɌȿɌ»
ȿ.ɇ. ɄɈɊɀɈȼ, Ɉ.Ⱥ. ɄɍɓȿȼȺ
ȼȼȿȾȿɇɂȿ ȼ ɌȿɏɇɈɅɈȽɂɘ ɉɊɈȽɊȺɆɆɂɊɈȼȺɇɂə ɑɚɫɬɶ 1. ɋɪɟɞɚ ɨɛɴɟɤɬɧɨ-ɨɪɢɟɧɬɢɪɨɜɚɧɧɨɝɨ ɩɪɨɝɪɚɦɦɢɪɨɜɚɧɢɹ Delphi ɍɱɟɛɧɨɟ ɩɨɫɨɛɢɟ ɞɥɹ ɜɭɡɨɜ
ɂɡɞɚɬɟɥɶɫɤɨ-ɩɨɥɢɝɪɚɮɢɱɟɫɤɢɣ ɰɟɧɬɪ ȼɨɪɨɧɟɠɫɤɨɝɨ ɝɨɫɭɞɚɪɫɬɜɟɧɧɨɝɨ ɭɧɢɜɟɪɫɢɬɟɬɚ 2007
ɍɬɜɟɪɠɞɟɧɨ ɧɚɭɱɧɨ-ɦɟɬɨɞɢɱɟɫɤɢɦ ɫɨɜɟɬɨɦ ɮɚɤɭɥɶɬɟɬɚ ɩɪɢɤɥɚɞɧɨɣ ɦɚɬɟɦɚɬɢɤɢ, ɢɧɮɨɪɦɚɬɢɤɢ ɢ ɦɟɯɚɧɢɤɢ 14 ɦɚɹ 2007 ɝ., ɩɪɨɬɨɤɨɥ ʋ 9
Ɋɟɰɟɧɡɟɧɬ ɡɚɜ. ɤɚɮ. ɩɪɨɝɪɚɦɦɢɪɨɜɚɧɢɹ ɢ ɢɧɮɨɪɦɚɰɢɨɧɧɵɯ ɬɟɯɧɨɥɨɝɢɣ ɮɚɤɭɥɶɬɟɬɚ ɤɨɦɩɶɸɬɟɪɧɵɯ ɧɚɭɤ ȼɨɪɨɧɟɠɫɤɨɝɨ ɝɨɫɭɞɚɪɫɬɜɟɧɧɨɝɨ ɭɧɢɜɟɪɫɢɬɟɬɚ, ɤɚɧɞ. ɮɢɡ.-ɦɚɬ. ɧɚɭɤ, ɞɨɰ. ɇ.Ⱥ. Ɍɸɤɚɱɟɜ.
Ʉɨɪɠɨɜ ȿ.ɇ. ȼɜɟɞɟɧɢɟ ɜ ɬɟɯɧɨɥɨɝɢɸ ɩɪɨɝɪɚɦɦɢɪɨɜɚɧɢɹ : ɭɱɟɛ. ɩɨɫɨɛɢɟ ɞɥɹ ɜɭɡɨɜ : ɜ 3 ɱ. ɑ. 1 : ɋɪɟɞɚ ɨɛɴɟɤɬɧɨ-ɨɪɢɟɧɬɢɪɨɜɚɧɧɨɝɨ ɩɪɨɝɪɚɦɦɢɪɨɜɚɧɢɹ Delphi / ȿ.ɇ. Ʉɨɪɠɨɜ, Ɉ.Ⱥ. Ʉɭɳɢɧɚ. – ȼɨɪɨɧɟɠ : ɂɡɞɚɬɟɥɶɫɤɨɩɨɥɢɝɪɚɮɢɱɟɫɤɢɣ ɰɟɧɬɪ ȼɨɪɨɧɟɠɫɤɨɝɨ ɝɨɫɭɞɚɪɫɬɜɟɧɧɨɝɨ ɭɧɢɜɟɪɫɢɬɟɬɚ, 2007. – 80 ɫ. ɇɚɫɬɨɹɳɟɟ ɭɱɟɛɧɨɟ ɩɨɫɨɛɢɟ ɫɬɚɜɢɬ ɫɜɨɟɣ ɰɟɥɶɸ ɪɚɡɜɢɬɢɟ ɩɟɪɜɵɯ ɩɪɚɤɬɢɱɟɫɤɢɯ ɧɚɜɵɤɨɜ ɢɫɩɨɥɶɡɨɜɚɧɢɹ ɫɪɟɞɵ ɩɪɨɝɪɚɦɦɢɪɨɜɚɧɢɹ Delphi ɜ ɪɚɡɪɚɛɨɬɤɟ ɩɪɨɝɪɚɦɦɧɨɝɨ ɨɛɟɫɩɟɱɟɧɢɹ ɤɨɦɩɶɸɬɟɪɧɵɯ ɫɢɫɬɟɦ ɨɛɳɟɝɨ ɧɚɡɧɚɱɟɧɢɹ. ȼ ɩɟɪɜɨɣ ɱɚɫɬɢ ɩɨɫɨɛɢɹ ɞɚɟɬɫɹ ɨɛɳɟɟ ɩɪɟɞɫɬɚɜɥɟɧɢɟ ɨɛ ɨɛɴɟɤɬɧɨɨɪɢɟɧɬɢɪɨɜɚɧɧɨɣ ɫɪɟɞɟ ɪɚɡɪɚɛɨɬɤɢ ɩɪɨɝɪɚɦɦɧɵɯ ɩɨɞɫɢɫɬɟɦ, ɩɪɢɜɨɞɹɬɫɹ ɧɟɤɨɬɨɪɵɟ ɫɜɟɞɟɧɢɹ ɨ ɫɨɜɪɟɦɟɧɧɵɯ ɜɡɝɥɹɞɚɯ ɜ ɨɛɥɚɫɬɢ ɬɟɯɧɨɥɨɝɢɢ ɨɛɴɟɤɬɧɨ-ɨɪɢɟɧɬɢɪɨɜɚɧɧɨɝɨ ɩɪɨɝɪɚɦɦɢɪɨɜɚɧɢɹ. ȼɨ ɜɬɨɪɨɣ ɱɚɫɬɢ ɩɪɟɞɫɬɚɜɥɟɧɵ ɡɚɞɚɧɢɹ ɢ ɩɪɢɦɟɪɵ ɢɯ ɜɵɩɨɥɧɟɧɢɹ ɜ ɪɚɦɤɚɯ ɥɚɛɨɪɚɬɨɪɧɨɝɨ ɩɪɚɤɬɢɤɭɦɚ, ɪɚɫɫɱɢɬɚɧɧɨɝɨ ɧɚ 20 ɚɤɚɞɟɦɢɱɟɫɤɢɯ ɱɚɫɨɜ. ȼ ɩɪɢɥɨɠɟɧɢɢ ɩɪɢɜɟɞɟɧɵ ɧɚɢɛɨɥɟɟ ɱɚɫɬɨ ɢɫɩɨɥɶɡɭɟɦɵɟ ɩɪɢ ɪɚɡɪɚɛɨɬɤɟ ɩɪɨɝɪɚɦɦ ɫɜɟɞɟɧɢɹ ɤɚɤ ɨ ɫɚɦɨɣ ɫɪɟɞɟ Delphi, ɬɚɤ ɢ ɨ ɧɟɤɨɬɨɪɵɯ ɟɺ ɧɚɢɛɨɥɟɟ ɱɚɫɬɨ ɭɩɨɬɪɟɛɥɹɸɳɢɯɫɹ ɤɨɦɩɨɧɟɧɬɚɯ.
ɍɱɟɛɧɨɟ ɩɨɫɨɛɢɟ ɩɨɞɝɨɬɨɜɥɟɧɨ ɧɚ ɤɚɮɟɞɪɟ ɬɟɨɪɟɬɢɱɟɫɤɨɣ ɢ ɩɪɢɤɥɚɞɧɨɣ ɦɟɯɚɧɢɤɢ ɮɚɤɭɥɶɬɟɬɚ ɩɪɢɤɥɚɞɧɨɣ ɦɚɬɟɦɚɬɢɤɢ, ɢɧɮɨɪɦɚɬɢɤɢ ɢ ɦɟɯɚɧɢɤɢ ȼɨɪɨɧɟɠɫɤɨɝɨ ɝɨɫɭɞɚɪɫɬɜɟɧɧɨɝɨ ɭɧɢɜɟɪɫɢɬɟɬɚ. Ɋɟɤɨɦɟɧɞɭɟɬɫɹ ɞɥɹ ɫɬɭɞɟɧɬɨɜ 3 ɢ 4 ɤɭɪɫɨɜ ɮɚɤɭɥɶɬɟɬɚ ɩɪɢɤɥɚɞɧɨɣ ɦɚɬɟɦɚɬɢɤɢ, ɢɧɮɨɪɦɚɬɢɤɢ ɢ ɦɟɯɚɧɢɤɢ ȼɨɪɨɧɟɠɫɤɨɝɨ ɝɨɫɭɞɚɪɫɬɜɟɧɧɨɝɨ ɭɧɢɜɟɪɫɢɬɟɬɚ. Ⱦɥɹ ɫɩɟɰɢɚɥɶɧɨɫɬɟɣ: 010200 – Ɇɚɬɟɦɚɬɢɤɚ. ɉɪɢɤɥɚɞɧɚɹ ɦɚɬɟɦɚɬɢɤɚ; 010900 – Ɇɟɯɚɧɢɤɚ; 230201 – ɂɧɮɨɪɦɚɰɢɨɧɧɵɟ ɫɢɫɬɟɦɵ ɢ ɬɟɯɧɨɥɨɝɢɢ 2
ɋɈȾȿɊɀȺɇɂȿ ȼɜɟɞɟɧɢɟ 1. ɂɧɬɟɝɪɢɪɨɜɚɧɧɚɹ ɫɪɟɞɚ ɪɚɡɪɚɛɨɬɱɢɤɚ ɩɪɨɝɪɚɦɦɧɨɝɨ ɨɛɟɫɩɟɱɟɧɢɹ Delphi 1.1. Ƚɥɚɜɧɨɟ ɨɤɧɨ 1.2. Ɉɤɧɨ ɮɨɪɦɵ 1.3. Ɉɤɧɨ ɢɧɫɩɟɤɬɨɪɚ ɨɛɴɟɤɬɨɜ 1.4. Ɉɤɧɨ ɞɟɪɟɜɚ ɨɛɴɟɤɬɨɜ 1.5. Ɉɤɧɨ ɤɨɞɚ ɩɪɨɝɪɚɦɦɵ 1.6. Ɉɤɧɨ ɧɚɜɢɝɚɬɨɪɚ 2. ɋɬɪɭɤɬɭɪɚ ɩɪɨɝɪɚɦɦ Delphi 3. Ʌɚɛɨɪɚɬɨɪɧɵɣ ɩɪɚɤɬɢɤɭɦ 3.1. Ɋɚɡɪɚɛɨɬɤɚ ɩɪɢɥɨɠɟɧɢɣ ɜ ɂɋɊ – Delphi 7. ɋɬɚɧɞɚɪɬɧɵɟ ɜɢɡɭɚɥɶɧɵɟ ɤɨɦɩɨɧɟɧɬɵ 3.2. Ɉɛɪɚɛɨɬɤɚ ɢɫɤɥɸɱɢɬɟɥɶɧɵɯ ɫɢɬɭɚɰɢɣ. Ʉɨɦɩɢɥɹɰɢɹ ɢ ɨɬɥɚɞɤɚ ɩɪɨɝɪɚɦɦ 3.3. ɋɨɫɬɚɜ ɩɪɨɟɤɬɚ Delphi. Ɇɟɧɟɞɠɟɪ ɩɪɨɟɤɬɨɜ. ɍɫɬɚɧɨɜɤɚ ɩɚɪɚɦɟɬɪɨɜ ɩɪɨɟɤɬɚ. Ⱥɬɪɢɛɭɬɵ ɢ ɫɬɢɥɢ ɮɨɪɦɵ. ɋɨɡɞɚɧɢɟ ɢ ɭɧɢɱɬɨɠɟɧɢɟ ɮɨɪɦɵ. ȼɢɡɭɚɥɢɡɚɰɢɹ ɮɨɪɦɵ. ɂɫɩɨɥɶɡɨɜɚɧɢɟ ɧɟɫɤɨɥɶɤɢɯ ɮɨɪɦ ɜ ɩɪɢɥɨɠɟɧɢɢ 3.4. Ƚɥɚɜɧɨɟ ɦɟɧɸ ɮɨɪɦɵ. ȼɫɩɨɦɨɝɚɬɟɥɶɧɵɟ ɦɟɧɸ. ɋɬɚɧɞɚɪɬɧɵɟ ɞɢɚɥɨɝɢ. ɉɪɨɝɪɚɦɦɵ, ɭɩɪɚɜɥɹɟɦɵɟ ɫɨɛɵɬɢɹɦɢ. ɋɨɛɵɬɢɹ, ɨɛɪɚɛɚɬɵɜɚɟɦɵɟ ɮɨɪɦɨɣ. ɋɨɛɵɬɢɹ ɨɬ ɤɥɚɜɢɚɬɭɪɵ ɢ ɦɵɲɢ. ɋɨɛɵɬɢɹ ɩɪɨɬɨɤɨɥɚ Drag & Drop 3.5. ɉɪɢɦɟɪɵ ɜɢɡɭɚɥɶɧɵɯ ɤɨɦɩɨɧɟɧɬɨɜ Windows-ɢɧɬɟɪɮɟɣɫɚ. Ɂɚɱɟɬɧɨɟ ɡɚɧɹɬɢɟ. Ɋɚɡɪɚɛɨɬɤɚ ɩɪɨɫɬɨɝɨ ɩɪɢɥɨɠɟɧɢɹ ɞɥɹ Windows ɜ ɂɋɊ–Delphi 7 4. Ɋɟɤɨɦɟɧɞɚɰɢɢ ɩɨ ɩɨɞɝɨɬɨɜɤɟ ɢ ɨɮɨɪɦɥɟɧɢɸ ɢɧɞɢɜɢɞɭɚɥɶɧɵɯ ɡɚɞɚɧɢɣ ɉɪɢɥɨɠɟɧɢɟ 1. Ƚɥɚɜɧɨɟ ɢɥɢ ɨɫɧɨɜɧɨɟ ɦɟɧɸ ɫɪɟɞɵ Delphi Ɍɚɛɥɢɰɚ 1.1. Ɉɩɰɢɹ File Ɍɚɛɥɢɰɚ 1.2. Ɉɩɰɢɹ Edit Ɍɚɛɥɢɰɚ 1.3. Ɉɩɰɢɹ Run Ɍɚɛɥɢɰɚ 1.4. ɉɢɤɬɨɝɪɚɮɢɱɟɫɤɢɟ ɤɧɨɩɤɢ ɩɚɧɟɥɟɣ ɢɧɫɬɪɭɦɟɧɬɨɜ ɉɪɢɥɨɠɟɧɢɟ 2. Ɇɟɧɸ ɤɨɦɩɨɧɟɧɬɨɜ Ɍɚɛɥɢɰɚ 2.1. ɋɜɨɣɫɬɜɚ ɤɨɦɩɨɧɟɧɬɚ Edit Ɍɚɛɥɢɰɚ 2.2. ɋɜɨɣɫɬɜɚ ɤɨɦɩɨɧɟɧɬɚ Button Ɍɚɛɥɢɰɚ 2.3. ɋɜɨɣɫɬɜɚ ɤɨɦɩɨɧɟɧɬɚ Memo ɉɪɢɥɨɠɟɧɢɟ 3. Ɉɫɧɨɜɧɵɟ ɦɚɬɟɦɚɬɢɱɟɫɤɢɟ ɮɭɧɤɰɢɢ ɉɪɢɥɨɠɟɧɢɟ 4. Ƚɪɚɮɢɱɟɫɤɢɣ ɢɧɫɬɪɭɦɟɧɬɚɪɢɣ Ɍɚɛɥɢɰɚ 4.1. ɋɜɨɣɫɬɜɚ ɤɥɚɫɫɚ TFont Ɍɚɛɥɢɰɚ 4.2. ɋɜɨɣɫɬɜɚ ɤɥɚɫɫɚ ɌɊɟn Ɍɚɛɥɢɰɚ 4.3. ɋɜɨɣɫɬɜɚ ɤɥɚɫɫɚ TBrush Ɍɚɛɥɢɰɚ 4.4. ɋɜɨɣɫɬɜɚ ɤɥɚɫɫɚ TCanvas Ɍɚɛɥɢɰɚ 4.5. Ɇɟɬɨɞɵ ɤɥɚɫɫɚ TCanvas Ʌɢɬɟɪɚɬɭɪɚ
3
4 5 5 7 8 9 9 11 11 13 13 24
37
46
62 70 72 72 72 73 74 75 76 76 77 78 78 79 79 80 81 82 85
ȼȼȿȾȿɇɂȿ ɇɚɫɬɨɹɳɟɟ ɭɱɟɛɧɨɟ ɩɨɫɨɛɢɟ ɩɨɞɝɨɬɨɜɥɟɧɨ ɞɥɹ ɫɬɭɞɟɧɬɨɜ, ɧɚɱɢɧɚɸɳɢɯ ɢɡɭɱɚɬɶ ɤɭɪɫ «əɡɵɤɢ ɩɪɨɝɪɚɦɦɢɪɨɜɚɧɢɹ ɜɵɫɨɤɨɝɨ ɭɪɨɜɧɹ», ɢɥɢ «Ɍɟɯɧɨɥɨɝɢɹ ɩɪɨɝɪɚɦɦɢɪɨɜɚɧɢɹ», ɤɨɝɞɚ ɜɵɛɪɚɧɚ ɫɪɟɞɚ ɩɪɨɝɪɚɦɦɢɪɨɜɚɧɢɹ Borland Delphi. Ɉɫɧɨɜɧɚɹ ɰɟɥɶ ɩɨɫɨɛɢɹ ɡɚɤɥɸɱɚɟɬɫɹ ɜ ɪɚɡɜɢɬɢɢ ɩɟɪɜɵɯ ɩɪɚɤɬɢɱɟɫɤɢɯ ɧɚɜɵɤɨɜ ɢɫɩɨɥɶɡɨɜɚɧɢɹ ɫɪɟɞɵ ɩɪɨɝɪɚɦɦɢɪɨɜɚɧɢɹ Delphi ɜ ɪɚɡɪɚɛɨɬɤɟ ɩɪɨɝɪɚɦɦɧɨɝɨ ɨɛɟɫɩɟɱɟɧɢɹ ɤɨɦɩɶɸɬɟɪɧɵɯ ɫɢɫɬɟɦ ɨɛɳɟɝɨ ɧɚɡɧɚɱɟɧɢɹ. ȼ ɩɟɪɜɨɣ ɱɚɫɬɢ ɩɨɫɨɛɢɹ ɞɚɟɬɫɹ ɨɛɳɟɟ ɩɪɟɞɫɬɚɜɥɟɧɢɟ ɨɛ ɨɛɴɟɤɬɧɨɨɪɢɟɧɬɢɪɨɜɚɧɧɨɣ ɫɪɟɞɟ ɪɚɡɪɚɛɨɬɤɢ ɩɪɨɝɪɚɦɦ Borland Delphi, ɨɬɥɢɱɚɸɳɟɣɫɹ, ɧɚ ɧɚɲ ɜɡɝɥɹɞ, ɨɬ ɞɪɭɝɢɯ ɩɨɞɨɛɧɵɯ ɫɢɫɬɟɦ ɧɚɢɛɨɥɶɲɟɣ ɫɬɪɨɝɨɫɬɶɸ ɹɡɵɤɚ, ɫ ɨɞɧɨɣ ɫɬɨɪɨɧɵ, ɢ ɩɨɩɭɥɹɪɧɨɫɬɶɸ ɫɪɟɞɢ ɨɛɭɱɚɸɳɢɯɫɹ ɩɪɢ ɢɡɭɱɟɧɢɢ ɨɫɧɨɜ ɩɪɨɝɪɚɦɦɢɪɨɜɚɧɢɹ, ɫ ɞɪɭɝɨɣ. ȼ ɩɨɫɨɛɢɢ ɩɪɢɜɨɞɹɬɫɹ ɧɟɤɨɬɨɪɵɟ ɧɚɱɚɥɶɧɵɟ ɫɜɟɞɟɧɢɹ ɨ ɫɨɜɪɟɦɟɧɧɵɯ ɜɡɝɥɹɞɚɯ ɜ ɨɛɥɚɫɬɢ ɬɟɯɧɨɥɨɝɢɢ ɨɛɴɟɤɬɧɨ-ɨɪɢɟɧɬɢɪɨɜɚɧɧɨɝɨ ɩɪɨɝɪɚɦɦɢɪɨɜɚɧɢɹ. ȼɨ ɜɬɨɪɨɣ ɱɚɫɬɢ ɩɪɟɞɫɬɚɜɥɟɧɵ ɡɚɞɚɧɢɹ ɢ ɩɪɢɦɟɪɵ ɢɯ ɜɵɩɨɥɧɟɧɢɹ ɜ ɪɚɦɤɚɯ ɥɚɛɨɪɚɬɨɪɧɨɝɨ ɩɪɚɤɬɢɤɭɦɚ, ɪɚɫɫɱɢɬɚɧɧɨɝɨ ɧɚ 20 ɚɤɚɞɟɦɢɱɟɫɤɢɯ ɱɚɫɨɜ. ɉɪɟɞɩɨɥɚɝɚɟɬɫɹ, ɱɬɨ ɩɪɚɤɬɢɤɭɦ ɫɨɫɬɨɢɬ ɢɡ ɩɹɬɢ ɱɟɬɵɪɟɯɱɚɫɨɜɵɯ ɫɞɜɨɟɧɧɵɯ ɡɚɧɹɬɢɣ. ɉɟɪɜɚɹ ɱɚɫɬɶ ɡɚɧɹɬɢɹ ɜɵɩɨɥɧɹɟɬɫɹ ɫɬɭɞɟɧɬɨɦ ɩɨɞ ɪɭɤɨɜɨɞɫɬɜɨɦ ɩɪɟɩɨɞɚɜɚɬɟɥɹ, ɚ ɜɬɨɪɚɹ – ɫɚɦɨɫɬɨɹɬɟɥɶɧɨ. ȼ ɉɪɢɥɨɠɟɧɢɢ ɩɪɢɜɟɞɟɧɵ ɧɚɢɛɨɥɟɟ ɱɚɫɬɨ ɢɫɩɨɥɶɡɭɟɦɵɟ ɩɪɢ ɪɚɡɪɚɛɨɬɤɟ ɩɪɨɝɪɚɦɦ ɫɜɟɞɟɧɢɹ ɤɚɤ ɨ ɫɚɦɨɣ ɫɪɟɞɟ Delphi, ɬɚɤ ɢ ɨ ɧɟɤɨɬɨɪɵɯ ɟɺ ɧɚɢɛɨɥɟɟ ɱɚɫɬɨ ɭɩɨɬɪɟɛɥɹɸɳɢɯɫɹ ɤɨɦɩɨɧɟɧɬɚɯ. ɉɪɟɞɩɨɥɚɝɚɟɬɫɹ, ɱɬɨ ɫɬɭɞɟɧɬ ɪɚɧɟɟ ɩɪɨɫɥɭɲɚɥ ɧɚɱɚɥɶɧɵɣ ɤɭɪɫ «ɂɧɮɨɪɦɚɬɢɤɚ» ɢ ɩɨɥɭɱɢɥ ɧɟɨɛɯɨɞɢɦɵɟ ɫɜɟɞɟɧɢɹ ɨ ɠɢɡɧɟɧɧɨɦ ɰɢɤɥɟ ɩɪɨɝɪɚɦɦɵ, ɩɨɧɹɬɢɟ ɨɛ ɚɥɝɨɪɢɬɦɟ ɢ ɟɝɨ ɫɜɨɣɫɬɜɚɯ, ɚ ɬɚɤɠɟ ɩɪɢɨɛɪɟɥ ɩɪɚɤɬɢɱɟɫɤɢɟ ɧɚɜɵɤɢ ɪɚɡɪɚɛɨɬɤɢ ɚɥɝɨɪɢɬɦɨɜ, ɜɤɥɸɱɚɸɳɢɟ ɫɥɟɞɭɸɳɢɟ ɲɚɝɢ, ɩɪɟɞɲɟɫɬɜɭɸɳɢɟ ɷɬɚɩɭ ɫɨɛɫɬɜɟɧɧɨ ɩɪɨɝɪɚɦɦɢɪɨɜɚɧɢɹ (ɤɨɞɢɪɨɜɚɧɢɹ): 1) ɚɧɚɥɢɡ ɡɚɞɚɧɢɹ ɢ ɨɩɪɟɞɟɥɟɧɢɟ ɨɫɧɨɜɧɨɣ ɢɞɟɢ ɟɝɨ ɪɟɚɥɢɡɚɰɢɢ; 2) ɨɩɪɟɞɟɥɟɧɢɟ ɜɯɨɞɧɵɯ ɞɚɧɧɵɯ; 3) ɨɩɪɟɞɟɥɟɧɢɟ ɜɵɯɨɞɧɵɯ ɞɚɧɧɵɯ; 4) ɡɚɩɢɫɶ ɬɟɤɫɬɚ ɧɚ ɚɥɝɨɪɢɬɦɢɱɟɫɤɨɦ ɹɡɵɤɟ ɢɥɢ ɫɨɫɬɚɜɥɟɧɢɟ ɛɥɨɤɫɯɟɦɵ ɚɥɝɨɪɢɬɦɚ. ɗɬɢ ɞɟɣɫɬɜɢɹ, ɩɪɟɞɲɟɫɬɜɭɸɳɢɟ ɧɟɩɨɫɪɟɞɫɬɜɟɧɧɨɣ ɪɚɛɨɬɟ ɫɨ ɫɪɟɞɨɣ ɩɪɨɝɪɚɦɦɢɪɨɜɚɧɢɹ, ɜ ɞɚɧɧɨɦ ɩɨɫɨɛɢɢ ɧɟ ɪɚɫɫɦɚɬɪɢɜɚɸɬɫɹ. ɉɨɥɚɝɚɟɬɫɹ, ɨɞɧɚɤɨ, ɱɬɨ ɩɨɞɨɛɧɚɹ ɩɪɟɞɜɚɪɢɬɟɥɶɧɚɹ ɪɚɛɨɬɚ ɩɪɨɜɨɞɢɬɫɹ ɤɚɠɞɵɦ ɫɬɭɞɟɧɬɨɦ ɫɚɦɨɫɬɨɹɬɟɥɶɧɨ ɢ ɨɮɨɪɦɥɹɟɬɫɹ ɞɨɥɠɧɵɦ ɨɛɪɚɡɨɦ ɜ ɪɚɛɨɱɟɣ ɬɟɬɪɚɞɢ. Ɇɵ ɫɨɱɥɢ ɜɨɡɦɨɠɧɵɦ ɬɚɤɠɟ ɧɟ ɚɤɰɟɧɬɢɪɨɜɚɬɶ ɜɧɢɦɚɧɢɟ ɧɚ ɬɚɤɨɦ ɜɨɩɪɨɫɟ, ɤɚɤ ɬɟɫɬɢɪɨɜɚɧɢɟ ɪɚɡɪɚɛɨɬɚɧɧɨɣ ɩɪɨɝɪɚɦɦɵ, ɯɨɬɹ ɷɬɨ, ɛɟɡɭɫɥɨɜɧɨ, ɜɚɠɧɟɣɲɢɣ ɷɬɚɩ ɠɢɡɧɟɧɧɨɝɨ ɰɢɤɥɚ ɩɪɨɝɪɚɦɦɵ ɢ ɨɞɢɧ ɢɡ ɩɪɢɟɦɨɜ ɞɨɤɚɡɚɬɟɥɶɫɬɜɚ ɩɪɚɜɢɥɶɧɨɫɬɢ ɟɟ ɪɚɛɨɬɵ ɢ ɫɨɨɬɜɟɬɫɬɜɢɹ ɮɭɧɤɰɢɨɧɚɥɶɧɵɦ ɢ ɩɪɨɰɟɞɭɪɧɵɦ ɫɩɟɰɢɮɢɤɚɰɢɹɦ. Ⱦɭɦɚɟɬɫɹ, ɩɪɟɞɫɬɚɜɥɟɧɧɵɣ ɦɚɬɟɪɢɚɥ ɜ ɧɚɢɛɨɥɶɲɟɣ ɫɬɟɩɟɧɢ ɨɬɜɟɱɚɟɬ ɨɫɧɨɜɧɨɣ ɡɚɞɚɱɟ ɷɬɨɝɨ ɫɟɦɟɫɬɪɨɜɨɝɨ ɤɭɪɫɚ. 4
1. ɂɇɌȿȽɊɂɊɈȼȺɇɇȺə ɋɊȿȾȺ ɊȺɁɊȺȻɈɌɑɂɄȺ ɉɊɈȽɊȺɆɆɇɈȽɈ ɈȻȿɋɉȿɑȿɇɂə DELPHI ɋɪɟɞɚ Delphi – ɷɬɨ ɫɥɨɠɧɵɣ ɢɧɫɬɪɭɦɟɧɬ, ɨɛɟɫɩɟɱɢɜɚɸɳɢɣ ɜɵɫɨɤɨɷɮɮɟɤɬɢɜɧɭɸ ɪɚɛɨɬɭ ɩɪɨɝɪɚɦɦɢɫɬɚ. ȼɢɡɭɚɥɶɧɨ ɨɧɚ ɪɟɚɥɢɡɭɟɬɫɹ ɜ ɜɢɞɟ ɧɟɫɤɨɥɶɤɢɯ ɨɞɧɨɜɪɟɦɟɧɧɨ ɪɚɫɤɪɵɜɚɸɳɢɯɫɹ ɧɚ ɷɤɪɚɧɟ ɨɤɨɧ. Ɉɤɧɚ ɦɨɠɧɨ ɩɟɪɟɦɟɳɚɬɶ ɩɨ ɷɤɪɚɧɭ, ɱɚɫɬɢɱɧɨ ɢɥɢ ɩɨɥɧɨɫɬɶɸ ɩɟɪɟɤɪɵɜɚɹ ɞɪɭɝ ɞɪɭɝɚ ɢ ɫɨɡɞɚɜɚɹ ɬɚɤɢɦ ɨɛɪɚɡɨɦ ɧɚɢɛɨɥɟɟ ɭɞɨɛɧɭɸ ɞɥɹ ɪɚɛɨɬɵ ɤɨɧɮɢɝɭɪɚɰɢɸ ɫɪɟɞɵ. ɉɨɫɥɟ ɡɚɩɭɫɤɚ Delphi ɧɚ ɷɤɪɚɧɟ ɦɨɠɧɨ ɭɜɢɞɟɬɶ ɧɟɱɬɨ, ɩɨɯɨɠɟɟ ɧɚ ɢɡɨɛɪɚɠɟɧɢɟ ɧɚ ɪɢɫ. 1.1 (ɧɚ ɪɢɫɭɧɤɟ ɩɨɤɚɡɚɧɵ ɨɤɧɚ Delphi ɜɟɪɫɢɢ 7; ɞɥɹ ɞɪɭɝɢɯ ɜɟɪɫɢɣ ɨɤɧɚ ɦɨɝɭɬ ɢɦɟɬɶ ɧɟɡɧɚɱɢɬɟɥɶɧɵɟ ɨɬɥɢɱɢɹ). ɇɚ ɧɟɦ ɢɡɨɛɪɚɠɟɧɨ ɩɹɬɶ ɧɚɢɛɨɥɟɟ ɜɚɠɧɵɯ ɨɤɨɧ Delphi: ɝɥɚɜɧɨɟ ɨɤɧɨ, ɨɤɧɨ ɮɨɪɦɵ, ɨɤɧɨ ɤɨɞɚ ɩɪɨɝɪɚɦɦɵ, ɨɤɧɨ ɂɧɫɩɟɤɬɨɪɚ ɨɛɴɟɤɬɨɜ, ɨɤɧɨ Ⱦɟɪɟɜɚ ɨɛɴɟɤɬɨɜ (Object Tree View). ɑɬɨɛɵ ɪɚɫɩɨɥɨɠɢɬɶ ɨɤɧɚ ɬɚɤɢɦ ɨɛɪɚɡɨɦ, ɤɚɤ ɷɬɨ ɩɨɤɚɡɚɧɨ ɧɚ ɪɢɫ. 1.1, ɧɟɨɛɯɨɞɢɦɨ «ɜɪɭɱɧɭɸ» ɢɡɦɟɧɹɬɶ ɢɯ ɩɨɥɨɠɟɧɢɟ ɢ ɪɚɡɦɟɪɵ, ɬ. ɤ. ɨɛɵɱɧɨ ɨɤɧɨ ɤɨɞɚ ɩɪɨɝɪɚɦɦɵ ɩɨɱɬɢ ɩɨɥɧɨɫɬɶɸ ɩɟɪɟɤɪɵɬɨ ɨɤɧɨɦ ɮɨɪɦɵ. ȼɩɪɨɱɟɦ, ɞɨɛɢɜɚɬɶɫɹ ɦɚɤɫɢɦɚɥɶɧɨɝɨ ɫɯɨɞɫɬɜɚ ɬɨɝɨ, ɱɬɨ ɜɢɞɧɨ ɧɚ ɷɤɪɚɧɟ ɤɨɦɩɶɸɬɟɪɚ, ɫ ɢɡɨɛɪɚɠɟɧɢɟɦ, ɩɨɤɚɡɚɧɧɵɦ ɧɚ ɪɢɫ. 1.1, ɜɨɜɫɟ ɧɟ ɨɛɹɡɚɬɟɥɶɧɨ: ɪɚɫɩɨɥɨɠɟɧɢɟ ɢ ɪɚɡɦɟɪɵ ɨɤɨɧ ɧɢɤɚɤ ɧɟ ɜɥɢɹɸɬ ɧɚ ɢɯ ɮɭɧɤɰɢɨɧɚɥɶɧɨɫɬɶ; ɟɫɥɢ ɜɵ ɧɟ ɜɢɞɢɬɟ ɧɚ ɷɤɪɚɧɟ ɨɤɧɚ ɤɨɞɚ, ɧɨ ɯɨɬɢɬɟ ɟɝɨ ɭɜɢɞɟɬɶ, ɩɪɨɫɬɨ ɧɚɠɦɢɬɟ ɤɥɚɜɢɲɭ F12 (ɟɫɥɢ ɤ ɷɬɨɦɭ ɦɨɦɟɧɬɭ ɚɤɬɢɜɧɵɦ ɛɵɥɨ ɨɤɧɨ ɂɧɫɩɟɤɬɨɪɚ ɨɛɴɟɤɬɨɜ, ɜɚɦ ɩɪɢɞɟɬɫɹ ɧɚɠɚɬɶ ɧɚ F12 ɟɳɟ ɪɚɡ). ɉɨɜɬɨɪɧɨɟ ɧɚɠɚɬɢɟ F12 ɜɧɨɜɶ ɚɤɬɢɜɢɡɢɪɭɟɬ ɨɤɧɨ ɮɨɪɦɵ ɢ ɬ. ɞ. – ɷɬɚ ɤɥɚɜɢɲɚ ɪɚɛɨɬɚɟɬ ɤɚɤ ɨɛɵɱɧɵɣ ɩɟɪɟɤɥɸɱɚɬɟɥɶ, ɩɨɨɱɟɪɟɞɧɨ ɩɨɤɚɡɵɜɚɹ ɨɤɧɨ ɮɨɪɦɵ ɢɥɢ ɨɤɧɨ ɤɨɞɚ ɩɪɨɝɪɚɦɦɵ. 1.1. Ƚɥɚɜɧɨɟ ɨɤɧɨ Ƚɥɚɜɧɨɟ ɨɤɧɨ ɨɫɭɳɟɫɬɜɥɹɟɬ ɨɫɧɨɜɧɵɟ ɮɭɧɤɰɢɢ ɭɩɪɚɜɥɟɧɢɹ ɩɪɨɟɤɬɨɦ ɫɨɡɞɚɜɚɟɦɨɣ ɩɪɨɝɪɚɦɦɵ. Ɇɢɧɢɦɢɡɚɰɢɹ ɝɥɚɜɧɨɝɨ ɨɤɧɚ ɩɪɢɜɨɞɢɬ ɤ ɢɫɱɟɡɧɨɜɟɧɢɸ ɫ ɷɤɪɚɧɚ ɞɪɭɝɢɯ ɨɤɨɧ Delphi (ɷɬɢ ɨɤɧɚ ɩɨɹɜɹɬɫɹ, ɤɚɤ ɬɨɥɶɤɨ ɛɭɞɭɬ ɜɨɫɫɬɚɧɨɜɥɟɧɵ ɪɚɡɦɟɪɵ ɝɥɚɜɧɨɝɨ ɨɤɧɚ), ɚ ɟɝɨ ɡɚɤɪɵɬɢɟ ɨɡɧɚɱɚɟɬ ɨɤɨɧɱɚɧɢɟ ɪɚɛɨɬɵ ɫ ɫɢɫɬɟɦɨɣ ɩɪɨɝɪɚɦɦɢɪɨɜɚɧɢɹ. ȼ ɝɥɚɜɧɨɦ ɨɤɧɟ ɪɚɫɩɨɥɚɝɚɟɬɫɹ ɨɫɧɨɜɧɨɟ ɦɟɧɸ Delphi (ɩɪɢɥɨɠɟɧɢɟ 1), ɩɚɧɟɥɶ ɭɩɪɚɜɥɟɧɢɹ ɫ ɧɚɛɨɪɨɦ ɩɢɤɬɨɝɪɚɮɢɱɟɫɤɢɯ ɤɧɨɩɨɤ ɢ ɩɚɥɢɬɪɚ ɤɨɦɩɨɧɟɧɬɨɜ. ȼɫɟ ɨɩɰɢɢ ɝɥɚɜɧɨɝɨ ɦɟɧɸ ɩɪɟɞɫɬɚɜɥɹɸɬ ɫɨɛɨɣ ɨɩɰɢɢ-ɡɚɝɨɥɨɜɤɢ, ɨɬɤɪɵɜɚɸɳɢɟ ɞɨɫɬɭɩ ɤ ɜɵɩɚɞɚɸɳɢɦ ɦɟɧɸ ɜɬɨɪɨɝɨ ɭɪɨɜɧɹ, ɜ ɤɨɬɨɪɵɯ ɫɨɞɟɪɠɚɬɫɹ ɤɨɦɚɧɞɵ ɫɪɟɞɵ, ɞɨɫɬɭɩɧɵɟ ɩɪɨɝɪɚɦɦɢɫɬɭ-ɩɨɥɶɡɨɜɚɬɟɥɸ.
5
1 6
4 2
7
5 3
Ɋɢɫ. 1.1. Ɉɫɧɨɜɧɵɟ ɨɤɧɚ ɫɪɟɞɵ Delphi: 1 – ɝɥɚɜɧɨɟ ɨɤɧɨ; 2 – ɨɤɧɨ Ɏɨɪɦɵ; 3 – ɨɤɧɨ Ʉɨɞɚ ɩɪɨɝɪɚɦɦɵ; 4 – ɉɚɥɢɬɪɚ ɤɨɦɩɨɧɟɧɬɨɜ; 5 – ɨɤɧɨ ɂɧɫɩɟɤɬɨɪɚ ɨɛɴɟɤɬɨɜ; 6 – ɉɚɧɟɥɶ ɢɧɫɬɪɭɦɟɧɬɨɜ; 7 – ɨɤɧɨ Ⱦɟɪɟɜɚ ɨɛɴɟɤɬɨɜ (Object Tree View) Ⱦɥɹ ɢɡɦɟɧɟɧɢɹ ɫɨɫɬɚɜɚ ɩɨɤɚɡɵɜɚɟɦɵɯ ɧɚ ɩɚɧɟɥɢ ɭɩɪɚɜɥɟɧɢɹ ɩɢɤɬɨɝɪɚɮɢɱɟɫɤɢɯ ɤɧɨɩɨɤ ɧɭɠɧɨ ɩɪɟɞɜɚɪɢɬɟɥɶɧɨ ɳɟɥɤɧɭɬɶ ɩɨ ɧɟɣ ɩɪɚɜɨɣ ɤɧɨɩɤɨɣ ɦɵɲɢ. ȼ ɩɨɹɜɢɜɲɟɦɫɹ ɩɨɫɥɟ ɷɬɨɝɨ ɨɤɧɟ ɜɫɩɨɦɨɝɚɬɟɥɶɧɨɝɨ ɦɟɧɸ (ɪɢɫ. 1.2ɚ)
ɚ) ɛ) Ɋɢɫ. 1.2. ɇɚɫɬɪɨɣɤɚ ɢɧɫɬɪɭɦɟɧɬɚɥɶɧɵɯ ɩɚɧɟɥɟɤ: ɚ – ɜɫɩɨɦɨɝɚɬɟɥɶɧɨɟ ɦɟɧɸ; ɛ – ɨɤɧɨ ɧɚɫɬɪɨɣɤɢ ɫ ɜɵɛɪɚɧɧɨɣ ɡɚɤɥɚɞɤɨɣ Commands 6
ɩɟɪɟɱɢɫɥɟɧɵ ɧɚɡɜɚɧɢɹ ɜɫɟɯ ɩɚɧɟɥɟɣ ɢ ɭɤɚɡɚɧ ɢɯ ɫɬɚɬɭɫ (ɨɬɦɟɱɟɧɧɵɟ ɮɥɚɠɤɚɦɢ ɩɚɧɟɥɢ ɜɢɞɧɵ; ɟɫɥɢ ɨɬɦɟɬɤɭ ɭɛɪɚɬɶ, ɩɚɧɟɥɶ ɢɫɱɟɡɧɟɬ). ɉɨɫɥɟ ɜɵɛɨɪɚ customize (ɇɚɫɬɪɨɣɤɚ) ɩɨɹɜɢɬɫɹ ɨɤɧɨ ɧɚɫɬɪɨɣɤɢ (ɪɢɫ. 1.2ɛ). Ɍɟɩɟɪɶ ɦɨɠɧɨ «ɫɬɚɫɤɢɜɚɬɶ» ɫ ɩɚɧɟɥɟɤ ɧɟɧɭɠɧɵɟ ɤɧɨɩɤɢ, ɜɵɛɢɪɚɬɶ ɢɡ ɫɩɢɫɤɚ ɜ ɨɤɧɟ commands (ɡɚɤɥɚɞɤɚ Commands) ɧɭɠɧɵɟ ɤɧɨɩɤɢ ɢ ɩɟɪɟɬɚɫɤɢɜɚɬɶ ɢɯ ɧɚ ɷɤɪɚɧ. ɉɢɤɬɨɝɪɚɮɢɱɟɫɤɢɟ ɤɧɨɩɤɢ ɨɬɤɪɵɜɚɸɬ ɛɵɫɬɪɵɣ ɞɨɫɬɭɩ ɤ ɧɚɢɛɨɥɟɟ ɜɚɠɧɵɦ ɤɨɦɚɧɞɚɦ ɫɪɟɞɵ (ɨɧɢ ɞɭɛɥɢɪɭɸɬ ɧɚɢɛɨɥɟɟ ɱɚɫɬɨ ɜɵɩɨɥɧɹɟɦɵɟ ɤɨɦɚɧɞɵ ɝɥɚɜɧɨɝɨ ɦɟɧɸ). ɉɨ ɮɭɧɤɰɢɨɧɚɥɶɧɨɦɭ ɩɪɢɡɧɚɤɭ ɨɧɢ ɪɚɡɞɟɥɟɧɵ ɧɚ 7 ɝɪɭɩɩ. Ʉɚɠɞɚɹ ɝɪɭɩɩɚ ɪɚɫɩɨɥɚɝɚɟɬɫɹ ɧɚ ɨɬɞɟɥɶɧɨɣ ɩɚɧɟɥɢ. ȼ ɩɪɢɥɨɠɟɧɢɢ 1, ɬɚɛɥ. 1.4 ɨɩɢɫɚɧɵ ɤɨɦɚɧɞɵ, ɪɟɚɥɢɡɭɟɦɵɟ ɫɬɚɧɞɚɪɬɧɵɦ ɧɚɛɨɪɨɦ ɩɢɤɬɨɝɪɚɮɢɱɟɫɤɢɯ ɤɧɨɩɨɤ. ɉɚɥɢɬɪɚ ɤɨɦɩɨɧɟɧɬɨɜ – ɷɬɨ ɝɥɚɜɧɨɟ ɛɨɝɚɬɫɬɜɨ Delphi. Ɉɧɚ ɡɚɧɢɦɚɟɬ ɩɪɚɜɭɸ ɱɚɫɬɶ ɝɥɚɜɧɨɝɨ ɨɤɧɚ ɢ ɢɦɟɟɬ ɡɚɤɥɚɞɤɢ, ɨɛɟɫɩɟɱɢɜɚɸɳɢɟ ɛɵɫɬɪɵɣ ɩɨɢɫɤ ɧɭɠɧɨɝɨ ɤɨɦɩɨɧɟɧɬɚ. ɑɟɪɟɡ ɦɟɧɸ ɤɨɦɩɨɧɟɧɬɨɜ (ɫɦ. ɩɪɢɥɨɠɟɧɢɟ 2) ɨɫɭɳɟɫɬɜɥɹɟɬɫɹ ɞɨɫɬɭɩ ɤ ɧɚɛɨɪɭ ɫɬɚɧɞɚɪɬɧɵɯ ɫɟɪɜɢɫɧɵɯ ɩɪɨɝɪɚɦɦ ɫɪɟɞɵ Delphi, ɤɨɬɨɪɵɟ ɨɩɢɫɵɜɚɸɬ ɧɟɤɨɬɨɪɵɣ ɜɢɡɭɚɥɶɧɵɣ ɷɥɟɦɟɧɬ (ɤɨɦɩɨɧɟɧɬ), ɩɨɦɟɳɟɧɧɵɣ ɩɪɨɝɪɚɦɦɢɫɬɨɦ ɜ ɨɤɧɨ ɮɨɪɦɵ. Ʉɚɠɞɵɣ ɤɨɦɩɨɧɟɧɬ ɢɦɟɟɬ ɨɩɪɟɞɟɥɟɧɧɵɣ ɧɚɛɨɪ ɫɜɨɣɫɬɜ (ɩɚɪɚɦɟɬɪɨɜ), ɤɨɬɨɪɵɟ ɩɪɨɝɪɚɦɦɢɫɬ ɦɨɠɟɬ ɡɚɞɚɜɚɬɶ. ɇɚɩɪɢɦɟɪ, ɰɜɟɬ, ɡɚɝɨɥɨɜɨɤ ɨɤɧɚ, ɧɚɞɩɢɫɶ ɧɚ ɤɧɨɩɤɟ, ɪɚɡɦɟɪ ɢ ɬɢɩ ɲɪɢɮɬɚ ɢ ɞɪ. 1.2. Ɉɤɧɨ ɮɨɪɦɵ Ɉɤɧɨ ɮɨɪɦɵ ɩɪɟɞɫɬɚɜɥɹɟɬ ɫɨɛɨɣ ɩɪɨɟɤɬ Windows-ɨɤɧɚ ɩɪɨɝɪɚɦɦɵ. ȼ ɷɬɨ ɨɤɧɨ ɜ ɩɪɨɰɟɫɫɟ ɧɚɩɢɫɚɧɢɹ ɩɪɨɝɪɚɦɦɵ ɩɨɦɟɳɚɸɬɫɹ ɧɟɨɛɯɨɞɢɦɵɟ ɤɨɦɩɨɧɟɧɬɵ. ɉɪɢɱɟɦ ɩɪɢ ɜɵɩɨɥɧɟɧɢɢ ɩɪɨɝɪɚɦɦɵ ɩɨɦɟɳɟɧɧɵɟ ɤɨɦɩɨɧɟɧɬɵ ɛɭɞɭɬ ɢɦɟɬɶ ɬɨɬ ɠɟ ɜɢɞ, ɱɬɨ ɢ ɧɚ ɷɬɚɩɟ ɩɪɨɟɤɬɢɪɨɜɚɧɢɹ. ɉɟɪɜɨɧɚɱɚɥɶɧɨ ɨɤɧɨ ɮɨɪɦɵ ɩɭɫɬɨ. Ɍɨɱɧɟɟ, ɨɧɨ ɫɨɞɟɪɠɢɬ ɫɬɚɧɞɚɪɬɧɵɟ ɞɥɹ Windows ɢɧɬɟɪɮɟɣɫɧɵɟ ɷɥɟɦɟɧɬɵ – ɤɧɨɩɤɢ ɜɵɡɨɜɚ ɫɢɫɬɟɦɧɨɝɨ ɦɟɧɸ, ɦɚɤɫɢɦɢɡɚɰɢɢ, ɦɢɧɢɦɢɡɚɰɢɢ ɢ ɡɚɤɪɵɬɢɹ ɨɤɧɚ, ɩɨɥɨɫɭ ɡɚɝɨɥɨɜɤɚ ɢ ɨɱɟɪɱɢɜɚɸɳɭɸ ɪɚɦɤɭ. ȼɫɹ ɪɚɛɨɱɚɹ ɨɛɥɚɫɬɶ ɨɤɧɚ ɨɛɵɱɧɨ ɡɚɩɨɥɧɟɧɚ ɬɨɱɤɚɦɢ ɤɨɨɪɞɢɧɚɬɧɨɣ ɫɟɬɤɢ, ɫɥɭɠɚɳɟɣ ɞɥɹ ɭɩɨɪɹɞɨɱɟɧɢɹ ɪɚɡɦɟɳɚɟɦɵɯ ɧɚ ɮɨɪɦɟ ɤɨɦɩɨɧɟɧɬɨɜ (ɜɵ ɦɨɠɟɬɟ ɭɛɪɚɬɶ ɷɬɢ ɬɨɱɤɢ, ɜɵɡɜɚɜ ɫ ɩɨɦɨɳɶɸ ɦɟɧɸ Tools | Environment options ɫɨɨɬɜɟɬɫɬɜɭɸɳɟɟ ɨɤɧɨ ɧɚɫɬɪɨɟɤ ɢ ɭɛɪɚɜ ɮɥɚɠɨɤ ɜ ɩɟɪɟɤɥɸɱɚɬɟɥɟ Display Grid ɧɚ ɨɤɧɟ, ɫɜɹɡɚɧɧɨɦ ɫ ɡɚɤɥɚɞɤɨɣ Preferences). Ɂɧɚɱɢɬɟɥɶɧɭɸ ɱɚɫɬɶ ɜɪɟɦɟɧɢ ɩɪɨɝɪɚɦɦɢɫɬ ɡɚɧɹɬ ɭɜɥɟɤɚɬɟɥɶɧɵɦ ɡɚɧɹɬɢɟɦ, ɧɚɩɨɦɢɧɚɸɳɢɦ ɪɚɛɨɬɭ ɫ ɧɚɛɨɪɨɦ ɞɟɬɚɥɟɣ ɤɨɧɫɬɪɭɤɬɨɪɚ «Lego»: ɨɧ «ɞɨɫɬɚɟɬ» ɢɡ ɩɚɥɢɬɪɵ ɤɨɦɩɨɧɟɧɬɨɜ, ɤɚɤ ɢɡ ɤɨɪɨɛɤɢ ɫ ɞɟɬɚɥɹɦɢ, ɧɭɠɧɵɣ ɤɨɦɩɨɧɟɧɬ ɢ ɪɚɡɦɟɳɚɟɬ ɟɝɨ ɧɚ «ɧɚɛɨɪɧɨɦ ɩɨɥɟ» ɨɤɧɚ ɮɨɪɦɵ, ɩɨɫɬɟɩɟɧɧɨ ɡɚɩɨɥɧɹɹ ɮɨɪɦɭ ɢɧɬɟɪɮɟɣɫɧɵɦɢ ɷɥɟɦɟɧɬɚɦɢ. ɋɨɛɫɬɜɟɧɧɨ, ɢɦɟɧɧɨ ɜ ɷɬɨɦ ɩɪɨɰɟɫɫɟ ɧɚɩɨɥɧɟɧɢɹ ɮɨɪɦɵ ɢ ɡɚɤɥɸɱɚɟɬɫɹ ɢɡɸɦɢɧɤɚ ɜɢɡɭɚɥɶɧɨɝɨ ɩɪɨɝɪɚɦɦɢɪɨɜɚɧɢɹ. ɉɪɨɝɪɚɦɦɢɫɬ ɜ ɥɸɛɨɣ ɦɨɦɟɧɬ ɜɪɟɦɟɧɢ ɤɨɧɬɪɨɥɢɪɭɟɬ ɫɨ7
ɞɟɪɠɚɧɢɟ ɨɤɧɚ ɫɨɡɞɚɜɚɟɦɨɣ ɩɪɨɝɪɚɦɦɵ ɢ ɦɨɠɟɬ ɜɧɟɫɬɢ ɜ ɧɟɝɨ ɧɟɨɛɯɨɞɢɦɵɟ ɢɡɦɟɧɟɧɢɹ. 1.3. Ɉɤɧɨ ɢɧɫɩɟɤɬɨɪɚ ɨɛɴɟɤɬɨɜ Ʌɸɛɨɣ ɪɚɡɦɟɳɚɟɦɵɣ ɧɚ ɮɨɪɦɟ ɤɨɦɩɨɧɟɧɬ ɯɚɪɚɤɬɟɪɢɡɭɟɬɫɹ ɧɟɤɨɬɨɪɵɦ ɧɚɛɨɪɨɦ ɩɚɪɚɦɟɬɪɨɜ: ɩɨɥɨɠɟɧɢɟɦ, ɪɚɡɦɟɪɨɦ, ɰɜɟɬɨɦ ɢ ɬ. ɞ. ɑɚɫɬɶ ɷɬɢɯ ɩɚɪɚɦɟɬɪɨɜ, ɧɚɩɪɢɦɟɪ, ɩɨɥɨɠɟɧɢɟ ɢ ɪɚɡɦɟɪɵ ɤɨɦɩɨɧɟɧɬɚ, ɩɪɨɝɪɚɦɦɢɫɬ ɦɨɠɟɬ ɢɡɦɟɧɹɬɶ, ɦɚɧɢɩɭɥɢɪɭɹ ɫ ɤɨɦɩɨɧɟɧɬɨɦ ɜ ɨɤɧɟ ɮɨɪɦɵ. Ⱦɥɹ ɢɡɦɟɧɟɧɢɹ ɞɪɭɝɢɯ ɩɚɪɚɦɟɬɪɨɜ ɩɪɟɞɧɚɡɧɚɱɟɧɨ ɨɤɧɨ ɂɧɫɩɟɤɬɨɪɚ ɨɛɴɟɤɬɨɜ (ɜɵɡɵɜɚɟɬɫɹ c ɩɨɦɨɳɶɸ ɤɥɚɜɢɲɢ F11). ɗɬɨ ɨɤɧɨ ɫɨɞɟɪɠɢɬ ɞɜɟ ɫɬɪɚɧɢɰɵ – Properties (ɋɜɨɣɫɬɜɚ) ɢ Events (ɋɨɛɵɬɢɹ). ɋɬɪɚɧɢɰɚ Properties ɫɥɭɠɢɬ ɞɥɹ ɭɫɬɚɧɨɜɤɢ ɧɭɠɧɵɯ ɫɜɨɣɫɬɜ ɤɨɦɩɨɧɟɧɬɚ, ɫɬɪɚɧɢɰɚ Events ɩɨɡɜɨɥɹɟɬ ɨɩɪɟɞɟɥɢɬɶ ɪɟɚɤɰɢɸ ɤɨɦɩɨɧɟɧɬɚ ɧɚ ɬɨ ɢɥɢ ɢɧɨɟ ɫɨɛɵɬɢɟ. ɋɨɜɨɤɭɩɧɨɫɬɶ ɫɜɨɣɫɬɜ ɨɬɨɛɪɚɠɚɟɬ ɜɢɞɢɦɭɸ ɫɬɨɪɨɧɭ ɤɨɦɩɨɧɟɧɬɚ: ɩɨɥɨɠɟɧɢɟ ɨɬɧɨɫɢɬɟɥɶɧɨ ɥɟɜɨɝɨ ɜɟɪɯɧɟɝɨ ɭɝɥɚ ɪɚɛɨɱɟɣ ɨɛɥɚɫɬɢ ɮɨɪɦɵ, ɟɝɨ ɪɚɡɦɟɪɵ ɢ ɰɜɟɬ, ɲɪɢɮɬ ɢ ɬɟɤɫɬ ɧɚɞɩɢɫɢ ɧɚ ɧɟɦ ɢ ɬ. ɩ.; ɫɨɜɨɤɭɩɧɨɫɬɶ ɫɨɛɵɬɢɣ – ɟɝɨ ɩɨɜɟɞɟɧɱɟɫɤɭɸ ɫɬɨɪɨɧɭ: ɛɭɞɟɬ ɥɢ ɤɨɦɩɨɧɟɧɬ ɪɟɚɝɢɪɨɜɚɬɶ ɧɚ ɳɟɥɱɨɤ ɦɵɲɢ ɢɥɢ ɧɚ ɧɚɠɚɬɢɟ ɤɥɚɜɢɲ, ɤɚɤ ɨɧ ɛɭɞɟɬ ɜɟɫɬɢ ɫɟɛɹ ɜ ɦɨɦɟɧɬ ɩɨɹɜɥɟɧɢɹ ɧɚ ɷɤɪɚɧɟ ɢɥɢ ɜ ɦɨɦɟɧɬ ɢɡɦɟɧɟɧɢɹ ɪɚɡɦɟɪɨɜ ɨɤɧɚ ɢ ɬ. ɩ. Ʉɚɠɞɚɹ ɫɬɪɚɧɢɰɚ ɨɤɧɚ ɂɧɫɩɟɤɬɨɪɚ ɨɛɴɟɤɬɨɜ ɩɪɟɞɫɬɚɜɥɹɟɬ ɫɨɛɨɣ ɞɜɭɯɤɨɥɨɧɱɚɬɭɸ ɬɚɛɥɢɰɭ, ɥɟɜɚɹ ɤɨɥɨɧɤɚ ɤɨɬɨɪɨɣ ɫɨɞɟɪɠɢɬ ɧɚɡɜɚɧɢɟ ɫɜɨɣɫɬɜɚ ɢɥɢ ɫɨɛɵɬɢɹ, ɚ ɩɪɚɜɚɹ – ɤɨɧɤɪɟɬɧɨɟ ɡɧɚɱɟɧɢɟ ɫɜɨɣɫɬɜɚ ɢɥɢ ɢɦɹ ɩɨɞɩɪɨɝɪɚɦɦɵ, ɨɛɪɚɛɚɬɵɜɚɸɳɟɣ ɫɨɨɬɜɟɬɫɬɜɭɸɳɟɟ ɫɨɛɵɬɢɟ. ɋɬɪɨɤɢ ɬɚɛɥɢɰɵ ɜɵɛɢɪɚɸɬɫɹ ɳɟɥɱɤɨɦ ɦɵɲɢ ɢ ɦɨɝɭɬ ɨɬɨɛɪɚɠɚɬɶ ɩɪɨɫɬɵɟ ɢɥɢ ɫɥɨɠɧɵɟ ɫɜɨɣɫɬɜɚ. Ʉ ɩɪɨɫɬɵɦ ɨɬɧɨɫɹɬɫɹ ɫɜɨɣɫɬɜɚ, ɨɩɪɟɞɟɥɹɟɦɵɟ ɟɞɢɧɫɬɜɟɧɧɵɦ ɡɧɚɱɟɧɢɟɦ – ɱɢɫɥɨɦ, ɫɬɪɨɤɨɣ ɫɢɦɜɨɥɨɜ, ɡɧɚɱɟɧɢɟɦ True (ɂɫɬɢɧɚ) ɢɥɢ False (Ʌɨɠɶ) ɢ ɬ. ɩ. ɇɚɩɪɢɦɟɪ, ɫɜɨɣɫɬɜɨ Caption (Ɂɚɝɨɥɨɜɨɤ) ɩɪɟɞɫɬɚɜɥɹɟɬɫɹ ɫɬɪɨɤɨɣ ɫɢɦɜɨɥɨɜ, ɫɜɨɣɫɬɜɚ Height (ȼɵɫɨɬɚ) ɢ Width (ɒɢɪɢɧɚ) – ɱɢɫɥɚɦɢ, ɫɜɨɣɫɬɜɨ Enabled (Ⱦɨɫɬɭɩɧɨɫɬɶ) – ɡɧɚɱɟɧɢɹɦɢ True ɢɥɢ False. ɋɥɨɠɧɵɟ ɫɜɨɣɫɬɜɚ ɨɩɪɟɞɟɥɹɸɬɫɹ ɫɨɜɨɤɭɩɧɨɫɬɶɸ ɡɧɚɱɟɧɢɣ. ɋɥɟɜɚ ɨɬ ɢɦɟɧɢ ɬɚɤɢɯ ɫɜɨɣɫɬɜ ɭɤɚɡɵɜɚɟɬɫɹ ɡɧɚɱɨɤ «+», ɚ ɳɟɥɱɨɤ ɦɵɲɶɸ ɩɨ ɷɬɨɦɭ ɫɢɦɜɨɥɭ ɩɪɢɜɨɞɢɬ ɤ ɪɚɫɤɪɵɬɢɸ ɫɩɢɫɤɚ ɫɨɫɬɚɜɥɹɸɳɢɯ ɫɥɨɠɧɨɝɨ ɫɜɨɣɫɬɜɚ. ɑɬɨɛɵ ɡɚɤɪɵɬɶ ɪɚɫɤɪɵɬɵɣ ɫɩɢɫɨɤ, ɧɭɠɧɨ ɳɟɥɤɧɭɬɶ ɩɨ ɡɧɚɱɤɭ «–» ɫɥɨɠɧɨɝɨ ɫɜɨɣɫɬɜɚ. ɓɟɥɱɨɤ ɦɵɲɶɸ ɧɚ ɩɪɚɜɨɣ ɤɨɥɨɧɤɟ ɫɬɪɨɤɢ ɬɚɛɥɢɰɵ ɚɤɬɢɜɢɡɢɪɭɟɬ ɭɤɚɡɚɧɧɨɟ ɜ ɧɟɣ ɡɧɚɱɟɧɢɟ ɫɜɨɣɫɬɜɚ, ɩɪɢ ɷɬɨɦ ɜ ɩɪɚɜɨɦ ɤɨɧɰɟ ɫɬɪɨɤɢ ɦɨɠɟɬ ɩɨɹɜɢɬɶɫɹ ɤɧɨɩɤɚ ɢɥɢ . ɓɟɥɱɨɤ ɩɨ ɤɧɨɩɤɟ ɩɪɢɜɨɞɢɬ ɤ ɩɨɹɜɥɟɧɢɸ ɧɚ ɷɤɪɚɧɟ ɞɢɚɥɨɝɨɜɨɝɨ ɨɤɧɚ, ɫ ɩɨɦɨɳɶɸ ɤɨɬɨɪɨɝɨ ɭɫɬɚɧɚɜɥɢɜɚɟɬɫɹ ɡɧɚɱɟɧɢɟ ɫɥɨɠɧɨɝɨ ɫɜɨɣɫɬɜɚ. ɓɟɥɱɨɤ ɩɨ ɤɧɨɩɤɟ ɩɨɡɜɨɥɹɟɬ ɜɵɛɪɚɬɶ ɢɡ ɪɚɫɤɪɵɜɚɸɳɟɝɨɫɹ ɫɩɢɫɤɚ ɨɞɧɨ ɢɡ ɜɨɡɦɨɠɧɵɯ ɡɧɚɱɟɧɢɣ ɫɜɨɣɫɬɜɚ. ȼ ɜɟɪɯɧɟɣ ɱɚɫɬɢ ɨɤɧɚ ɂɧɫɩɟɤɬɨɪɚ ɨɛɴɟɤɬɨɜ ɪɚɫɩɨɥɚɝɚɟɬɫɹ ɪɚɫɤɪɵɜɚɸɳɢɣɫɹ ɫɩɢɫɨɤ ɜɫɟɯ ɩɨɦɟɳɟɧɧɵɯ ɧɚ ɮɨɪɦɭ ɤɨɦɩɨɧɟɧɬɨɜ. ɉɨɫɤɨɥɶɤɭ ɮɨɪɦɚ ɫɚɦɚ ɩɨ ɫɟɛɟ ɹɜɥɹɟɬɫɹ ɤɨɦɩɨɧɟɧɬɨɦ, ɟɟ ɢɦɹ ɬɚɤɠɟ ɩɪɢɫɭɬɫɬɜɭɟɬ ɜ 8
ɷɬɨɦ ɫɩɢɫɤɟ. ȼ ɨɬɥɢɱɢɟ ɨɬ ɩɪɟɞɵɞɭɳɢɯ ɜɟɪɫɢɣ ɪɚɫɤɪɵɜɚɸɳɢɣɫɹ ɫɩɢɫɨɤ ɫɨɞɟɪɠɢɬ ɧɟ ɬɨɥɶɤɨ ɢɦɟɧɚ ɤɨɦɩɨɧɟɧɬɨɜ, ɧɨ ɢ ɢɯ ɤɥɚɫɫɵ. 1.4. Ɉɤɧɨ ɞɟɪɟɜɚ ɨɛɴɟɤɬɨɜ ɗɬɨ ɨɤɧɨ ɩɨɹɜɢɥɨɫɶ ɜ ɜɟɪɫɢɢ 6 ɢ ɩɪɟɞɧɚɡɧɚɱɟɧɨ ɞɥɹ ɧɚɝɥɹɞɧɨɝɨ ɨɬɨɛɪɚɠɟɧɢɹ ɫɜɹɡɟɣ ɦɟɠɞɭ ɨɬɞɟɥɶɧɵɦɢ ɤɨɦɩɨɧɟɧɬɚɦɢ, ɪɚɡɦɟɳɟɧɧɵɦɢ ɧɚ ɚɤɬɢɜɧɨɣ ɮɨɪɦɟ ɢɥɢ ɜ ɚɤɬɢɜɧɨɦ ɦɨɞɭɥɟ ɞɚɧɧɵɯ. ɓɟɥɱɨɤ ɩɨ ɥɸɛɨɦɭ ɤɨɦɩɨɧɟɧɬɭ ɜ ɷɬɨɦ ɨɤɧɟ ɚɤɬɢɜɢɡɢɪɭɟɬ ɫɨɨɬɜɟɬɫɬɜɭɸɳɢɣ ɤɨɦɩɨɧɟɧɬ ɜ ɨɤɧɟ ɮɨɪɦɵ ɢ ɨɬɨɛɪɚɠɚɟɬ ɫɜɨɣɫɬɜɚ ɷɬɨɝɨ ɤɨɦɩɨɧɟɧɬɚ ɜ ɨɤɧɟ ɂɧɫɩɟɤɬɨɪɚ ɨɛɴɟɤɬɨɜ. Ⱦɜɨɣɧɨɣ ɳɟɥɱɨɤ ɩɪɢɜɨɞɢɬ ɤ ɫɪɚɛɚɬɵɜɚɧɢɸ ɦɟɯɚɧɢɡɦɚ Code Insight, ɤɨɬɨɪɵɣ ɜɫɬɚɜɥɹɟɬ ɜ ɨɤɧɨ ɤɨɞɚ ɡɚɝɨɬɨɜɤɭ ɞɥɹ ɨɛɪɚɛɨɬɱɢɤɚ ɫɨɛɵɬɢɹ OnClick. ɇɚɤɨɧɟɰ, ɤɨɦɩɨɧɟɧɬ ɦɨɠɧɨ «ɩɟɪɟɬɚɳɢɬɶ» ɜ ɨɤɧɟ ɢ ɬɚɤɢɦ ɨɛɪɚɡɨɦ ɩɨɦɟɧɹɬɶ ɟɝɨ ɜɥɚɞɟɥɶɰɚ (ɫɜɨɣɫɬɜɨ parent). ȼ ɩɪɟɞɵɞɭɳɢɯ ɜɟɪɫɢɹɯ ɬɚɤɭɸ ɡɚɦɟɧɭ ɦɨɠɧɨ ɛɵɥɨ ɫɞɟɥɚɬɶ ɬɨɥɶɤɨ ɫ ɩɨɦɨɳɶɸ ɦɟɠɩɪɨɝɪɚɦɦɧɨɝɨ ɛɭɮɟɪɚ ɨɛɦɟɧɚ Clipboard. 1.5. Ɉɤɧɨ ɤɨɞɚ ɩɪɨɝɪɚɦɦɵ Ɉɤɧɨ ɤɨɞɚ ɩɪɟɞɧɚɡɧɚɱɟɧɨ ɞɥɹ ɫɨɡɞɚɧɢɹ ɢ ɪɟɞɚɤɬɢɪɨɜɚɧɢɹ ɬɟɤɫɬɚ ɩɪɨɝɪɚɦɦɵ. ɗɬɨɬ ɬɟɤɫɬ ɫɨɫɬɚɜɥɹɟɬɫɹ ɩɨ ɫɩɟɰɢɚɥɶɧɵɦ ɩɪɚɜɢɥɚɦ ɢ ɨɩɢɫɵɜɚɟɬ ɚɥɝɨɪɢɬɦ ɪɚɛɨɬɵ ɩɪɨɝɪɚɦɦɵ. ɋɨɜɨɤɭɩɧɨɫɬɶ ɩɪɚɜɢɥ ɡɚɩɢɫɢ ɬɟɤɫɬɚ ɧɚɡɵɜɚɟɬɫɹ ɹɡɵɤɨɦ ɩɪɨɝɪɚɦɦɢɪɨɜɚɧɢɹ. ȼ ɫɢɫɬɟɦɟ Delphi ɢɫɩɨɥɶɡɭɟɬɫɹ ɹɡɵɤ ɩɪɨɝɪɚɦɦɢɪɨɜɚɧɢɹ Object Pascal, ɤɨɬɨɪɵɣ ɩɪɟɞɫɬɚɜɥɹɟɬ ɫɨɛɨɣ ɪɚɫɲɢɪɟɧɧɭɸ ɢ ɭɫɨɜɟɪɲɟɧɫɬɜɨɜɚɧɧɭɸ ɜɟɪɫɢɸ ɲɢɪɨɤɨ ɪɚɫɩɪɨɫɬɪɚɧɟɧɧɨɝɨ ɹɡɵɤɚ ɉɚɫɤɚɥɶ, ɜɩɟɪɜɵɟ ɩɪɟɞɥɨɠɟɧɧɨɝɨ ɲɜɟɣɰɚɪɫɤɢɦ ɭɱɟɧɵɦ ɇ. ȼɢɪɬɨɦ ɟɳɟ ɜ 1970 ɝ. ɢ ɭɫɨɜɟɪɲɟɧɫɬɜɨɜɚɧɧɨɝɨ ɫɨɬɪɭɞɧɢɤɚɦɢ ɤɨɪɩɨɪɚɰɢɢ Borland (ɫɨɡɞɚɧɧɵɟ ɢɦɢ ɹɡɵɤɢ ɧɚɡɵɜɚɥɢɫɶ Turbo Pascal, Borland Pascal ɢ Object Pascal). ɇɟɫɦɨɬɪɹ ɧɚ ɬɨ, ɱɬɨ ɜɢɡɭɚɥɶɧɚɹ ɫɪɟɞɚ Delphi ɛɟɪɟɬ ɧɚ ɫɟɛɹ ɦɧɨɝɢɟ ɪɭɬɢɧɧɵɟ ɚɫɩɟɤɬɵ ɩɪɨɝɪɚɦɦɢɪɨɜɚɧɢɹ, ɡɧɚɧɢɟ ɹɡɵɤɚ Object Pascal ɹɜɥɹɟɬɫɹ ɧɟɩɪɟɦɟɧɧɵɦ ɭɫɥɨɜɢɟɦ ɞɥɹ ɥɸɛɨɝɨ ɩɪɨɝɪɚɦɦɢɫɬɚ, ɪɚɛɨɬɚɸɳɟɝɨ ɜ ɷɬɨɣ ɫɪɟɞɟ. ɉɪɨɝɪɚɦɦɚ ɜ ɫɪɟɞɟ Delphi ɫɨɫɬɚɜɥɹɟɬɫɹ ɤɚɤ ɨɩɢɫɚɧɢɟ ɚɥɝɨɪɢɬɦɨɜ, ɤɨɬɨɪɵɟ ɧɟɨɛɯɨɞɢɦɨ ɜɵɩɨɥɧɢɬɶ, ɟɫɥɢ ɜɨɡɧɢɤɚɟɬ ɨɩɪɟɞɟɥɟɧɧɨɟ ɫɨɛɵɬɢɟ, ɫɜɹɡɚɧɧɨɟ ɫ ɮɨɪɦɨɣ (ɧɚɩɪɢɦɟɪ, ɳɟɥɱɨɤ ɦɵɲɢ ɧɚ ɤɧɨɩɤɟ – ɫɨɛɵɬɢɟ OnClick, ɫɨɡɞɚɧɢɟ ɮɨɪɦɵ – OnCreate). Ⱦɥɹ ɤɚɠɞɨɝɨ ɨɛɪɚɛɚɬɵɜɚɟɦɨɝɨ ɜ ɮɨɪɦɟ ɫɨɛɵɬɢɹ, ɫ ɩɨɦɨɳɶɸ ɫɬɪɚɧɢɰɵ Events ɢɧɫɩɟɤɬɨɪɚ ɨɛɴɟɤɬɨɜ ɜ ɬɟɤɫɬɟ ɩɪɨɝɪɚɦɦɵ ɨɪɝɚɧɢɡɭɟɬɫɹ ɩɪɨɰɟɞɭɪɚ (procedure), ɦɟɠɞɭ ɤɥɸɱɟɜɵɦɢ ɫɥɨɜɚɦɢ begin ɢ end ɤɨɬɨɪɨɣ ɩɪɨɝɪɚɦɦɢɫɬ ɡɚɩɢɫɵɜɚɟɬ ɧɚ ɹɡɵɤɟ Object Pascal ɬɪɟɛɭɟɦɵɣ ɚɥɝɨɪɢɬɦ. ɉɟɪɟɤɥɸɱɟɧɢɟ ɦɟɠɞɭ ɨɤɧɨɦ ɮɨɪɦɵ ɢ ɨɤɧɨɦ ɬɟɤɫɬɚ ɩɪɨɝɪɚɦɦɵ ɨɫɭɳɟɫɬɜɥɹɟɬɫɹ ɫ ɩɨɦɨɳɶɸ ɤɥɚɜɢɲɢ F12. ɉɟɪɜɨɧɚɱɚɥɶɧɨ ɨɤɧɨ ɤɨɞɚ ɫɨɞɟɪɠɢɬ ɦɢɧɢɦɚɥɶɧɵɣ ɢɫɯɨɞɧɵɣ ɬɟɤɫɬ, ɨɛɟɫɩɟɱɢɜɚɸɳɢɣ ɧɨɪɦɚɥɶɧɨɟ ɮɭɧɤɰɢɨɧɢɪɨɜɚɧɢɟ ɩɭɫɬɨɣ ɮɨɪɦɵ ɜ ɤɚɱɟɫɬɜɟ ɩɨɥɧɨɰɟɧɧɨɝɨ Windows-ɨɤɧɚ. ȼ ɯɨɞɟ ɪɚɛɨɬɵ ɧɚɞ ɩɪɨɟɤɬɨɦ ɩɪɨɝɪɚɦɦɢɫɬ 9
ɜɧɨɫɢɬ ɜ ɧɟɝɨ ɧɟɨɛɯɨɞɢɦɵɟ ɞɨɩɨɥɧɟɧɢɹ, ɱɬɨɛɵ ɩɪɢɞɚɬɶ ɩɪɨɝɪɚɦɦɟ ɧɭɠɧɭɸ ɮɭɧɤɰɢɨɧɚɥɶɧɨɫɬɶ. ɉɨɫɤɨɥɶɤɭ ɞɥɹ ɫɨɡɞɚɧɢɹ ɞɚɠɟ ɩɪɨɫɬɵɯ ɩɪɨɝɪɚɦɦ ɜɚɦ ɩɨɧɚɞɨɛɢɬɫɹ ɫɨɡɞɚɜɚɬɶ ɢ ɢɡɦɟɧɹɬɶ (ɪɟɞɚɤɬɢɪɨɜɚɬɶ) ɤɨɞ ɩɪɨɝɪɚɦɦɵ, ɧɢɠɟ ɨɩɢɫɵɜɚɸɬɫɹ ɨɫɧɨɜɧɵɟ ɩɪɢɟɦɵ ɪɚɛɨɬɵ ɫ ɨɤɧɨɦ ɤɨɞɚ. ɋɪɚɡɭ ɩɨɫɥɟ ɨɬɤɪɵɬɢɹ ɧɨɜɨɝɨ ɩɪɨɟɤɬɚ ɜ ɧɟɦ ɛɭɞɭɬ ɬɚɤɢɟ ɫɬɪɨɤɢ: unit Unit1; interface uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Frms, Dialogs; type TFormI = class(TForm) private { Private declarations } public { Public declarations } end; var Form1: TForm1; implementation {SR *.DFM} end. ɗɬɢ ɫɬɪɨɤɢ Delphi ɚɜɬɨɦɚɬɢɱɟɫɤɢ ɜɫɬɚɜɥɹɟɬ ɜ ɨɤɧɨ ɤɨɞɚ ɞɥɹ ɧɨɜɨɣ ɮɨɪɦɵ. Ʉɚɤ ɭɠɟ ɝɨɜɨɪɢɥɨɫɶ, ɨɤɧɨ ɤɨɞɚ ɨɩɪɟɞɟɥɹɟɬ ɩɨɜɟɞɟɧɱɟɫɤɭɸ ɫɬɨɪɨɧɭ ɩɪɨɝɪɚɦɦɵ (ɬ. ɟ. ɨɤɧɚ, ɩɨɹɜɥɹɸɳɟɝɨɫɹ ɩɨɫɥɟ ɧɚɱɚɥɚ ɪɚɛɨɬɵ ɩɪɨɝɪɚɦɦɵ), ɚ ɨɤɧɨ ɮɨɪɦɵ – ɟɝɨ ɜɧɟɲɧɢɣ ɜɢɞ. Ɉɛɚ ɨɤɧɚ ɬɟɫɧɨ ɫɜɹɡɚɧɵ ɞɪɭɝ ɫ ɞɪɭɝɨɦ, ɩɪɢɱɟɦ Delphi «ɯɨɡɹɣɧɢɱɚɟɬ» ɜ ɟɝɨ ɜɟɪɯɧɟɣ ɱɚɫɬɢ, ɜɫɬɚɜɥɹɹ ɧɟɨɛɯɨɞɢɦɵɟ ɫɬɪɨɤɢ ɦɟɠɞɭ unit Unit1 ɢ implementation. ɉɨɤɚ ɧɟ ɫɬɨɢɬ ɢɡɦɟɧɹɬɶ ɷɬɭ ɱɚɫɬɶ ɬɟɤɫɬɚ. ȼ ɞɚɥɶɧɟɣɲɟɦ ɦɵ ɛɭɞɟɦ ɜɫɬɚɜɥɹɬɶ ɜ ɨɤɧɨ ɤɨɞɚ ɬɟɤɫɬ ɩɪɨɝɪɚɦɦɵ ɦɟɠɞɭ ɫɬɪɨɤɚɦɢ {$R *.DFM} ɢ end ɜ ɧɢɠɧɟɣ ɱɚɫɬɢ ɨɤɧɚ. ɑɬɨɛɵ ɜɫɬɚɜɢɬɶ ɜ ɨɤɧɨ ɤɨɞɚ ɧɨɜɭɸ ɫɬɪɨɤɭ (ɫɬɪɨɤɢ), ɧɭɠɧɨ ɫɧɚɱɚɥɚ ɫ ɩɨɦɨɳɶɸ ɤɥɚɜɢɲ ɭɩɪɚɜɥɟɧɢɹ ɤɭɪɫɨɪɨɦ ɢɥɢ ɳɟɥɱɤɨɦ ɩɨ ɨɤɧɭ ɥɟɜɨɣ ɤɥɚɜɢɲɢ ɦɵɲɢ ɩɨɫɬɚɜɢɬɶ ɤɭɪɫɨɪ ɬɟɤɫɬɚ (ɦɢɝɚɸɳɭɸ ɜɟɪɬɢɤɚɥɶɧɭɸ ɱɟɪɬɭ) ɧɚ ɧɭɠɧɨɟ ɦɟɫɬɨ, ɚ ɡɚɬɟɦ ɫ ɩɨɦɨɳɶɸ ɤɥɚɜɢɚɬɭɪɵ ɜɜɟɫɬɢ ɬɟɤɫɬ. Ɉɛɵɱɧɨ ɬɟɤɫɬ ɤɨɞɚ ɩɪɨɝɪɚɦɦɵ ɪɚɫɩɨɥɚɝɚɟɬɫɹ ɜ ɧɟɫɤɨɥɶɤɢɯ ɫɬɪɨɤɚɯ. Ⱦɥɹ ɩɟɪɟɯɨɞɚ ɧɚ ɧɨɜɭɸ ɫɬɪɨɤɭ ɢɫɩɨɥɶɡɭɟɬɫɹ ɤɥɚɜɢɲɚ Enter. ȿɫɥɢ ɜ ɩɪɨɰɟɫɫɟ ɜɜɨɞɚ ɞɨɩɭɳɟɧɚ ɨɲɢɛɤɚ ɢ ɨɧɚ ɛɵɥɚ ɫɪɚɡɭ ɡɚɦɟɱɟɧɚ, ɭɞɚɥɢɬɶ ɨɲɢɛɨɱɧɵɣ ɫɢɦɜɨɥ ɦɨɠɧɨ ɤɥɚɜɢɲɟɣ Backspace (ɤɥɚɜɢɲɚ ɜ ɩɪɚɜɨɦ ɜɟɪɯɧɟɦ ɭɝɥɭ ɚɥɮɚɜɢɬɧɨɰɢɮɪɨɜɵɯ ɨɛɥɚɫɬɢ ɤɥɚɜɢɚɬɭɪɵ ɢɥɢ ɤɥɚɜɢɲɚ ɫ «ɥɟɜɨɣ» ɫɬɪɟɥɤɨɣ). Ʉɥɚɜɢɲɚ Backspace ɭɞɚɥɹɟɬ ɫɢɦɜɨɥ ɫɥɟɜɚ ɨɬ ɦɢɝɚɸɳɟɝɨ ɭɤɚɡɚɬɟɥɹ, ɚ ɤɥɚɜɢɲɚ Delete – ɫɩɪɚɜɚ ɨɬ ɧɟɝɨ. ȿɫɥɢ ɩɨɧɚɞɨɛɢɬɫɹ ɭɞɚɥɢɬɶ ɫɪɚɡɭ ɜɫɸ ɫɬɪɨɤɭ ɬɟɤɫɬɚ, ɩɨɫɬɚɜɶɬɟ ɜ ɥɸɛɨɟ ɦɟɫɬɨ ɫɬɪɨɤɢ ɦɢɝɚɸɳɢɣ ɭɤɚɡɚɬɟɥɶ, ɧɚɠɦɢɬɟ ɤɥɚɜɢɲɭ Ctrl ɢ, ɧɟ ɨɬɩɭɫɤɚɹ ɟɟ, ɤɥɚɜɢɲɭ ɫ ɥɚɬɢɧɫɤɨɣ ɛɭɤɜɨɣ Y. Ɍɚɤɨɟ ɫɨɜɦɟ10
ɫɬɧɨɟ ɧɚɠɚɬɢɟ ɤɥɚɜɢɲ ɜ ɞɚɥɶɧɟɣɲɟɦ ɛɭɞɟɦ ɨɛɨɡɧɚɱɚɬɶ ɫɨɜɦɟɫɬɧɨ ɫ ɫɢɦɜɨɥɨɦ «+»: Ctrl+Y. ɑɬɨɛɵ ɨɬɦɟɧɢɬɶ ɩɨɫɥɟɞɧɟɟ ɢɡɦɟɧɟɧɢɟ ɬɟɤɫɬɚ, ɧɚɠɦɢɬɟ Ctrl+Z ɢɥɢ ɜɵɛɟɪɢɬɟ ɉɭɧɤɬ ɦɟɧɸ Edit | Undo. 1.6. Ɉɤɧɨ ɧɚɜɢɝɚɬɨɪɚ ȼɦɟɫɬɟ ɫ ɨɤɧɨɦ ɤɨɞɚ ɨɛɵɱɧɨ ɚɤɬɢɜɢɡɢɪɭɟɬɫɹ ɨɤɧɨ ɧɚɜɢɝɚɬɨɪɚ ɢɥɢ ɛɪɚɭɡɟɪɚ ɤɨɞɚ ɩɪɨɝɪɚɦɦɵ Code Explorer, ɨɛɥɟɝɱɚɸɳɟɟ ɩɨɢɫɤ ɧɭɠɧɵɯ ɷɥɟɦɟɧɬɨɜ ɜ ɫɥɭɱɚɟ, ɤɨɝɞɚ ɜ ɨɤɧɟ ɧɚɛɪɚɧɨ ɦɧɨɝɨ ɫɬɪɨɤ ɬɟɤɫɬɚ (ɪɢɫ. 1.1). Ⱦɜɨɣɧɨɣ ɳɟɥɱɨɤ ɦɵɲɶɸ ɧɚ ɷɥɟɦɟɧɬɟ ɜ ɨɤɧɟ ɛɪɚɭɡɟɪɚ ɩɪɢɜɨɞɢɬ ɤ ɩɨɡɢɰɢɨɧɢɪɨɜɚɧɢɸ ɬɟɤɫɬɨɜɨɝɨ ɭɤɚɡɚɬɟɥɹ ɜ ɨɤɧɟ ɤɨɞɚ ɧɚ ɨɩɢɫɚɧɢɟ ɫɨɨɬɜɟɬɫɬɜɭɸɳɟɝɨ ɨɛɴɟɤɬɚ ɢɥɢ ɟɝɨ ɩɟɪɜɨɟ ɭɩɨɦɢɧɚɧɢɟ. ɉɪɢ ɪɚɡɪɚɛɨɬɤɟ ɧɟɫɥɨɠɧɵɯ ɭɱɟɛɧɵɯ ɩɪɨɝɪɚɦɦ ɦɨɠɧɨ ɡɚɤɪɵɬɶ ɨɤɧɨ ɧɚɜɢɝɚɬɨɪɚ ɦɚɥɟɧɶɤɨɣ ɤɧɨɩɤɨɣ ɜ ɟɝɨ ɜɟɪɯɧɟɦ ɩɪɚɜɨɦ ɭɝɥɭ. ȼɨɫɫɬɚɧɨɜɢɬɶ ɡɚɤɪɵɬɨɟ ɨɤɧɨ ɦɨɠɧɨ ɩɨɫɥɟ ɳɟɥɱɤɚ ɩɪɚɜɨɣ ɤɧɨɩɤɨɣ ɦɵɲɢ ɩɨ ɨɤɧɭ ɤɨɞɚ ɢ ɜɵɛɨɪɚ ɨɩɰɢɢ view Explorer. Ɂɚɦɟɬɢɦ, ɱɬɨ ɨɤɧɨ ɛɪɚɭɡɟɪɚ ɪɚɫɩɨɥɚɝɚɟɬɫɹ ɧɚ ɜɫɩɨɦɨɝɚɬɟɥɶɧɨɣ ɩɚɧɟɥɢ ɢ ɢɦɟɟɬ ɭɩɪɚɜɥɹɸɳɭɸ ɩɨɥɨɫɭ ɜ ɜɟɪɯɧɟɣ ɱɚɫɬɢ ɪɚɦɤɢ. «ɋɯɜɚɬɢɜ» ɟɟ ɦɵɲɶɸ, ɦɨɠɧɨ ɩɟɪɟɬɚɳɢɬɶ ɨɤɧɨ ɧɚ ɥɸɛɨɟ ɫɜɨɛɨɞɧɨɟ ɦɟɫɬɨ ɷɤɪɚɧɚ ɢɥɢ «ɩɪɢɱɚɥɢɬɶ» ɟɝɨ ɤ ɨɤɧɭ ɂɧɫɩɟɤɬɨɪɚ ɨɛɴɟɤɬɨɜ. 2. ɋɌɊɍɄɌɍɊȺ ɉɊɈȽɊȺɆɆ DELPHI ɉɪɨɝɪɚɦɦɚ ɜ Delphi ɫɨɫɬɨɢɬ ɢɡ ɮɚɣɥɚ ɩɪɨɟɤɬɚ (ɮɚɣɥ ɫ ɪɚɫɲɢɪɟɧɢɟɦ .dpr), ɨɞɧɨɝɨ ɢɥɢ ɧɟɫɤɨɥɶɤɢɯ ɮɚɣɥɨɜ ɫ ɬɟɤɫɬɨɦ ɢɫɯɨɞɧɨɝɨ ɩɪɨɝɪɚɦɦɧɨɝɨ ɤɨɞɚ (ɫ ɪɚɫɲɢɪɟɧɢɟɦ .pas), ɮɚɣɥɨɜ ɫ ɨɩɢɫɚɧɢɟɦ ɨɤɨɧ ɮɨɪɦɵ (ɫ ɪɚɫɲɢɪɟɧɢɟɦ .dfm). ȼ ɮɚɣɥɟ ɩɪɨɟɤɬɚ ɧɚɯɨɞɢɬɫɹ ɢɧɮɨɪɦɚɰɢɹ ɨ ɦɨɞɭɥɹɯ, ɫɨɫɬɚɜɥɹɸɳɢɯ ɞɚɧɧɵɣ ɩɪɨɟɤɬ. Ɏɚɣɥ ɩɪɨɟɤɬɚ ɚɜɬɨɦɚɬɢɱɟɫɤɢ ɫɨɡɞɚɟɬɫɹ ɢ ɪɟɞɚɤɬɢɪɭɟɬɫɹ ɫɪɟɞɨɣ Delphi ɢ ɧɟ ɩɪɟɞɧɚɡɧɚɱɟɧ ɞɥɹ ɪɟɞɚɤɬɢɪɨɜɚɧɢɹ ɟɝɨ ɩɨɥɶɡɨɜɚɬɟɥɟɦɩɪɨɝɪɚɦɦɢɫɬɨɦ. Ɏɚɣɥ ɢɫɯɨɞɧɨɝɨ ɬɟɤɫɬɚ – ɩɪɨɝɪɚɦɦɧɵɣ ɦɨɞɭɥɶ (Unit) ɩɪɟɞɧɚɡɧɚɱɟɧ ɞɥɹ ɪɚɡɦɟɳɟɧɢɹ ɬɟɤɫɬɨɜ ɩɪɨɝɪɚɦɦ. ȼ ɷɬɨɦ ɮɚɣɥɟ ɩɪɨɝɪɚɦɦɢɫɬ ɪɚɡɦɟɳɚɟɬ ɬɟɤɫɬ ɩɪɨɝɪɚɦɦɵ, ɧɚɩɢɫɚɧɧɵɣ ɧɚ ɹɡɵɤɟ Object Pascal. Ɇɨɞɭɥɶ ɢɦɟɟɬ ɫɥɟɞɭɸɳɭɸ ɫɬɪɭɤɬɭɪɭ: unit Unit1; // ɡɚɝɨɥɨɜɨɤ ɦɨɞɭɥɹ interface // Ɋɚɡɞɟɥ ɢɧɬɟɪɮɟɣɫɚ implementation // Ɋɚɡɞɟɥ ɪɟɚɥɢɡɚɰɢɢ initialization // Ɋɚɡɞɟɥ ɢɧɢɰɢɚɥɢɡɚɰɢɢ finalization // Ɋɚɡɞɟɥ ɡɚɜɟɪɲɟɧɢɹ end. 11
Ɂɚɝɨɥɨɜɨɤ ɦɨɞɭɥɹ ɫɨɫɬɨɢɬ ɢɡ ɫɥɭɠɟɛɧɨɝɨ ɫɥɨɜɚ unit ɢ ɢɦɟɧɢ ɦɨɞɭɥɹ, ɤɨɬɨɪɨɟ ɨɛɹɡɚɬɟɥɶɧɨ ɞɨɥɠɧɨ ɫɨɜɩɚɞɚɬɶ ɫ ɢɦɟɧɟɦ ɮɚɣɥɚ. ȼ ɨɬɥɢɱɢɟ ɨɬ ɡɚɝɨɥɨɜɤɚ ɩɪɨɝɪɚɦɦɵ, ɡɚɝɨɥɨɜɨɤ ɦɨɞɭɥɹ ɹɜɥɹɟɬɫɹ ɨɛɹɡɚɬɟɥɶɧɵɦ. Ɋɚɡɞɟɥ ɢɧɬɟɪɮɟɣɫɚ ɫɨɞɟɪɠɢɬ ɨɩɢɫɚɧɢɟ ɤɨɧɫɬɚɧɬ, ɬɢɩɨɜ, ɩɟɪɟɦɟɧɧɵɯ, ɩɪɨɰɟɞɭɪ ɢ ɮɭɧɤɰɢɣ, ɤɨɬɨɪɵɟ ɛɭɞɭɬ ɞɨɫɬɭɩɧɵ ɜ ɞɪɭɝɢɯ ɩɪɨɝɪɚɦɦɚɯ ɢ ɦɨɞɭɥɹɯ. ɂɧɬɟɪɮɟɣɫɧɚɹ ɱɚɫɬɶ ɧɚɱɢɧɚɟɬɫɹ ɫ ɡɚɪɟɡɟɪɜɢɪɨɜɚɧɧɨɝɨ ɫɥɨɜɚ interface ɢ ɜɫɟɝɞɚ ɞɨɥɠɧɚ ɫɥɟɞɨɜɚɬɶ ɫɪɚɡɭ ɡɚ ɡɚɝɨɥɨɜɤɨɦ. Ɋɚɡɞɟɥ ɢɧɬɟɪɮɟɣɫɚ ɦɨɠɟɬ ɫɨɞɟɪɠɚɬɶ ɨɛɴɹɜɥɟɧɢɟ uses, ɤɨɬɨɪɨɟ ɞɨɥɠɧɨ ɛɵɬɶ ɡɚɩɢɫɚɧɨ ɜ ɩɟɪɜɭɸ ɨɱɟɪɟɞɶ, ɞɨ ɜɫɟɯ ɞɪɭɝɢɯ ɨɛɴɹɜɥɟɧɢɣ. ȼ ɪɚɡɞɟɥɟ ɢɧɬɟɪɮɟɣɫɚ ɨɛɴɹɜɥɹɸɬɫɹ ɬɨɥɶɤɨ ɡɚɝɨɥɨɜɤɢ ɩɪɨɰɟɞɭɪ ɢ ɮɭɧɤɰɢɣ. ɂɯ ɨɩɢɫɚɧɢɟ ɞɚɟɬɫɹ ɜ ɪɚɡɞɟɥɟ ɪɟɚɥɢɡɚɰɢɢ. Ɋɚɡɞɟɥ ɪɟɚɥɢɡɚɰɢɢ ɧɚɱɢɧɚɟɬɫɹ ɫ ɡɚɪɟɡɟɪɜɢɪɨɜɚɧɧɨɝɨ ɫɥɨɜɚ implementation ɢ ɦɨɠɟɬ ɫɨɞɟɪɠɚɬɶ ɨɛɴɹɜɥɟɧɢɹ ɤɨɧɫɬɚɧɬ, ɩɟɪɟɦɟɧɧɵɯ, ɚ ɬɚɤɠɟ ɨɩɢɫɚɧɢɹ ɬɢɩɨɜ, ɩɪɨɰɟɞɭɪ ɢ ɮɭɧɤɰɢɣ, ɨɛɴɟɤɬɨɜ ɢɥɢ ɤɥɚɫɫɨɜ. ȼɫɟ ɷɬɢ ɨɛɴɹɜɥɟɧɢɹ ɞɟɣɫɬɜɢɬɟɥɶɧɵ ɬɨɥɶɤɨ ɞɥɹ ɞɚɧɧɨɝɨ ɦɨɞɭɥɹ. Ʉɪɨɦɟ ɬɨɝɨ, ɜ ɪɚɡɞɟɥɟ implementation ɪɚɡɦɟɳɚɟɬɫɹ ɪɟɚɥɢɡɚɰɢɹ ɜɫɟɯ ɩɪɨɰɟɞɭɪ ɢ ɮɭɧɤɰɢɣ, ɡɚɝɨɥɨɜɤɢ ɤɨɬɨɪɵɯ ɨɛɴɹɜɥɟɧɵ ɜ ɪɚɡɞɟɥɟ ɢɧɬɟɪɮɟɣɫɚ. ȼɫɟ ɢɞɟɧɬɢɮɢɤɚɬɨɪɵ, ɨɛɴɹɜɥɟɧɧɵɟ ɜ ɪɚɡɞɟɥɟ interface, ɞɨɫɬɭɩɧɵ ɬɚɤɠɟ ɜ ɪɚɡɞɟɥɟ ɪɟɚɥɢɡɚɰɢɢ. Ɋɚɡɞɟɥ ɪɟɚɥɢɡɚɰɢɢ ɦɨɠɟɬ ɫɨɞɟɪɠɚɬɶ ɩɪɟɞɥɨɠɟɧɢɟ uses, ɤɨɬɨɪɨɟ ɞɨɥɠɧɨ ɫɥɟɞɨɜɚɬɶ ɫɪɚɡɭ ɡɚ ɫɥɨɜɨɦ implementation, ɩɪɢɱɟɦ ɢɫɩɨɥɶɡɭɟɦɵɟ ɦɨɞɭɥɢ ɥɭɱɲɟ ɭɤɚɡɵɜɚɬɶ ɢɦɟɧɧɨ ɜ ɪɚɡɞɟɥɟ ɪɟɚɥɢɡɚɰɢɢ. Ɋɚɡɞɟɥ ɢɧɢɰɢɚɥɢɡɚɰɢɢ ɫɨɞɟɪɠɢɬ ɨɩɟɪɚɬɨɪɵ, ɜɵɩɨɥɧɹɟɦɵɟ ɬɨɥɶɤɨ ɨɞɢɧ ɪɚɡ ɩɪɢ ɡɚɩɭɫɤɟ ɩɪɨɝɪɚɦɦɵ, ɜ ɤɨɬɨɪɨɣ ɢɫɩɨɥɶɡɭɟɬɫɹ ɞɚɧɧɵɣ ɦɨɞɭɥɶ. Ɋɚɡɞɟɥ ɢɧɢɰɢɚɥɢɡɚɰɢɢ ɧɟɨɛɹɡɚɬɟɥɟɧ. ɇɚɱɚɥɨ ɛɥɨɤɚ ɭɤɚɡɵɜɚɟɬɫɹ ɡɚɪɟɡɟɪɜɢɪɨɜɚɧɧɵɦ ɫɥɨɜɨɦ initialization. ɂɧɢɰɢɚɥɢɡɚɰɢɨɧɧɵɟ ɪɚɡɞɟɥɵ ɦɨɞɭɥɟɣ ɜɵɩɨɥɧɹɸɬɫɹ ɜ ɬɨɦ ɩɨɪɹɞɤɟ, ɜ ɤɨɬɨɪɨɦ ɦɨɞɭɥɢ ɨɛɴɹɜɥɟɧɵ ɜ ɩɪɟɞɥɨɠɟɧɢɢ uses. Ɋɚɡɞɟɥ ɡɚɜɟɪɲɟɧɢɹ ɧɚɱɢɧɚɟɬɫɹ ɫ ɤɥɸɱɟɜɨɝɨ ɫɥɨɜɚ finalization ɢ ɜɤɥɸɱɚɟɬɫɹ ɜ ɩɪɨɝɪɚɦɦɭ ɬɨɥɶɤɨ ɜ ɬɨɦ ɫɥɭɱɚɟ, ɟɫɥɢ ɦɨɞɭɥɶ ɫɨɞɟɪɠɢɬ ɪɚɡɞɟɥ ɢɧɢɰɢɚɥɢɡɚɰɢɢ. Ȼɥɨɤ ɡɚɜɟɪɲɟɧɢɹ ɫɨɞɟɪɠɢɬ ɨɩɟɪɚɬɨɪɵ, ɤɨɬɨɪɵɟ ɜɵɩɨɥɧɹɸɬɫɹ ɬɨɥɶɤɨ ɨɞɢɧ ɪɚɡ ɩɪɢ ɡɚɜɟɪɲɟɧɢɢ ɪɚɛɨɬɵ ɩɪɨɝɪɚɦɦɵ, ɢɫɩɨɥɶɡɭɸɳɟɣ ɞɚɧɧɵɣ ɦɨɞɭɥɶ. Ɋɚɡɞɟɥɵ ɡɚɜɟɪɲɟɧɢɹ ɜɵɩɨɥɧɹɸɬɫɹ ɜ ɩɨɪɹɞɤɟ, ɨɛɪɚɬɧɨɦ ɩɨɪɹɞɤɭ ɩɟɪɟɱɢɫɥɟɧɢɹ ɦɨɞɭɥɟɣ ɜ ɨɛɴɹɜɥɟɧɢɢ uses. ɉɪɢ ɤɨɦɩɢɥɹɰɢɢ ɩɪɨɝɪɚɦɦɵ Delphi ɫɨɡɞɚɟɬ ɨɛɴɟɤɬɧɵɣ ɮɚɣɥ ɫ ɪɚɫɲɢɪɟɧɢɟɦ .dcu, ɫɨɞɟɪɠɚɳɢɣ ɜ ɫɟɛɟ ɪɟɡɭɥɶɬɚɬ ɩɟɪɟɜɨɞɚ ɬɟɤɫɬɚ ɤɨɞɚ ɩɪɨɝɪɚɦɦɵ ɜ ɦɚɲɢɧɧɵɟ ɤɨɞɵ ɫɨɞɟɪɠɢɦɨɝɨ ɮɚɣɥɨɜ ɫ ɪɚɫɲɢɪɟɧɢɟɦ .pas ɢ .dfm. Ʉɨɦɩɨɧɨɜɳɢɤ ɢɥɢ ɪɟɞɚɤɬɨɪ ɫɜɹɡɟɣ ɩɪɟɨɛɪɚɡɭɟɬ ɫɨɜɨɤɭɩɧɨɫɬɶ ɨɛɴɟɤɬɧɵɯ ɮɚɣɥɨɜ ɫ ɪɚɫɲɢɪɟɧɢɟɦ .dcu ɜ ɟɞɢɧɵɣ ɡɚɝɪɭɠɚɟɦɵɣ ɮɚɣɥ ɫ ɪɚɫɲɢɪɟɧɢɟɦ .exe. ȼ ɮɚɣɥɚɯ, ɢɦɟɸɳɢɯ ɪɚɫɲɢɪɟɧɢɟ .~df, .~dp, .~pa, ɯɪɚɧɹɬɫɹ ɪɟɡɟɪɜɧɵɟ ɤɨɩɢɢ ɮɚɣɥɨɜ ɫ ɨɛɪɚɡɨɦ ɮɨɪɦɵ, ɩɪɨɟɤɬɚ ɢ ɢɫɯɨɞɧɨɝɨ ɬɟɤɫɬɚ ɫɨɨɬɜɟɬɫɬɜɟɧɧɨ. ȼ ɩɪɨɟɤɬɟ Delphi ɦɨɝɭɬ ɩɪɢɫɭɬɫɬɜɨɜɚɬɶ ɢ ɞɪɭɝɢɟ ɮɚɣɥɵ: 12
– *.res – ɪɟɫɭɪɫɵ (ɯɪɚɧɹɬ ɢɡɨɛɪɚɠɟɧɢɹ, ɫɬɪɨɤɢ ɞɥɹ ɫɨɨɛɳɟɧɢɣ, ɢɧɮɨɪɦɚɰɢɸ ɨ ɜɟɪɫɢɢ ɩɪɨɝɪɚɦɦɵ); – *.cfg – ɨɬɤɨɦɩɢɥɢɪɨɜɚɧɧɵɣ ɮɚɣɥ ɧɚɫɬɪɨɟɤ ɩɪɨɟɤɬɚ; – *.dof – ɬɟɤɫɬɨɜɵɣ ɮɚɣɥ, ɜ ɤɨɬɨɪɨɦ ɯɪɚɧɹɬɫɹ ɡɧɚɱɟɧɢɹ ɨɩɰɢɣ ɩɪɨɟɤɬɚ (ɧɚɫɬɪɨɣɤɢ ɤɨɦɩɢɥɹɬɨɪɚ ɢ ɤɨɦɩɨɧɨɜɳɢɤɚ, ɤɚɬɚɥɨɝɢ ɢ ɬ. ɞ.); – *.dsk – ɬɟɤɫɬɨɜɵɣ ɮɚɣɥ ɧɚɫɬɪɨɟɤ ɫɪɟɞɵ ɪɚɡɪɚɛɨɬɤɢ ɞɥɹ ɞɚɧɧɨɝɨ ɩɪɨɟɤɬɚ. 3. ɅȺȻɈɊȺɌɈɊɇɕɃ ɉɊȺɄɌɂɄɍɆ ȼ ɫɨɫɬɚɜ ɥɚɛɨɪɚɬɨɪɧɨɝɨ ɩɪɚɤɬɢɤɭɦɚ ɜɯɨɞɢɬ ɩɹɬɶ ɱɟɬɵɪɟɯɱɚɫɨɜɵɯ ɡɚɧɹɬɢɣ. ɉɪɟɞɩɨɥɚɝɚɟɬɫɹ, ɱɬɨ ɩɟɪɜɚɹ ɱɚɫɬɶ ɜɵɩɨɥɧɹɟɬɫɹ ɫɬɭɞɟɧɬɨɦ ɩɨɞ ɪɭɤɨɜɨɞɫɬɜɨɦ ɩɪɟɩɨɞɚɜɚɬɟɥɹ, ɚ ɜɬɨɪɚɹ – ɫɚɦɨɫɬɨɹɬɟɥɶɧɨ. 3.1. Ɋɚɡɪɚɛɨɬɤɚ ɩɪɢɥɨɠɟɧɢɣ ɜ ɫɪɟɞɟ Delphi 7. ɋɬɚɧɞɚɪɬɧɵɟ ɜɢɡɭɚɥɶɧɵɟ ɤɨɦɩɨɧɟɧɬɵ ɐɟɥɶ: ɨɡɧɚɤɨɦɢɬɶɫɹ ɫ ɨɫɧɨɜɧɵɦɢ ɨɤɧɚɦɢ ɫɪɟɞɵ Delphi, ɫ ɩɪɨɰɟɫɫɨɦ ɤɨɧɫɬɪɭɢɪɨɜɚɧɢɹ ɜɢɡɭɚɥɶɧɨɝɨ ɩɪɨɹɜɥɟɧɢɹ ɩɪɨɝɪɚɦɦɵ ɢ ɫ ɧɚɛɨɪɨɦ ɫɬɚɧɞɚɪɬɧɵɯ ɤɨɦɩɨɧɟɧɬɨɜ Delphi. Ɂɚɤɪɟɩɢɬɶ ɡɧɚɧɢɹ ɩɨ ɩɪɨɰɟɫɫɭ ɤɨɧɫɬɪɭɢɪɨɜɚɧɢɹ ɩɪɨɝɪɚɦɦɵ, ɩɨɥɭɱɟɧɧɵɟ ɧɚ ɩɟɪɜɨɣ ɱɚɫɬɢ ɡɚɧɹɬɢɹ. Ɋɟɡɭɥɶɬɚɬ ɨɛɭɱɟɧɢɹ: ɩɨɫɥɟ ɭɫɩɟɲɧɨɝɨ ɡɚɜɟɪɲɟɧɢɹ ɡɚɧɹɬɢɹ ɩɨɥɶɡɨɜɚɬɟɥɶ ɞɨɥɠɟɧ: – ɡɧɚɬɶ ɧɚɡɧɚɱɟɧɢɟ ɨɤɨɧ: ɝɥɚɜɧɨɝɨ, ɮɨɪɦɵ, ɨɤɧɚ ɤɨɞɚ, ɢɧɫɩɟɤɬɨɪɚ ɨɛɴɟɤɬɨɜ; – ɭɦɟɬɶ ɪɚɫɩɨɥɚɝɚɬɶ ɤɨɦɩɨɧɟɧɬɵ ɧɚ ɮɨɪɦɟ; – ɩɪɢɞɚɜɚɬɶ ɤɨɦɩɨɧɟɧɬɚɦ ɫɜɨɣɫɬɜɚ ɢ ɮɭɧɤɰɢɨɧɚɥɶɧɨɫɬɶ ɫ ɩɨɦɨɳɶɸ ɢɧɫɩɟɤɬɨɪɚ ɨɛɴɟɤɬɨɜ; – ɭɦɟɬɶ ɢɫɩɨɥɶɡɨɜɚɬɶ ɜ ɩɪɨɝɪɚɦɦɚɯ ɪɟɞɚɤɬɨɪɵ ɬɟɤɫɬɨɜ, ɫɩɢɫɤɢ ɜɵɛɨɪɚ, ɩɟɪɟɤɥɸɱɚɬɟɥɢ, ɤɨɦɩɨɧɟɧɬɵ ɞɥɹ ɨɛɴɟɞɢɧɟɧɢɹ ɝɪɭɩɩ ɷɥɟɦɟɧɬɨɜ ɭɩɪɚɜɥɟɧɢɹ. ɉɥɚɧ ɡɚɧɹɬɢɹ ɑɚɫɬɶ I. Ɋɚɡɪɚɛɨɬɤɚ ɩɪɢɥɨɠɟɧɢɣ ɜ ɫɪɟɞɟ Delphi 7. 1. ɂɡɭɱɟɧɢɟ ɦɟɬɨɞɨɜ ɫɨɡɞɚɧɢɹ ɩɪɢɥɨɠɟɧɢɹ ɜ ɫɪɟɞɟ Delphi 7: ɪɚɛɨɬɚ ɩɨɞ ɪɭɤɨɜɨɞɫɬɜɨɦ ɩɪɟɩɨɞɚɜɚɬɟɥɹ 50 ɦɢɧɭɬ. 2. ɋɚɦɨɫɬɨɹɬɟɥɶɧɚɹ ɪɚɛɨɬɚ 30 ɦɢɧɭɬ. ɑɚɫɬɶ II. ɋɬɚɧɞɚɪɬɧɵɟ ɜɢɡɭɚɥɶɧɵɟ ɤɨɦɩɨɧɟɧɬɵ. 1. ɂɡɭɱɟɧɢɟ ɩɪɢɟɦɨɜ ɢɫɩɨɥɶɡɨɜɚɧɢɹ ɷɥɟɦɟɧɬɨɜ ɭɩɪɚɜɥɟɧɢɹ, ɪɚɫɩɨɥɨɠɟɧɧɵɯ ɧɚ ɩɚɧɟɥɢ Standard. ɂɡɭɱɟɧɢɟ ɫɜɨɣɫɬɜ ɢ ɦɟɬɨɞɨɜ ɷɬɢɯ ɤɨɦɩɨɧɟɧɬɨɜ: ɪɚɛɨɬɚ ɩɨɞ ɪɭɤɨɜɨɞɫɬɜɨɦ ɩɪɟɩɨɞɚɜɚɬɟɥɹ 40 ɦɢɧɭɬ. 2. ɋɚɦɨɫɬɨɹɬɟɥɶɧɚɹ ɪɚɛɨɬɚ 40 ɦɢɧɭɬ. ɑɚɫɬɶ I. Ɋɚɡɪɚɛɨɬɤɚ ɩɪɢɥɨɠɟɧɢɣ ɜ ɫɪɟɞɟ Delphi 7. 13
1. ɂɡɭɱɟɧɢɟ ɦɟɬɨɞɨɜ ɫɨɡɞɚɧɢɹ ɩɪɢɥɨɠɟɧɢɹ ɜ ɫɪɟɞɟ Delphi 7 1.1. ɉɨɞɝɨɬɨɜɢɬɟɥɶɧɵɟ ɞɟɣɫɬɜɢɹ 1. Ʌɸɛɚɹ ɩɪɨɝɪɚɦɦɚ ɜ Delphi ɫɨɫɬɨɢɬ ɢɡ ɧɟɫɤɨɥɶɤɢɯ ɮɚɣɥɨɜ, ɩɨɷɬɨɦɭ ɤɚɠɞɭɸ ɩɪɨɝɪɚɦɦɭ ɩɨɥɟɡɧɨ ɫɨɯɪɚɧɹɬɶ ɜ ɨɬɞɟɥɶɧɨɦ ɤɚɬɚɥɨɝɟ. Ɇɢɧɢɦɢɡɢɪɭɣɬɟ ɨɤɧɨ Delphi. ɇɚ ɞɢɫɤɟ ɫɨɡɞɚɣɬɟ ɢɧɞɢɜɢɞɭɚɥɶɧɭɸ ɪɚɛɨɱɭɸ ɩɚɩɤɭ (ɤɚɬɚɥɨɝ). Ɂɚɞɚɣɬɟ ɢɦɹ ɤɚɬɚɥɨɝɚ, ɫɨɜɩɚɞɚɸɳɟɟ ɫ ɜɚɲɟɣ ɮɚɦɢɥɢɟɣ. ȼɨ ɜɧɨɜɶ ɫɨɡɞɚɧɧɨɦ ɤɚɬɚɥɨɝɟ ɫɨɡɞɚɣɬɟ ɤɚɬɚɥɨɝ ɫ ɢɦɟɧɟɦ Lab_1. 1.2. Ɂɧɚɤɨɦɫɬɜɨ ɫ Ƚɥɚɜɧɵɦ ɨɤɧɨɦ Delphi 1. ȼ ɜɟɪɯɧɟɣ ɱɚɫɬɢ ɷɤɪɚɧɚ ɪɚɫɩɨɥɚɝɚɟɬɫɹ ɝɥɚɜɧɨɟ ɨɤɧɨ Delphi. Ƚɥɚɜɧɨɟ ɨɤɧɨ ɨɫɭɳɟɫɬɜɥɹɟɬ ɨɫɧɨɜɧɵɟ ɮɭɧɤɰɢɢ ɭɩɪɚɜɥɟɧɢɹ ɩɪɨɟɤɬɨɦ ɫɨɡɞɚɜɚɟɦɨɣ ɩɪɨɝɪɚɦɦɵ. Ɂɞɟɫɶ ɪɚɫɩɨɥɚɝɚɟɬɫɹ ɝɥɚɜɧɨɟ ɢɥɢ ɨɫɧɨɜɧɨɟ ɦɟɧɸ Delphi, ɩɚɧɟɥɢ ɭɩɪɚɜɥɟɧɢɹ ɫ ɧɚɛɨɪɚɦɢ ɩɢɤɬɨɝɪɚɮɢɱɟɫɤɢɯ ɤɧɨɩɨɤ ɢ ɩɚɥɢɬɪɚ ɤɨɦɩɨɧɟɧɬɨɜ. ȼɢɡɭɚɥɶɧɨ ɨɬɦɟɬɶɬɟ ɷɬɢ ɫɨɫɬɚɜɥɹɸɳɢɟ ɝɥɚɜɧɨɝɨ ɨɤɧɚ. 2. ȼɫɟ ɷɥɟɦɟɧɬɵ ɝɥɚɜɧɨɝɨ ɨɤɧɚ ɧɚɯɨɞɹɬɫɹ ɧɚ ɫɩɟɰɢɚɥɶɧɵɯ ɩɚɧɟɥɹɯ, ɜ ɥɟɜɨɣ ɱɚɫɬɢ ɤɨɬɨɪɵɯ ɢɦɟɸɬɫɹ ɤɧɨɩɤɢ ɭɩɪɚɜɥɟɧɢɹ, ɩɨɡɜɨɥɹɸɳɢɟ ɫ ɩɨɦɨɳɶɸ ɦɵɲɢ ɩɟɪɟɬɚɫɤɢɜɚɬɶ ɩɚɧɟɥɢ ɫ ɩɨɦɟɳɟɧɧɵɦɢ ɧɚ ɧɢɯ ɷɥɟɦɟɧɬɚɦɢ. ɂɡɦɟɧɢɬɟ ɪɚɫɩɨɥɨɠɟɧɢɟ ɩɚɧɟɥɟɣ. Ⱦɥɹ ɷɬɨɝɨ ɧɭɠɧɨ ɧɚɠɚɬɶ ɥɟɜɭɸ ɤɥɚɜɢɲɭ ɦɵɲɢ ɧɚɞ ɤɧɨɩɤɨɣ ɭɩɪɚɜɥɟɧɢɹ ɢ, ɧɟ ɨɬɩɭɫɤɚɹ ɤɥɚɜɢɲɭ, ɫɦɟɫɬɢɬɶ ɭɤɚɡɚɬɟɥɶ ɧɚ ɧɨɜɨɟ ɦɟɫɬɨ. 3. ɉɢɤɬɨɝɪɚɮɢɱɟɫɤɢɟ ɤɧɨɩɤɢ ɨɬɤɪɵɜɚɸɬ ɛɵɫɬɪɵɣ ɞɨɩɭɫɤ ɤ ɧɚɢɛɨɥɟɟ ɜɚɠɧɵɦ ɤɨɦɚɧɞɚɦ ɫɪɟɞɵ. ɉɟɪɟɦɟɳɚɹ ɤɭɪɫɨɪ ɦɵɲɢ ɜɞɨɥɶ ɤɧɨɩɨɤ, ɡɚɞɟɪɠɢɜɚɣɬɟ ɟɝɨ ɧɚɞ ɤɚɠɞɨɣ ɤɧɨɩɤɨɣ ɢ ɨɡɧɚɤɨɦɶɬɟɫɶ ɫ ɩɨɹɜɥɹɸɳɟɣɫɹ ɩɨɞɫɤɚɡɤɨɣ ɨ ɟɟ ɧɚɡɧɚɱɟɧɢɢ. 4. ɇɚɛɨɪ ɩɢɤɬɨɝɪɚɮɢɱɟɫɤɢɯ ɤɧɨɩɨɤ ɦɨɠɧɨ ɢɡɦɟɧɹɬɶ, ɭɞɚɥɹɹ ɢɡ ɧɟɝɨ ɪɟɞɤɨ ɢɫɩɨɥɶɡɭɟɦɵɟ ɢɥɢ ɞɨɛɚɜɥɹɹ ɧɨɜɵɟ. – ɑɬɨɛɵ ɢɡɦɟɧɢɬɶ ɧɚɛɨɪ ɤɧɨɩɨɤ, ɳɟɥɤɧɢɬɟ ɩɨ ɥɸɛɨɣ ɢɡ ɧɢɯ ɩɪɚɜɨɣ ɤɥɚɜɢɲɟɣ ɦɵɲɢ ɢ ɜ ɩɨɹɜɢɜɲɟɦɫɹ ɜɫɩɨɦɨɝɚɬɟɥɶɧɨɦ ɦɟɧɸ ɜɵɛɟɪɢɬɟ ɤɨɦɚɧɞɭ Customize (ɦɨɞɢɮɢɰɢɪɨɜɚɬɶ) – ɧɚ ɷɤɪɚɧɟ ɩɨɹɜɢɬɫɹ ɨɤɧɨ ɦɨɞɢɮɢɤɚɰɢɢ ɩɚɧɟɥɟɣ ɢɧɫɬɪɭɦɟɧɬɨɜ. ȿɫɥɢ ɭɛɪɚɬɶ ɮɥɚɠɨɤ ɜɵɛɨɪɚ ɫɥɟɜɚ ɨɬ ɧɚɡɜɚɧɢɹ ɝɪɭɩɩɵ (ɩɚɧɟɥɶ Toolbar), ɫɨɨɬɜɟɬɫɬɜɭɸɳɚɹ ɩɚɧɟɥɶ ɢɫɱɟɡɧɟɬ ɢɡ ɨɤɧɚ. ɍɞɚɥɢɬɟ/ɜɨɫɫɬɚɧɨɜɢɬɟ ɫɬɚɧɞɚɪɬɧɭɸ ɩɚɧɟɥɶ. – ɑɬɨɛɵ ɭɞɚɥɢɬɶ ɤɧɨɩɤɭ, ɭɤɚɠɢɬɟ ɧɚ ɧɟɟ ɦɵɲɶɸ, ɧɚɠɦɢɬɟ ɥɟɜɭɸ ɤɥɚɜɢɲɭ ɦɵɲɢ ɢ, ɧɟ ɨɬɩɭɫɤɚɹ ɟɟ, «ɫɬɚɳɢɬɟ» ɤɧɨɩɤɭ ɡɚ ɝɪɚɧɢɰɭ ɝɥɚɜɧɨɝɨ ɨɤɧɚ. ɉɪɢ ɷɬɨɦ ɨɤɧɨ ɦɨɞɢɮɢɤɚɰɢɢ ɷɥɟɦɟɧɬɨɜ ɝɥɚɜɧɨɝɨ ɨɤɧɚ (Custɨmize) ɞɨɥɠɧɨ ɛɵɬɶ ɨɬɤɪɵɬɨ. ɍɛɟɪɢɬɟ ɤɧɨɩɤɭ ɜɵɡɨɜɚ ɫɩɪɚɜɨɱɧɨɣ ɫɥɭɠɛɵ. – ɑɬɨɛɵ ɩɨɦɟɫɬɢɬɶ ɧɚ ɩɚɧɟɥɶ ɤɧɨɩɨɤ ɧɨɜɭɸ, ɜɵɛɟɪɢɬɟ ɡɚɤɥɚɞɤɭ Commands, ɡɚɬɟɦ ɧɭɠɧɭɸ ɨɩɟɪɚɰɢɸ – ɡɚɝɨɥɨɜɨɤ ɝɥɚɜɧɨɝɨ ɦɟɧɸ ɢ «ɩɟɪɟɬɚɳɢɬɟ» ɟɟ ɧɚ ɬɭ ɢɥɢ ɢɧɭɸ ɩɚɧɟɥɶɤɭ ɫ ɤɧɨɩɤɚɦɢ. ȼɨɫɫɬɚɧɨɜɢɬɟ ɤɧɨɩɤɭ ɜɵɡɨɜɚ ɫɩɪɚɜɨɱɧɨɣ ɫɥɭɠɛɵ. 5. ɉɚɥɢɬɪɚ ɤɨɦɩɨɧɟɧɬɨɜ ɡɚɧɢɦɚɟɬ ɩɪɚɜɭɸ ɱɚɫɬɶ ɝɥɚɜɧɨɝɨ ɨɤɧɚ ɢ ɢɦɟɟɬ ɡɚɤɥɚɞɤɢ, ɨɛɟɫɩɟɱɢɜɚɸɳɢɟ ɛɵɫɬɪɵɣ ɩɨɢɫɤ ɧɟɨɛɯɨɞɢɦɨɝɨ ɤɨɦɩɨɧɟɧɬɚ. 14
– ɉɪɨɫɦɨɬɪɢɬɟ ɫɨɞɟɪɠɢɦɨɟ ɤɚɠɞɨɣ ɫɬɪɚɧɢɰɵ ɩɚɥɢɬɪɵ ɤɨɦɩɨɧɟɧɬɨɜ. – Ʉɚɤ ɢ ɩɚɧɟɥɶ ɤɧɨɩɨɤ, ɩɚɥɢɬɪɚ ɤɨɦɩɨɧɟɧɬɨɜ ɦɨɠɟɬ ɧɚɫɬɪɚɢɜɚɬɶɫɹ. Ⱦɥɹ ɷɬɨɝɨ ɢɫɩɨɥɶɡɭɟɬɫɹ ɫɩɟɰɢɚɥɶɧɵɣ ɪɟɞɚɤɬɨɪ Palette Properties, ɨɤɧɨ ɤɨɬɨɪɨɝɨ ɩɨɹɜɥɹɟɬɫɹ ɧɚ ɷɤɪɚɧɟ ɩɨɫɥɟ ɳɟɥɱɤɚ ɩɪɚɜɨɣ ɤɧɨɩɤɨɣ ɦɵɲɢ ɧɚ ɥɸɛɨɣ ɩɢɤɬɨɝɪɚɦɦɟ ɜ ɩɚɥɢɬɪɟ ɤɨɦɩɨɧɟɧɬɨɜ ɢ ɜɵɛɨɪɚ ɨɩɰɢɢ Properties. «ɉɟɪɟɬɚɳɢɬɟ» ɫɬɪɨɤɭ Samples ɜ ɨɤɧɟ Pages ɪɟɞɚɤɬɨɪɚ ɩɚɥɢɬɪɵ ɜɜɟɪɯ ɢ «ɩɨɥɨɠɢɬɟ» ɟɟ ɧɚ ɫɬɪɨɤɭ Data Access. Ɂɚɤɪɨɣɬɟ ɨɤɧɨ Palette Properties. ɋɬɪɚɧɢɰɚ Samples ɬɟɩɟɪɶ ɪɚɫɩɨɥɨɠɟɧɚ ɧɚ ɩɹɬɨɦ ɦɟɫɬɟ ɢ ɞɨɫɬɭɩɧɚ ɛɟɡ «ɩɪɨɤɪɭɬɤɢ» ɡɚɤɥɚɞɨɤ ɩɚɥɢɬɪɵ. 1.3. Ɂɧɚɤɨɦɫɬɜɨ ɫ ɨɤɧɨɦ ɮɨɪɦɵ 1. Ɉɤɧɨ ɮɨɪɦɵ ɩɪɟɞɫɬɚɜɥɹɟɬ ɫɨɛɨɣ ɩɪɨɟɤɬ Windows-ɨɤɧɚ ɛɭɞɭɳɟɣ ɩɪɨɝɪɚɦɦɵ. ȼɧɚɱɚɥɟ ɨɤɧɨ ɮɨɪɦɵ ɫɨɞɟɪɠɢɬ ɬɨɥɶɤɨ ɫɬɚɧɞɚɪɬɧɵɟ ɞɥɹ Windows ɢɧɬɟɪɮɟɣɫɧɵɟ ɷɥɟɦɟɧɬɵ – ɫɬɪɨɤɭ ɡɚɝɨɥɨɜɤɚ ɫ ɤɧɨɩɤɚɦɢ ɜɵɡɨɜɚ ɫɢɫɬɟɦɧɨɝɨ ɦɟɧɸ ɢ ɢɡɦɟɧɟɧɢɹ ɜɢɞɚ ɨɤɧɚ – ɦɚɤɫɢɦɢɡɚɰɢɢ, ɦɢɧɢɦɢɡɚɰɢɢ ɢ ɡɚɤɪɵɬɢɹ, ɚ ɬɚɤɠɟ ɨɱɟɪɱɢɜɚɸɳɭɸ ɟɝɨ ɪɚɦɤɭ. ȼɢɡɭɚɥɶɧɨ ɨɬɦɟɬɶɬɟ ɷɬɢ ɷɥɟɦɟɧɬɵ ɧɚ ɮɨɪɦɟ. 2. ɉɪɢ ɧɚɠɚɬɢɢ ɤɧɨɩɤɢ
ɜɵɩɨɥɧɹɸɬɫɹ ɬɪɢ ɷɬɚɩɚ: ɤɨɦɩɢɥɹɰɢɹ, ɤɨɦɩɨɧɨɜɤɚ, ɢɫɩɨɥɧɟɧɢɟ ɩɪɨɝɪɚɦɦɵ. – Ɉɫɭɳɟɫɬɜɢɬɟ ɩɪɨɝɨɧ ɩɪɨɝɪɚɦɦɵ, ɧɚɠɚɜ ɤɧɨɩɤɭ . – ɇɚ ɷɤɪɚɧɟ ɪɚɛɨɬɚɸɳɟɟ ɩɪɢɥɨɠɟɧɢɟ, ɩɪɟɞɫɬɚɜɥɹɸɳɟɟ ɫɨɛɨɣ ɩɭɫɬɨɟ ɨɤɧɨ. Ɂɚɤɪɨɣɬɟ ɩɪɢɥɨɠɟɧɢɟ. 3. Ʉɨɦɩɨɧɟɧɬɵ ɫ ɉɚɥɢɬɪɵ ɤɨɦɩɨɧɟɧɬɨɜ ɪɚɡɦɟɳɚɸɬɫɹ ɧɚ ɩɨɜɟɪɯɧɨɫɬɢ ɮɨɪɦɵ. Ⱦɥɹ ɷɬɨɝɨ ɫɧɚɱɚɥɚ ɧɭɠɧɨ ɤɨɦɩɨɧɟɧɬ ɜɵɛɪɚɬɶ (ɳɟɥɤɧɭɬɶ ɩɨ ɧɟɦɭ ɦɵɲɶɸ) ɜ ɉɚɥɢɬɪɟ ɤɨɦɩɨɧɟɧɬɨɜ, ɚ ɡɚɬɟɦ ɳɟɥɤɧɭɬɶ ɦɵɲɶɸ ɩɨ ɬɨɱɤɟ ɪɚɛɨɱɟɝɨ ɩɨɥɹ ɮɨɪɦɵ, ɝɞɟ ɞɨɥɠɟɧ ɪɚɫɩɨɥɚɝɚɬɶɫɹ ɥɟɜɵɣ ɜɟɪɯɧɢɣ ɭɝɨɥ ɤɨɦɩɨɧɟɧɬɚ. Ɋɚɡɦɟɫɬɢɬɟ ɧɚ ɮɨɪɦɟ ɤɨɦɩɨɧɟɧɬɵ, ɪɚɫɩɨɥɨɠɟɧɧɵɟ ɧɚ ɩɚɧɟɥɢ Standard. 4. Ⱦɥɹ ɬɨɝɨ ɱɬɨɛɵ ɭɛɪɚɬɶ ɤɨɦɩɨɧɟɧɬ ɫ ɩɨɜɟɪɯɧɨɫɬɢ ɮɨɪɦɵ, ɧɟɨɛɯɨɞɢɦɨ ɜɵɞɟɥɢɬɶ ɤɨɦɩɨɧɟɧɬ ɢ ɧɚɠɚɬɶ ɤɥɚɜɢɲɭ . ɍɛɟɪɢɬɟ ɤɨɦɩɨɧɟɧɬɵ ɫ ɩɨɜɟɪɯɧɨɫɬɢ ɮɨɪɦɵ. 1.4. Ɂɧɚɤɨɦɫɬɜɨ ɫ ɨɤɧɨɦ ɢɧɫɩɟɤɬɨɪɚ ɨɛɴɟɤɬɨɜ 1. Ɉɤɧɨ ɢɧɫɩɟɤɬɨɪɚ ɨɛɴɟɤɬɨɜ ɫɨɞɟɪɠɢɬ ɞɜɟ ɫɬɪɚɧɢɰɵ: Properties ɢ Events. ɋɬɪɚɧɢɰɚ Properties ɫɥɭɠɢɬ ɞɥɹ ɭɫɬɚɧɨɜɤɢ ɧɭɠɧɵɯ ɫɜɨɣɫɬɜ ɤɨɦɩɨɧɟɧɬɚ, ɫɬɪɚɧɢɰɚ Events ɩɨɡɜɨɥɹɟɬ ɨɩɪɟɞɟɥɢɬɶ ɪɟɚɤɰɢɸ ɤɨɦɩɨɧɟɧɬɚ ɧɚ ɬɨ ɢɥɢ ɢɧɨɟ ɫɨɛɵɬɢɟ. ȼ ɜɟɪɯɧɟɣ ɱɚɫɬɢ ɢɧɫɩɟɤɬɨɪɚ ɨɛɴɟɤɬɨɜ ɪɚɫɩɨɥɚɝɚɟɬɫɹ ɪɚɫɤɪɵɜɚɸɳɢɣɫɹ ɫɩɢɫɨɤ ɜɫɟɯ ɤɨɦɩɨɧɟɧɬɨɜ, ɩɨɦɟɳɟɧɧɵɯ ɧɚ ɮɨɪɦɭ. ɉɪɨɫɦɨɬɪɢɬɟ ɫɜɨɣɫɬɜɚ ɮɨɪɦɵ, ɩɪɟɞɫɬɚɜɥɟɧɧɵɟ ɧɚ ɫɬɪɚɧɢɰɟ Properties. 2. ɉɨ ɭɦɨɥɱɚɧɢɸ ɡɚɝɨɥɨɜɨɤ ɨɤɧɚ ɫɨɜɩɚɞɚɟɬ ɫ ɡɚɝɨɥɨɜɤɨɦ ɮɨɪɦɵ: Form1. ɂɡɦɟɧɢɬɟ ɫɜɨɣɫɬɜɨ Caption ɫ Form1 ɧɚ Ʌɚɛɨɪɚɬɨɪɧɚɹ ɪɚɛɨɬɚ 15
ʋ 1. Ⱦɥɹ ɷɬɨɝɨ ɳɟɥɤɧɢɬɟ ɦɵɲɶɸ ɩɨ ɫɬɪɨɤɟ Caption ɜ ɩɪɚɜɨɣ ɱɚɫɬɢ ɢ ɜɜɟɞɢɬɟ ɬɟɤɫɬ ɧɨɜɨɝɨ ɡɚɝɨɥɨɜɤɚ. 3. Ɉɛɪɚɬɢɬɟ ɜɧɢɦɚɧɢɟ ɧɚ ɫɜɨɣɫɬɜɨ Name. ɗɬɨ ɫɜɨɣɫɬɜɨ ɨɩɪɟɞɟɥɹɟɬ ɢɦɹ ɤɨɦɩɨɧɟɧɬɚ, ɩɨɞ ɤɨɬɨɪɵɦ ɤɨɦɩɨɧɟɧɬ ɛɭɞɟɬ ɢɡɜɟɫɬɟɧ ɩɪɨɝɪɚɦɦɟ. ɉɟɪɜɨɟ ɜɪɟɦɹ ɦɨɠɧɨ ɨɫɬɚɜɥɹɬɶ ɢɦɹ ɤɨɦɩɨɧɟɧɬɚ ɬɚɤɢɦ, ɤɚɤɨɟ ɡɚɞɚɟɬ Delphi ɩɨ ɭɦɨɥɱɚɧɢɸ. Ɍɚɤ ȼɵ ɡɚɩɨɦɧɢɬɟ ɧɚɡɜɚɧɢɹ ɤɨɦɩɨɧɟɧɬɨɜ. ȼ ɞɚɥɶɧɟɣɲɟɣ ɪɚɛɨɬɟ ɪɟɤɨɦɟɧɞɭɟɬɫɹ ɡɚɞɚɜɚɬɶ ɤɨɦɩɨɧɟɧɬɚɦ ɢɦɟɧɚ «ɫɨ ɫɦɵɫɥɨɦ» ɜɦɟɫɬɨ ɨɞɧɨɬɢɩɧɵɯ ɢɦɟɧ, ɤɨɬɨɪɵɟ «ɩɪɢɞɭɦɵɜɚɟɬ» Delphi. 4. ɉɨɦɟɫɬɢɬɟ ɧɚ ɮɨɪɦɭ ɤɨɦɩɨɧɟɧɬ Panel1. Ɉɫɭɳɟɫɬɜɢɬɟ ɩɪɨɝɨɧ ɩɭɫɬɨɣ ɩɪɨɝɪɚɦɦɵ. ȼ ɪɚɛɨɱɟɦ ɩɪɢɥɨɠɟɧɢɢ ɦɚɤɫɢɦɢɡɢɪɭɣɬɟ ɨɤɧɨ, ɚ ɡɚɬɟɦ ɡɚɤɪɨɣɬɟ ɟɝɨ. 5. Ɂɚɞɚɣɬɟ ɫɜɨɣɫɬɜɭ Align ɤɨɦɩɨɧɟɧɬɚ Panel1 ɡɧɚɱɟɧɢɟ alBottom. ɋɜɨɣɫɬɜɨ Align ɭɤɚɡɵɜɚɟɬ ɫɩɨɫɨɛ ɜɵɪɚɜɧɢɜɚɧɢɹ ɪɚɡɦɟɳɚɟɦɨɝɨ ɤɨɦɩɨɧɟɧɬɚ ɨɬɧɨɫɢɬɟɥɶɧɨ ɬɨɝɨ ɤɨɧɬɟɣɧɟɪɚ, ɜ ɤɨɬɨɪɨɦ ɨɧ ɪɚɡɦɟɳɚɟɬɫɹ. Ɉɫɭɳɟɫɬɜɢɬɟ ɩɪɨɝɨɧ ɩɪɨɝɪɚɦɦɵ. ȼ ɪɚɛɨɱɟɦ ɩɪɢɥɨɠɟɧɢɢ ɦɚɤɫɢɦɢɡɢɪɭɣɬɟ ɨɤɧɨ, ɚ ɡɚɬɟɦ ɡɚɤɪɨɣɬɟ ɟɝɨ. Ɋɚɡɦɟɪ ɩɚɧɟɥɢ ɩɪɢ ɬɚɤɨɦ ɪɚɡɦɟɳɟɧɢɢ ɢɡɦɟɧɹɟɬɫɹ ɩɪɨɩɨɪɰɢɨɧɚɥɶɧɨ ɮɨɪɦɟ. 6. Ɉɱɢɫɬɢɬɟ ɫɜɨɣɫɬɜɨ Caption ɞɥɹ ɤɨɦɩɨɧɟɧɬɚ Panel1. 7. Ɉɬɛɭɤɫɢɪɭɣɬɟ ɫɬɨɪɨɧɭ ɤɨɦɩɨɧɟɧɬɚ Panel1, ɭɯɜɚɬɢɜɲɢɫɶ ɡɚ ɜɟɪɯɧɢɣ ɨɛɪɚɦɥɹɸɳɢɣ ɱɟɪɧɵɣ ɤɜɚɞɪɚɬɢɤ. ɍɫɬɚɧɨɜɢɬɟ ɜɵɫɨɬɭ ɩɚɧɟɥɢ ɩɪɢɛɥɢɡɢɬɟɥɶɧɨ ɪɚɜɧɭɸ 175. Ɉɛɪɚɬɢɬɟ ɜɧɢɦɚɧɢɟ ɧɚ ɬɨ, ɱɬɨ ɷɬɨ ɡɧɚɱɟɧɢɟ ɭɫɬɚɧɨɜɢɥɨɫɶ ɜ ɫɜɨɣɫɬɜɟ Height ɢɧɫɩɟɤɬɨɪɚ ɨɛɴɟɤɬɨɜ. 8. ɉɨɦɟɫɬɢɬɟ ɧɚ ɮɨɪɦɭ ɤɨɦɩɨɧɟɧɬ Panel2 ɢ ɪɚɫɩɨɥɨɠɢɬɟ ɟɝɨ ɩɨ ɥɟɜɨɣ ɫɬɨɪɨɧɟ (ɫɜɨɣɫɬɜɭ Align ɡɚɞɚɣɬɟ ɡɧɚɱɟɧɢɟ alLeft). Ɉɱɢɫɬɢɬɟ ɫɜɨɣɫɬɜɨ Caption. ɒɢɪɢɧɭ ɩɚɧɟɥɢ ɢɡɦɟɧɢɬɟ, ɭɫɬɚɧɨɜɢɜ ɡɧɚɱɟɧɢɟ 233 ɜ ɫɜɨɣɫɬɜɟ Width ɢɧɫɩɟɤɬɨɪɚ ɨɛɴɟɤɬɨɜ. 9. ɉɨɦɟɫɬɢɬɟ ɧɚ ɮɨɪɦɭ ɤɨɦɩɨɧɟɧɬ Memo1 (ɦɧɨɝɨɫɬɪɨɱɧɵɣ ɪɟɞɚɤɬɨɪ) ɢ ɡɚɞɚɣɬɟ ɫɜɨɣɫɬɜɭ Align ɡɧɚɱɟɧɢɟ alClient. Ʉɨɦɩɨɧɟɧɬ ɡɚɣɦɟɬ ɜɫɸ ɨɫɬɚɜɲɭɸɫɹ ɱɚɫɬɶ ɮɨɪɦɵ. 10. Ɉɱɢɫɬɢɬɟ ɫɜɨɣɫɬɜɨ Lines ɦɧɨɝɨɫɬɪɨɱɧɨɝɨ ɪɟɞɚɤɬɨɪɚ. Ⱦɥɹ ɷɬɨɝɨ ɳɟɥɤɧɢɬɟ ɩɨ ɷɬɨɦɭ ɫɜɨɣɫɬɜɭ ɜ ɨɤɧɟ ɢɧɫɩɟɤɬɨɪɚ ɨɛɴɟɤɬɨɜ ɢ ɜɵɡɨɜɢɬɟ ɞɢɚɥɨɝɨɜɨɟ ɨɤɧɨ ɢɡɦɟɧɟɧɢɹ ɫɜɨɣɫɬɜɚ. ɍɞɚɥɢɬɟ ɭɦɚɥɱɢɜɚɟɦɵɣ ɬɟɤɫɬ Memo1 ɢ ɡɚɤɪɨɣɬɟ ɨɤɧɨ ɤɧɨɩɤɨɣ <ɈɄ>. 11. ɍɫɬɚɧɨɜɢɬɟ ɧɚ ɩɚɧɟɥɶ Panel2 ɦɟɬɤɭ Label1. ɋɜɨɣɫɬɜɭ WordWrap ɩɪɢɞɚɣɬɟ ɡɧɚɱɟɧɢɟ True. ɋɜɨɣɫɬɜɨ WordWrap ɪɚɡɪɟɲɚɟɬ/ɨɬɦɟɧɹɟɬ ɪɚɡɪɵɜ ɫɬɪɨɤɢ ɧɚ ɝɪɚɧɢɰɟ ɫɥɨɜɚ. ɋɜɨɣɫɬɜɭ Caption ɩɪɢɞɚɣɬɟ ɡɧɚɱɟɧɢɟ «ȼɜɟɞɢɬɟ ɡɧɚɱɟɧɢɟ ɜɟɫɚ ɜ ɝɪɚɦɦɚɯ». 12. ɍɫɬɚɧɨɜɢɬɟ ɧɚ ɩɚɧɟɥɶ Panel2 ɨɞɧɨɫɬɪɨɱɧɵɣ ɪɟɞɚɤɬɨɪ Edit1. Ɉɱɢɫɬɢɬɟ ɫɜɨɣɫɬɜɨ Text. 16
13. ɍɫɬɚɧɨɜɢɬɟ ɧɚ ɷɬɭ ɠɟ ɩɚɧɟɥɶ ɤɧɨɩɤɭ Button1. Ɂɚɞɚɣɬɟ ɫɜɨɣɫɬɜɭ Caption ɡɧɚɱɟɧɢɟ «ȼɜɨɞ». ɓɟɥɱɤɨɦ ɩɨ ɩɪɚɜɨɣ ɱɚɫɬɢ ɫɬɪɨɤɢ ɫɜɨɣɫɬɜɚ Font ɪɚɫɤɪɨɣɬɟ ɞɢɚɥɨɝɨɜɨɟ ɨɤɧɨ ɧɚɫɬɪɨɣɤɢ ɲɪɢɮɬɚ ɢ ɢɡɦɟɧɢɬɟ ɜɵɫɨɬɭ ɲɪɢɮɬɚ. 14. Ɍɟɩɟɪɶ ɭɫɬɚɧɨɜɢɬɟ ɧɚ ɩɚɧɟɥɶ Panel1 ɤɧɨɩɤɭ BitBtn1, ɤɨɬɨɪɚɹ ɧɚɯɨɞɢɬɫɹ ɧɚ ɩɚɧɟɥɢ Additional. ɂɡɦɟɧɢɬɟ ɫɜɨɣɫɬɜɨ Kind ɧɚ bkClose. Ⱦɥɹ ɤɨɦɩɨɧɟɧɬɨɜ ɌBitBtn ɫɜɨɣɫɬɜɨ Kind (ɫɨɪɬ) ɨɩɪɟɞɟɥɹɟɬ ɬɢɩɨɜɵɟ ɮɭɧɤɰɢɢ, ɤɨɬɨɪɵɟ ɪɟɚɥɢɡɭɟɬ ɤɧɨɩɤɚ ɜ ɞɢɚɥɨɝɨɜɵɯ ɨɤɧɚɯ. Ɂɧɚɱɟɧɢɟ bkClose ɨɩɪɟɞɟɥɢɬ ɬɢɩɨɜɭɸ ɮɭɧɤɰɢɸ ɡɚɤɪɵɬɢɹ ɨɤɧɚ, ɤɨɬɨɪɚɹ ɛɭɞɟɬ ɫɜɹɡɚɧɚ ɫ ɷɬɨɣ ɤɧɨɩɤɨɣ. ɍɜɟɥɢɱɶɬɟ ɪɚɡɦɟɪɵ ɤɧɨɩɤɢ. 15. ȼɚɲɚ ɩɪɨɟɤɬɢɪɭɟɦɚɹ ɮɨɪɦɚ ɞɨɥɠɧɚ ɩɪɢɧɹɬɶ ɜɢɞ, ɩɪɟɞɫɬɚɜɥɟɧɧɵɣ ɧɚ ɪɢɫ. 3.1.1.
Ɋɢɫ. 3.1.1. ȼɢɞ ɮɨɪɦɵ ɩɪɨɟɤɬɢɪɭɟɦɨɣ ɩɪɨɝɪɚɦɦɵ 16. ȼɵɞɟɥɢɬɟ ɤɧɨɩɤɭ Button1. ȼ ɢɧɫɩɟɤɬɨɪɟ ɨɛɴɟɤɬɨɜ ɨɬɪɚɡɹɬɫɹ ɫɜɨɣɫɬɜɚ ɷɬɨɣ ɤɧɨɩɤɢ. ɓɟɥɤɧɢɬɟ ɩɨ ɡɚɤɥɚɞɤɟ Events. ɇɚ ɷɬɨɣ ɡɚɤɥɚɞɤɟ ɩɟɪɟɱɢɫɥɟɧɵ ɫɨɛɵɬɢɹ, ɧɚ ɤɨɬɨɪɵɟ ɨɬɤɥɢɤɚɟɬɫɹ ɤɧɨɩɤɚ. Ⱦɜɚɠɞɵ ɳɟɥɤɧɢɬɟ ɩɨ ɩɪɚɜɨɣ ɱɚɫɬɢ ɫɬɪɨɤɢ ɫɨɛɵɬɢɹ OnClick (ɩɨ ɳɟɥɱɤɭ). ȼ ɨɬɜɟɬ Delphi ɚɤɬɢɜɢɡɢɪɭɟɬ ɨɤɧɨ ɩɪɨɝɪɚɦɦɵ. ɋɨɛɵɬɢɟ OnClick ɜɨɡɧɢɤɚɟɬ ɜ ɪɚɛɨɬɚɸɳɟɣ ɩɪɨɝɪɚɦɦɟ ɩɪɢ ɳɟɥɱɤɟ ɩɨ ɤɧɨɩɤɟ ɥɟɜɨɣ ɤɥɚɜɢɲɟɣ ɦɵɲɢ. 1.5. Ɂɧɚɤɨɦɫɬɜɨ ɫ ɨɤɧɨɦ ɤɨɞɚ ɩɪɨɝɪɚɦɦɵ 1. Ɉɤɧɨ ɤɨɞɚ ɩɪɨɝɪɚɦɦɵ ɩɪɟɞɧɚɡɧɚɱɟɧɨ ɞɥɹ ɫɨɡɞɚɧɢɹ ɢ ɪɟɞɚɤɬɢɪɨɜɚɧɢɹ ɬɟɤɫɬɚ ɩɪɨɝɪɚɦɦɵ. ɗɬɨɬ ɬɟɤɫɬ ɝɨɬɨɜɢɬɫɹ ɫ ɭɱɟɬɨɦ ɫɩɟɰɢɚɥɶɧɵɯ ɩɪɚɜɢɥ ɢ ɨɩɢɫɵɜɚɟɬ ɚɥɝɨɪɢɬɦ ɪɚɛɨɬɵ ɩɪɨɝɪɚɦɦɵ. ɉɟɪɜɨɧɚɱɚɥɶɧɨ ɨɤɧɨ ɤɨɞɚ ɫɨɞɟɪɠɢɬ ɦɢɧɢɦɚɥɶɧɵɣ ɢɫɯɨɞɧɵɣ ɬɟɤɫɬ, ɨɛɟɫɩɟɱɢɜɚɸɳɢɣ ɧɨɪɦɚɥɶɧɨɟ ɮɭɧɤɰɢɨɧɢɪɨɜɚɧɢɟ ɩɭɫɬɨɣ ɮɨɪɦɵ ɜ ɤɚɱɟɫɬɜɟ ɩɨɥɧɨɰɟɧɧɨɝɨ Windowsɨɤɧɚ. ȼ ɯɨɞɟ ɪɚɛɨɬɵ ɧɚɞ ɩɪɨɟɤɬɨɦ ɩɪɨɝɪɚɦɦɢɫɬ ɜɧɨɫɢɬ ɧɟɨɛɯɨɞɢɦɵɟ ɞɨɩɨɥɧɟɧɢɹ, ɱɬɨɛɵ ɩɪɢɞɚɬɶ ɩɪɨɝɪɚɦɦɟ ɧɭɠɧɭɸ ɮɭɧɤɰɢɨɧɚɥɶɧɨɫɬɶ. ɂɫɩɨɥɶɡɭɹ ɥɢɧɟɣɤɢ ɩɪɨɤɪɭɬɤɢ, ɩɪɨɫɦɨɬɪɢɬɟ ɫɨɞɟɪɠɢɦɨɟ ɨɤɧɚ ɤɨɞɚ ɩɪɨɝɪɚɦɦɵ. 2. ȼɦɟɫɬɟ ɫ ɨɤɧɨɦ ɤɨɞɚ ɩɪɨɝɪɚɦɦɵ ɨɛɵɱɧɨ ɚɤɬɢɜɢɡɢɪɭɟɬɫɹ ɬɚɤɠɟ ɢ ɨɤɧɨ ɧɚɜɢɝɚɬɨɪɚ ɤɨɞɚ ɩɪɨɝɪɚɦɦɵ, ɨɛɥɟɝɱɚɸɳɟɟ ɩɨɢɫɤ ɧɭɠɧɵɯ ɷɥɟɦɟɧɬɨɜ ɜ ɫɥɭɱɚɟ, ɤɨɝɞɚ ɜ ɨɤɧɟ ɧɚɛɪɚɧɨ ɦɧɨɝɨ ɫɬɪɨɤ ɬɟɤɫɬɚ. ɉɪɢ ɪɚɡɪɚɛɨɬɤɟ ɧɟɫɥɨɠɧɵɯ ɭɱɟɛɧɵɯ ɩɪɨɝɪɚɦɦ ɦɨɠɧɨ ɡɚɤɪɵɬɶ ɷɬɨ ɨɤɧɨ ɤɧɨɩɤɨɣ ɫ ɤɪɟɫɬɢɤɨɦ ɜ ɟɝɨ 17
ɜɟɪɯɧɟɦ ɩɪɚɜɨɦ ɭɝɥɭ. ȼɨɫɫɬɚɧɨɜɢɬɶ ɡɚɤɪɵɬɨɟ ɨɤɧɨ ɧɚɜɢɝɚɬɨɪɚ ɦɨɠɧɨ ɩɨɫɥɟ ɳɟɥɱɤɚ ɩɪɚɜɨɣ ɤɧɨɩɤɨɣ ɦɵɲɢ ɩɨ ɨɤɧɭ ɩɪɨɝɪɚɦɦɵ ɢ ɜɵɛɨɪɚ ɨɩɰɢɢ View/Code Explorer. Ɂɚɤɪɨɣɬɟ, ɨɬɤɪɨɣɬɟ ɢ ɜɧɨɜɶ ɡɚɤɪɨɣɬɟ ɨɤɧɨ ɧɚɜɢɝɚɬɨɪɚ. 3. Ⱦɜɚɠɞɵ ɳɟɥɤɧɭɜ ɩɨ ɩɪɚɜɨɣ ɱɚɫɬɢ ɫɬɪɨɤɢ ɫɨɛɵɬɢɹ OnClick, ȼɵ ɡɚɫɬɚɜɢɥɢ Delphi ɫɚɦɨɫɬɨɹɬɟɥɶɧɨ ɫɞɟɥɚɬɶ ɡɚɝɨɬɨɜɤɭ ɞɥɹ ɩɪɨɰɟɞɭɪɵ ɨɛɪɚɛɨɬɱɢɤɚ ɫɨɛɵɬɢɹ OnClick. procedure TForm1.Button1Click(Sender: TObject); begin … end; Ɇɟɠɞɭ ɨɩɟɪɚɬɨɪɧɵɦɢ ɫɤɨɛɤɚɦɢ Begin ɢ End ɜɜɟɞɢɬɟ ɫɥɟɞɭɸɳɢɟ ɨɩɟɪɚɬɨɪɵ ɹɡɵɤɚ Object Pascal: x := StrToFloat(Edit1.Text); y := x/400; Memo1.Lines.Add(FormatFloat('####.## Ƚɪɚɦɦɨɜ =',x)+ FormatFloat('####.## Ɏɭɧɬɨɜ', y)); Ⱦɨɩɨɥɧɢɬɟ ɨɩɢɫɚɧɢɟ ɩɟɪɟɦɟɧɧɵɯ ɦɨɞɭɥɹ. ɉɨɫɥɟ Var Form1: TForm1; ɞɨɛɚɜɶɬɟ x, y: Real; ȼ ɩɟɪɜɨɦ ɨɩɟɪɚɬɨɪɟ ɩɪɢɫɜɚɢɜɚɧɢɹ ɫɨɞɟɪɠɢɦɨɟ ɨɤɧɚ ɪɟɞɚɤɬɨɪɚ ɩɪɟɨɛɪɚɡɭɟɬɫɹ ɜ ɜɟɳɟɫɬɜɟɧɧɨɟ ɱɢɫɥɨ. ȼɬɨɪɨɣ ɨɩɟɪɚɬɨɪ ɩɪɢɫɜɚɢɜɚɧɢɹ – ɮɨɪɦɭɥɚ ɩɟɪɟɫɱɟɬɚ. Ⱦɥɹ ɨɬɪɚɠɟɧɢɹ ɪɟɡɭɥɶɬɚɬɚ ɪɚɫɱɟɬɚ ɜ ɨɤɧɟ TɆemo ɢɫɩɨɥɶɡɭɟɬɫɹ ɦɟɬɨɞ Add ɷɬɨɝɨ ɤɨɦɩɨɧɟɧɬɚ. Ɇɟɬɨɞ Add ɤɥɚɫɫɚ TStringList ɞɨɛɚɜɥɹɟɬ ɧɨɜɭɸ ɫɬɪɨɤɭ ɤ ɢɦɟɸɳɟɦɭɫɹ ɜ Lines ɧɚɛɨɪɭ ɫɬɪɨɤ. Ⱦɨɛɚɜɥɟɧɧɚɹ ɫɬɪɨɤɚ ɨɬɨɛɪɚɠɚɟɬɫɹ ɧɚ ɷɤɪɚɧɟ. ɉɚɪɚɦɟɬɪɨɦ ɦɟɬɨɞɚ ɹɜɥɹɟɬɫɹ ɫɬɪɨɤɨɜɚɹ ɩɟɪɟɦɟɧɧɚɹ. ɋɬɪɨɤɨɜɚɹ ɩɟɪɟɦɟɧɧɚɹ ɫɤɥɚɞɵɜɚɟɬɫɹ ɢɡ ɫɬɪɨɤɨɜɨɝɨ ɩɪɟɞɫɬɚɜɥɟɧɢɹ ɜɟɳɟɫɬɜɟɧɧɵɯ ɩɟɪɟɦɟɧɧɵɯ x ɢ y. Ɏɭɧɤɰɢɹ FormatFloat ɮɨɪɦɚɬɢɪɭɟɬ ɡɧɚɱɟɧɢɟ ɫ ɩɨɦɨɳɶɸ ɨɩɢɫɚɧɧɨɝɨ ɮɨɪɦɚɬɚ. 4. Ɉɫɭɳɟɫɬɜɢɬɟ ɩɪɨɝɨɧ ɩɪɨɝɪɚɦɦɵ, ɧɚɠɚɜ ɤɥɚɜɢɲɭ . ȼɜɟɞɢɬɟ ɜ ɨɤɧɨ ɪɟɞɚɤɬɨɪɚ ɥɸɛɨɟ ɱɢɫɥɨ, ɧɚɠɦɢɬɟ ɧɚ ɤɧɨɩɤɭ <ȼɜɨɞ>, ɢ ɜɵ ɩɨɥɭɱɢɬɟ ɪɟɡɭɥɶɬɚɬ ɜ ɨɤɧɟ ɦɧɨɝɨɫɬɪɨɱɧɨɝɨ ɪɟɞɚɤɬɨɪɚ. 5. Ɇɢɧɢɦɢɡɢɪɭɣɬɟ ɨɤɧɨ Delphi ɢ ɡɚɚɪɯɢɜɢɪɭɣɬɟ ɜɫɟ ɮɚɣɥɵ ɜ ɤɚɬɚɥɨɝɟ Lab_1. ȼɵ ɩɨɡɧɚɤɨɦɢɥɢɫɶ ɫɨ ɫɥɟɞɭɸɳɢɦɢ ɤɨɦɩɨɧɟɧɬɚɦɢ, ɢɯ ɦɟɬɨɞɚɦɢ ɢ ɫɜɨɣɫɬɜɚɦɢ: Ɏɨɪɦɚ (TForm), ɩɚɧɟɥɶ (TPanel), ɦɟɬɤɚ (TLabel), ɨɞɧɨɫɬɪɨɱɧɵɣ ɪɟɞɚɤɬɨɪ (TEdit), ɦɧɨɝɨɫɬɪɨɱɧɵɣ ɪɟɞɚɤɬɨɪ (TMemo), ɤɧɨɩɤɚ (TButton), ɤɧɨɩɤɚ (TBitBtn). 18
Height, Width Align Captio n Text Name Kind Lines Word Wrap Font Add
OnClic k
ɋɜɨɣɫɬɜɚ ȼɵɫɨɬɚ ɢ ɲɢɪɢɧɚ ɤɨɦɩɨɧɟɧɬɚ ɋɩɨɫɨɛ ɜɵɪɚɜɧɢɜɚɧɢɹ ɪɚɡɦɟɳɚɟɦɨɝɨ ɤɨɦɩɨɧɟɧɬɚ ɨɬɧɨɫɢɬɟɥɶɧɨ ɬɨɝɨ ɤɨɧɬɟɣɧɟɪɚ, ɜ ɤɨɬɨɪɨɦ ɨɧ ɧɚɯɨɞɢɬɫɹ Ɂɚɝɨɥɨɜɨɤ ɋɨɞɟɪɠɢɦɨɟ ɫɬɪɨɤɢ ɜɜɨɞɚ ɂɦɹ ɤɨɦɩɨɧɟɧɬɚ ɜ ɩɪɨɝɪɚɦɦɟ Ⱦɥɹ ɤɨɦɩɨɧɟɧɬɚ BitBtn ɨɩɪɟɞɟɥɹɟɬ ɬɢɩɨɜɵɟ ɮɭɧɤɰɢɢ, ɤɨɬɨɪɵɟ ɪɟɚɥɢɡɭɟɬ ɤɧɨɩɤɚ ɜ ɞɢɚɥɨɝɨɜɵɯ ɨɤɧɚɯ ɋɨɞɟɪɠɢɬ ɪɟɞɚɤɬɢɪɭɟɦɵɣ ɬɟɤɫɬ Ɋɚɡɪɟɲɚɟɬ/ɡɚɩɪɟɳɚɟɬ ɪɚɡɪɵɜ ɫɬɪɨɤɢ ɧɚ ɝɪɚɧɢɰɟ ɫɥɨɜɚ ɉɚɪɚɦɟɬɪɵ ɲɪɢɮɬɚ ɤɨɦɩɨɧɟɧɬɚ Ɇɟɬɨɞɵ Ⱦɨɛɚɜɥɹɟɬ ɧɨɜɭɸ ɫɬɪɨɤɭ ɤ ɢɦɟɸɳɟɦɭɫɹ ɜ Lines ɧɚɛɨɪɭ ɫɬɪɨɤ ɋɨɛɵɬɢɹ ɓɟɥɱɨɤ ɦɵɲɶɸ
ɑɚɫɬɶ II. ɋɬɚɧɞɚɪɬɧɵɟ ɜɢɡɭɚɥɶɧɵɟ ɤɨɦɩɨɧɟɧɬɵ 1. ɂɡɭɱɟɧɢɟ ɩɪɢɟɦɨɜ ɢɫɩɨɥɶɡɨɜɚɧɢɹ ɷɥɟɦɟɧɬɨɜ ɭɩɪɚɜɥɟɧɢɹ, ɪɚɫɩɨɥɨɠɟɧɧɵɯ ɧɚ ɩɚɧɟɥɢ Standard. ɂɡɭɱɟɧɢɟ ɫɜɨɣɫɬɜ ɢ ɦɟɬɨɞɨɜ ɷɬɢɯ ɤɨɦɩɨɧɟɧɬɨɜ ɇɚ ɩɚɧɟɥɢ Standard ɪɚɫɩɨɥɨɠɟɧɵ ɫɥɟɞɭɸɳɢɟ ɤɨɦɩɨɧɟɧɬɵ TMainMenu – ɞɥɹ ɫɨɡɞɚɧɢɹ ɢ ɨɛɫɥɭɠɢɜɚɧɢɹ ɝɥɚɜɧɨɝɨ ɦɟɧɸ ɩɪɨɝɪɚɦɦɵ. Ȼɭɞɟɬ ɪɚɫɫɦɨɬɪɟɧ ɨɬɞɟɥɶɧɨ ɜ ɡɚɧɹɬɢɢ ʋ 4. TPopupMenu – ɞɥɹ ɫɨɡɞɚɧɢɹ ɢ ɨɛɫɥɭɠɢɜɚɧɢɹ ɤɨɧɬɟɤɫɬɧɨɝɨ ɦɟɧɸ ɩɪɨɝɪɚɦɦɵ. Ȼɭɞɟɬ ɪɚɫɫɦɨɬɪɟɧ ɨɬɞɟɥɶɧɨ ɜ ɡɚɧɹɬɢɢ ʋ 4. TLabel – ɞɥɹ ɩɪɟɞɫɬɚɜɥɟɧɢɹ ɫɬɚɬɢɱɟɫɤɢɯ ɬɟɤɫɬɨɜ. ɂɫɩɨɥɶɡɭɟɬɫɹ ɞɥɹ ɩɪɟɞɫɬɚɜɥɟɧɢɹ ɩɨɹɫɧɹɸɳɢɯ ɬɟɤɫɬɨɜ. Tȿdit – ɨɞɧɨɫɬɪɨɱɧɵɣ ɪɟɞɚɤɬɨɪ, ɫ ɟɝɨ ɩɨɦɨɳɶɸ ɦɨɠɧɨ ɜɜɨɞɢɬɶ ɢ/ɢɥɢ ɨɬɨɛɪɚɠɚɬɶ ɞɨɫɬɚɬɨɱɧɨ ɞɥɢɧɧɵɟ ɬɟɤɫɬɨɜɵɟ ɫɬɪɨɤɢ. TMemo – ɦɧɨɝɨɫɬɪɨɱɧɵɣ ɪɟɞɚɤɬɨɪ, ɩɪɟɞɧɚɡɧɚɱɟɧɧɵɣ ɞɥɹ ɜɜɨɞɚ, ɪɟɞɚɤɬɢɪɨɜɚɧɢɹ ɢ/ɢɥɢ ɨɬɨɛɪɚɠɟɧɢɹ ɞɨɫɬɚɬɨɱɧɨ ɞɥɢɧɧɨɝɨ ɬɟɤɫɬɚ. TButton – ɤɧɨɩɤɚ, ɢɫɩɨɥɶɡɭɸɳɚɹɫɹ ɞɥɹ ɭɩɪɚɜɥɟɧɢɹ ɩɪɨɝɪɚɦɦɚɦɢ. TCheckBox – ɧɟɡɚɜɢɫɢɦɵɣ ɩɟɪɟɤɥɸɱɚɬɟɥɶ ɞɥɹ ɩɪɢɧɹɬɢɹ ɪɟɲɟɧɢɹ ɬɢɩɚ Ⱦɚ/ɇɟɬ. TRadioButton – ɡɚɜɢɫɢɦɵɣ ɩɟɪɟɤɥɸɱɚɬɟɥɶ, ɩɪɟɞɧɚɡɧɚɱɟɧɧɵɣ ɞɥɹ ɜɵɛɨɪɚ ɨɞɧɨɝɨ ɢɡ ɧɟɫɤɨɥɶɤɢɯ ɜɡɚɢɦɨɢɫɤɥɸɱɚɸɳɢɯ ɪɟɲɟɧɢɣ. 19
TListBox – ɫɬɚɧɞɚɪɬɧɵɣ ɫɩɢɫɨɤ ɜɵɛɨɪɚ, ɫ ɩɨɦɨɳɶɸ ɤɨɬɨɪɨɝɨ ɩɨɥɶɡɨɜɚɬɟɥɶ ɦɨɠɟɬ ɜɵɛɪɚɬɶ ɨɞɢɧ ɢɥɢ ɧɟɫɤɨɥɶɤɨ ɷɥɟɦɟɧɬɨɜ ɜɵɛɨɪɚ. TComboBox – ɤɨɦɛɢɧɢɪɨɜɚɧɧɵɣ ɫɩɢɫɨɤ ɜɵɛɨɪɚ, ɩɪɟɞɫɬɚɜɥɹɸɳɢɣ ɫɨɛɨɣ ɤɨɦɛɢɧɚɰɢɸ ɫɩɢɫɤɚ TListBox ɢ ɪɟɞɚɤɬɨɪɚ TEdit. TScrollBar – ɩɨɥɨɫɚ ɩɪɨɤɪɭɬɤɢ, ɢɫɩɨɥɶɡɭɸɳɚɹɫɹ ɞɥɹ ɜɢɡɭɚɥɶɧɨɝɨ ɭɩɪɚɜɥɟɧɢɹ ɡɧɚɱɟɧɢɟɦ ɱɢɫɥɨɜɨɣ ɜɟɥɢɱɢɧɵ. TGroupBox – ɩɪɹɦɨɭɝɨɥɶɧɨɟ ɨɤɧɨ ɫ ɪɚɦɤɨɣ ɢ ɬɟɤɫɬɨɦ ɜ ɪɚɡɪɵɜɟ ɪɚɦɤɢ. ɋɥɭɠɢɬ ɤɨɧɬɟɣɧɟɪɨɦ ɞɥɹ ɪɚɡɦɟɳɟɧɢɹ ɞɨɱɟɪɧɢɯ ɤɨɦɩɨɧɟɧɬɨɜ. TRadioGroup – ɫɩɟɰɢɚɥɶɧɵɣ ɤɨɧɬɟɣɧɟɪ, ɩɪɟɞɧɚɡɧɚɱɟɧɧɵɣ ɞɥɹ ɪɚɡɦɟɳɟɧɢɹ ɡɚɜɢɫɢɦɵɯ ɩɟɪɟɤɥɸɱɚɬɟɥɟɣ. TPanel – ɤɨɧɬɟɣɧɟɪ ɨɛɳɟɝɨ ɧɚɡɧɚɱɟɧɢɹ. 1.1.
ɉɨɞɝɨɬɨɜɢɬɟɥɶɧɵɟ ɞɟɣɫɬɜɢɹ
1. ɍɞɚɥɢɬɟ ɤɧɨɩɤɭ Button1ɫ ɩɚɧɟɥɢ Panel2. ɍɞɚɥɢɬɟ ɨɩɢɫɚɧɢɟ ɩɟɪɟɦɟɧɧɵɯ x,y ɜ ɪɚɡɞɟɥɟ ɨɩɢɫɚɧɢɹ ɩɟɪɟɦɟɧɧɵɯ var. 1.2.
ɋɩɢɫɨɤ ɜɵɛɨɪɚ ListBox1
1. ɍɫɬɚɧɨɜɢɬɟ ɧɚ ɮɨɪɦɭ ɤɨɦɩɨɧɟɧɬ ListBox1 (ɫɦ. ɪɢɫ. 3.1.2). 2. ɋɜɨɣɫɬɜɭ Items ɡɚɞɚɣɬɟ ɫɥɟɞɭɸɳɢɟ ɡɧɚɱɟɧɢɹ: Ɏɭɧɬ, ɉɭɞ, ɍɧɰɢɹ, Ⱦɪɚɯɦ, Ƚɪɚɧ. ɋɜɨɣɫɬɜɨ Items (ɤɥɚɫɫ TString) ɯɪɚɧɢɬ ɫɬɪɨɤɢ ɫɩɢɫɤɚ. 3. ɋɚɦɨɫɬɨɹɬɟɥɶɧɨ ɢɡɦɟɧɢɬɟ ɪɚɡɦɟɪ ɢ ɰɜɟɬ ɲɪɢɮɬɚ ɞɥɹ ɤɨɦɩɨɧɟɧɬɚ ListBox1. 4. ɋɨɡɞɚɣɬɟ ɨɛɪɚɛɨɬɱɢɤ ɫɨɛɵɬɢɹ OnClick ɞɥɹ ɤɨɦɩɨɧɟɧɬɚ ListBox1. ɋɨɛɵɬɢɟ OnClick ɩɪɨɢɫɯɨɞɢɬ ɩɪɢ ɜɵɛɨɪɟ ɷɥɟɦɟɧɬɚ ɜ ɫɩɢɫɤɟ. Ɉɛɪɚɛɨɬɱɢɤ ɫɨɛɵɬɢɹ. ɋɜɨɣɫɬɜɨ ItemIndex ɨɩɪɟɞɟɥɹɟɬ ɧɨɦɟɪ ɜɵɛɪɚɧɧɨɝɨ ɷɥɟɦɟɧɬɚ ɫɩɢɫɤɚ. Ɇɟɬɨɞ Clear ɨɱɢɳɚɟɬ ɫɨɞɟɪɠɢɦɨɟ ɤɨɦɩɨɧɟɧɬɚ Tȿdit. Ɇɟɬɨɞ SetFocus ɭɫɬɚɧɚɜɥɢɜɚɟɬ ɤɭɪɫɨɪ ɜ ɷɬɨɬ ɤɨɦɩɨɧɟɧɬ. procedure TForm1.ListBox1Click(Sender: TObject); begin {ȿɫɥɢ ɜ ɩɨɥɟ ɪɟɞɚɤɬɨɪɚ ɧɟ ɜɜɟɞɟɧɚ ɢɧɮɨɪɦɚɰɢɹ, ɬɨ ɪɚɫɱɟɬɚ ɧɟ ɩɪɨɢɡɜɨɞɢɬɶ} if (Edit1.Text = '') then Exit; x := StrToFloat(Edit1.Text); Case ListBox1.ItemIndex of {ȼ ɡɚɜɢɫɢɦɨɫɬɢ ɨɬ ɜɵɛɪɚɧɧɨɝɨ ɷɥɟɦɟɧɬɚ ɫɩɢɫɤɚ} 0: y := x/400; {ɪɚɫɱɟɬ ɩɪɨɢɡɜɨɞɢɬɶ ɩɨ ɪɚɡɧɵɦ ɮɨɪɦɭɥɚɦ} 1: y := x/16380; 2: y := x/28.35; 3: y := x/28.35*16; 4: y := 437.5*x/28.35; End; 20
Memo1.Lines.Add(FormatFloat('#####.##### Ƚɪɚɦɦ =',x)+ FormatFloat('#####.#####'y) + ListBox1.Items [ListBox1.ItemIndex]); Edit1.Clear; Edit1.SetFocus; end; 4. Ɉɫɭɳɟɫɬɜɢɬɟ ɩɪɨɝɨɧ ɩɪɨɝɪɚɦɦɵ ɢ ɜɵɩɨɥɧɢɬɟ ɧɟɫɤɨɥɶɤɨ ɤɨɧɬɪɨɥɶɧɵɯ ɪɚɫɱɟɬɨɜ: 1234 ɝ = 3,085 Ɏɭɧɬ 1234 ɝ = 0,07534 ɉɭɞ 1234 ɝ = 43,52734 ɍɧɰɢɹ 1234 ɝ = 696,43739 Ⱦɪɚɯɦ 1234 ɝ = 19043,20988 Ƚɪɚɧ 1.3.
123,4 ɝ = ? 12,34 ɝ = ? 1,234 ɝ = ? 0,1234 ɝ = ? 0, 01234 ɝ = ?
ɋɜɨɣɫɬɜɨ Anchors
1. ȼ ɪɚɛɨɬɚɸɳɟɦ ɩɪɢɥɨɠɟɧɢɢ ɦɚɤɫɢɦɢɡɢɪɭɣɬɟ ɨɤɧɨ. Ɉɛɪɚɬɢɬɟ ɜɧɢɦɚɧɢɟ ɧɚ ɦɟɫɬɨɩɨɥɨɠɟɧɢɟ ɤɧɨɩɤɢ ɨɬɧɨɫɢɬɟɥɶɧɨ ɥɟɜɨɝɨ ɤɪɚɹ ɮɨɪɦɵ. 2. Ɂɚɤɪɨɣɬɟ ɩɪɢɥɨɠɟɧɢɟ. ɋɞɟɥɚɟɦ ɬɚɤ, ɱɬɨɛɵ ɤɧɨɩɤɚ ɜɫɟɝɞɚ ɨɫɬɚɜɚɥɚɫɶ ɜ ɩɪɚɜɨɦ ɧɢɠɧɟɦ ɭɝɥɭ. ȼɨɫɩɨɥɶɡɭɟɦɫɹ ɫɜɨɣɫɬɜɨɦ Anchors. ɉɨ ɭɦɨɥɱɚɧɢɸ ɷɬɨ ɫɜɨɣɫɬɜɨ ɢɦɟɟɬ ɡɧɚɱɟɧɢɟ [akTop, akLeft]. ɉɪɢɫɜɨɢɦ ɷɬɨɦɭ ɫɜɨɣɫɬɜɭ ɡɧɚɱɟɧɢɟ [akRight, akBottom]. Ⱦɥɹ ɷɬɨɝɨ ɜ ɩɪɚɜɨɣ ɱɚɫɬɢ ɫɬɪɨɤɢ ɫɜɨɣɫɬɜɚ Anchors ɡɚɞɚɞɢɦ: akTop – False; akLeft – False; akRight – True; akBottom – True. 3. Ɉɫɭɳɟɫɬɜɢɬɟ ɩɪɨɝɨɧ ɩɪɨɝɪɚɦɦɵ ɢ ɩɪɨɜɟɪɶɬɟ, ɜɟɪɧɨ ɥɢ ɜɵ ɢɫɩɨɥɶɡɨɜɚɥɢ ɫɜɨɣɫɬɜɨ Anchors. 4. Ⱦɥɹ ɬɨɝɨ ɱɬɨɛɵ ɪɚɡɦɟɪ ɧɢɠɧɟɣ ɩɚɧɟɥɢ ɢɡɦɟɧɹɥɫɹ ɩɪɨɩɨɪɰɢɨɧɚɥɶɧɨ ɪɚɡɦɟɪɭ ɨɤɧɚ, ɩɪɢɫɜɨɣɬɟ ɫɜɨɣɫɬɜɭ Anchors ɡɧɚɱɟɧɢɟ [akTop, akLeft, akRight, akBottom]. Ɂɚɩɭɫɬɢɬɟ ɩɪɨɝɪɚɦɦɭ ɢ ɜɵ ɭɜɢɞɢɬɟ, ɱɬɨ ɩɪɢ ɢɡɦɟɧɟɧɢɢ ɪɚɡɦɟɪɨɜ ɨɤɧɚ Panel1 ɬɨɠɟ ɦɟɧɹɟɬ ɫɜɨɢ ɪɚɡɦɟɪɵ. 1.4. Ʉɨɦɩɨɧɟɧɬ TGroupBox 1. ɍɫɬɚɧɨɜɢɬɟ ɧɚ Panel1 ɤɨɦɩɨɧɟɧɬ TGroupBox ɢ ɡɚɞɚɣɬɟ ɫɜɨɣɫɬɜɨ Caption ɪɚɜɧɵɦ «ɇɚɫɬɪɨɣɤɚ ɪɟɞɚɤɬɨɪɚ». ɋ ɩɨɦɨɳɶɸ ɷɬɨɝɨ ɤɨɦɩɨɧɟɧɬɚ ɜɵɞɟɥɹɟɬɫɹ ɝɪɭɩɩɚ ɭɩɪɚɜɥɹɸɳɢɯ ɷɥɟɦɟɧɬɨɜ, ɨɛɴɟɞɢɧɟɧɧɵɯ ɩɨ ɮɭɧɤɰɢɨɧɚɥɶɧɨɦɭ ɧɚɡɧɚɱɟɧɢɸ. 1.5. Ʉɨɦɩɨɧɟɧɬ TɋheckBox 1. ɋɨɫɬɨɹɧɢɟ ɷɬɨɝɨ ɤɨɦɩɨɧɟɧɬɚ ɫɨɞɟɪɠɢɬ ɫɜɨɣɫɬɜɨ State: cbUnchecked – ɧɟɬ; cbChecked – ɞɚ; cbGrayed – ɧɟ ɡɧɚɸ. ɗɬɨ ɫɜɨɣɫɬɜɨ ɞɨɫɬɭɩɧɨ ɤɚɤ ɞɥɹ ɱɬɟɧɢɹ, ɬɚɤ ɢ ɞɥɹ ɡɚɩɢɫɢ. ɋɜɨɣɫɬɜɨ Checked ɫɨɞɟɪɠɢɬ ɜɵɛɨɪ ɩɨɥɶɡɨɜɚɬɟɥɹ ɬɢɩɚ Ⱦɚ/ɇɟɬ. ɍɫɬɚɧɨɜɢɬɟ ɞɜɚ ɤɨɦɩɨɧɟɧɬɚ TɋheckBox 21
ɧɚ ɤɨɧɬɟɣɧɟɪ TGroupBox. ɋɜɨɣɫɬɜɭ Caption ɡɚɞɚɣɬɟ ɡɧɚɱɟɧɢɹ ɜ ɫɨɨɬɜɟɬɫɬɜɢɢ ɫ ɪɢɫ. 3.1.2. 2. ɋɨɡɞɚɣɬɟ ɨɛɪɚɛɨɬɱɢɤɢ ɫɨɛɵɬɢɹ OnClick ɞɥɹ ɷɬɢɯ ɤɨɦɩɨɧɟɧɬɨɜ. procedure TForm1.CheckBox1Click(Sender: TObject); begin if CheckBox1.State = cbChecked then Memo1.Font.Style := [fsItalic]{ȿɫɥɢ ɩɟɪɟɤɥɸɱɚɬɟɥɶ ɪɟɞɚɤɬɨɪɚ ɭɫɬɚɧɨɜɥɟɧ, ɬɨ ɜɵɛɢɪɚɟɬɫɹ ɤɭɪɫɢɜ} else { ɲɪɢɮɬ ɩɨ ɭɦɨɥɱɚɧɢɸ} Memo1.Font.Style := []; end; { TForm1.CheckBox1Click } procedure TForm1.CheckBox2Click(Sender: TObject); begin if CheckBox2.State = cbChecked then Memo1.Font.Color := clRed else Memo1.Font.Color := clBlack; end; {TForm1.CheckBox2Click} 3. ɉɪɨɜɟɪɶɬɟ ɪɚɛɨɬɭ ɜɧɨɜɶ ɭɫɬɚɧɨɜɥɟɧɧɵɯ ɤɨɦɩɨɧɟɧɬɨɜ. 1.6. Ʉɨɦɩɨɧɟɧɬ TScrollBar 1. ɍɫɬɚɧɨɜɢɬɟ ɧɚ Panel1 ɤɨɦɩɨɧɟɧɬ TScrollBar. ɗɬɨɬ ɤɨɦɩɨɧɟɧɬ ɢɫɩɨɥɶɡɭɟɬɫɹ ɞɥɹ ɜɢɡɭɚɥɶɧɨɝɨ ɭɩɪɚɜɥɟɧɢɹ ɡɧɚɱɟɧɢɟɦ ɱɢɫɥɨɜɨɣ ɜɟɥɢɱɢɧɵ. ȿɝɨ ɫɜɨɣɫɬɜɨ Position ɫɨɞɟɪɠɢɬ ɬɟɤɭɳɟɟ ɡɧɚɱɟɧɢɟ ɱɢɫɥɨɜɨɣ ɜɟɥɢɱɢɧɵ. ɋɜɨɣɫɬɜɚ Min ɢ Max ɫɨɞɟɪɠɚɬ ɦɢɧɢɦɚɥɶɧɨɟ ɢ ɦɚɤɫɢɦɚɥɶɧɨɟ ɡɧɚɱɟɧɢɹ ɱɢɫɥɨɜɨɣ ɜɟɥɢɱɢɧɵ. 2. ɋɨɡɞɚɣɬɟ ɨɛɪɚɛɨɬɱɢɤ OnScroll ɞɥɹ ɷɬɨɝɨ ɤɨɦɩɨɧɟɧɬɚ. ɋɨɛɵɬɢɟ OnScroll ɜɨɡɧɢɤɚɟɬ ɩɪɢ ɥɸɛɨɦ ɢɡɦɟɧɟɧɢɢ ɫɜɨɣɫɬɜɚ Position. procedure TScrollCode;
TForm1.ScrollBar1Scroll(Sender:
TObject;
ScrollCode:
var ScrollPos: Integer); begin x := SCrollBar1.Position; Edit1.Text := FloatToStr(x); end; { TForm1.ScrollBar1Scroll } ȼ ɷɬɨɦ ɨɛɪɚɛɨɬɱɢɤɟ ɦɵ ɫɜɹɡɚɥɢ ɩɨɡɢɰɢɸ ɩɨɥɡɭɧɤɚ ɥɢɧɟɣɤɢ ɩɪɨɤɪɭɬɤɢ ɫ ɡɚɞɚɜɚɟɦɵɦ ɡɧɚɱɟɧɢɟɦ ɩɟɪɟɦɟɧɧɨɣ x. 22
1.7.ɋɨɛɵɬɢɟ OnActivate Ⱦɥɹ ɬɨɝɨ ɱɬɨɛɵ ɭɫɬɚɧɨɜɢɬɶ ɮɨɤɭɫ ɜɜɨɞɚ ɜ ɨɤɧɨ ɪɟɞɚɤɬɨɪɚ ɜ ɫɚɦɨɦ ɧɚɱɚɥɟ ɪɚɛɨɬɵ, ɫɨɡɞɚɞɢɦ ɟɳɟ ɨɞɢɧ ɨɛɪɚɛɨɬɱɢɤ ɫɨɛɵɬɢɹ. ɋɨɛɵɬɢɟ ɞɥɹ ɮɨɪɦɵ OnActivate ɜɨɡɧɢɤɚɟɬ ɜ ɦɨɦɟɧɬ ɚɤɬɢɜɢɡɚɰɢɢ ɨɤɧɚ (ɩɪɢ ɩɨɥɭɱɟɧɢɢ ɮɨɤɭɫɚ ɜɜɨɞɚ). procedure TForm1.FormActivate(Sender: TObject); begin Edit1.SetFocus; end; { TForm1.FormActivate }
Ɋɢɫ. 3.1.2. Ɉɤɧɨ ɩɪɨɝɪɚɦɦɵ ɩɨɫɥɟ ɟɺ ɡɚɩɭɫɤɚ ɇɨɜɵɟ ɫɜɨɣɫɬɜɚ, ɦɟɬɨɞɵ, ɫɨɛɵɬɢɹ, ɤɨɬɨɪɵɟ ɜɵ ɢɡɭɱɢɥɢ ɋɜɨɣɫɬɜɚ Items ɯɪɚɧɢɬ ɫɬɪɨɤɢ ɫɩɢɫɤɚ ItemIndex ɨɩɪɟɞɟɥɹɟɬ ɧɨɦɟɪ ɜɵɛɪɚɧɧɨɝɨ ɷɥɟɦɟɧɬɚ ɫɩɢɫɤɚ Checked ɫɨɞɟɪɠɢɬ ɜɵɛɨɪ ɩɨɥɶɡɨɜɚɬɟɥɹ ɬɢɩɚ Ⱦɚ/ɇɟɬ ɜ ɩɟɪɟɤɥɸɱɚɬɟɥɟ TCheckBox ɢ ɜ ɡɚɜɢɫɢɦɨɦ ɩɟɪɟɤɥɸɱɚɬɟɥɟ TRadioButton State ɫɨɞɟɪɠɢɬ ɫɨɫɬɨɹɧɢɟ ɤɨɦɩɨɧɟɧɬɚ: cbUnchecked – ɧɟɬ; cbChecked – ɞɚ; cbGrayed – ɧɟ ɡɧɚɸ Position, ɬɟɤɭɳɟɟ, ɦɢɧɢɦɚɥɶɧɨɟ ɢ ɦɚɤɫɢɦɚɥɶɧɨɟ ɡɧɚɱɟɧɢɹ ɱɢɫɥɨMin, Max ɜɨɣ ɜɟɥɢɱɢɧɵ ScrollBars ɨɩɪɟɞɟɥɹɟɬ ɧɚɥɢɱɢɟ ɥɢɧɟɣɤɢ ɩɪɨɤɪɭɬɤɢ Anchors ɨɩɪɟɞɟɥɹɟɬ ɫɩɨɫɨɛ ɮɢɤɫɢɪɨɜɚɧɢɹ ɞɨɱɟɪɧɟɝɨ ɤɨɦɩɨɧɟɧɬɚ ɨɬɧɨɫɢɬɟɥɶɧɨ ɝɪɚɧɢɰ ɫɜɨɟɝɨ ɪɨɞɢɬɟɥɶɫɤɨɝɨ ɤɨɦɩɨɧɟɧɬɚ Ɇɟɬɨɞɵ Clear ɨɱɢɳɚɟɬ ɫɨɞɟɪɠɢɦɨɟ ɤɨɦɩɨɧɟɧɬɚ SetFocus ɭɫɬɚɧɚɜɥɢɜɚɟɬ ɮɨɤɭɫ ɜɜɨɞɚ ɋɨɛɵɬɢɹ OnScroll ɜɨɡɧɢɤɚɟɬ ɩɪɢ ɥɸɛɨɦ ɢɡɦɟɧɟɧɢɢ ɫɜɨɣɫɬɜɚ Position ɤɨɦ23
OnActivate
ɩɨɧɟɧɬɚ TScrollBar ɜɨɡɧɢɤɚɟɬ ɞɥɹ ɮɨɪɦɵ ɜ ɦɨɦɟɧɬ ɚɤɬɢɜɢɡɚɰɢɢ ɨɤɧɚ (ɩɪɢ ɩɨɥɭɱɟɧɢɢ ɟɸ ɮɨɤɭɫɚ ɜɜɨɞɚ)
2. ɋɚɦɨɫɬɨɹɬɟɥɶɧɚɹ ɪɚɛɨɬɚ Ɂɚɞɚɧɢɟ. ɋɨɡɞɚɣɬɟ ɩɪɢɥɨɠɟɧɢɟ ɞɥɹ ɩɟɪɟɫɱɟɬɚ ɢɡ ɨɞɧɨɣ ɫɢɫɬɟɦɵ ɢɡɦɟɪɟɧɢɹ ɜ ɞɪɭɝɭɸ. ȼɵɛɨɪ ɫɢɫɬɟɦɵ ɢɡɦɟɪɟɧɢɹ ɨɫɭɳɟɫɬɜɢɬɶ ɫ ɩɨɦɨɳɶɸ ɤɨɦɩɨɧɟɧɬɚ TɋomboBox. ȼɚɪɢɚɧɬɵ 1
2
3
4
ɂɫɯɨɞɧɵɟ ɞɚɧɧɵɟ 1 ɦɦ. ɪɬ. ɫɬ. = 133 ɉɚ 1 ɞɢɧ/ɫɦ2 = 0,1ɉɚ 1 ɮɢɡ. Ⱥɬɦ = 1,013 × 105 ɉɚ 1 ɤɝɫ × ɦ2 = 9,81 ɉɚ 1 ɞɸɣɦ = 2,54 ɫɦ 1 ɹɪɞ = 0,9144 ɦ 1 ɜɟɪɫɬɚ = 500 ɫɚɠɟɧɶ 1 ɤɨɫɚɹ ɫɚɠɟɧɶ = 1,76 ɦ 1 ɛɭɲɟɥɶ = 36,37 ɞɦ3 1 ɝɚɥɥɨɧ = 4,54 ɞɦ3 1 ɩɢɧɬɚ = 0,5683 ɞɦ3 1 ɤɚɥɨɪɢɹ = 4,19 Ⱦɠ 1 ɷɪɝ = 10-7 Ⱦɠ 1 ɤɝɫ × ɦ = 9,81 Ⱦɠ 1 ɜɚɬɬ × ɱɚɫ = 3,6 × 103 Ⱦɠ
ɉɪɢ ɩɪɨɟɤɬɢɪɨɜɚɧɢɢ ɮɨɪɦɵ ɩɪɨɹɜɢɬɟ ɮɚɧɬɚɡɢɸ ɢ ɫɨɡɞɚɣɬɟ ɢɧɞɢɜɢɞɭɚɥɶɧɭɸ ɤɨɧɫɬɪɭɤɰɢɸ. ɉɪɨɝɪɚɦɦɭ ɡɚɩɢɲɢɬɟ ɜ ɩɨɞɤɚɬɚɥɨɝ Lab_2_s ɜɚɲɟɝɨ ɤɚɬɚɥɨɝɚ. 3.2. Ɉɛɪɚɛɨɬɤɚ ɢɫɤɥɸɱɢɬɟɥɶɧɵɯ ɫɢɬɭɚɰɢɣ. Ʉɨɦɩɢɥɹɰɢɹ ɢ ɨɬɥɚɞɤɚ ɩɪɨɝɪɚɦɦ ɐɟɥɶ: ɧɚɭɱɢɬɶɫɹ ɢɫɩɨɥɶɡɨɜɚɬɶ ɜ ɩɪɨɝɪɚɦɦɚɯ ɨɩɟɪɚɬɨɪ Try…Except. Ɉɡɧɚɤɨɦɢɬɶɫɹ ɫ ɨɫɧɨɜɧɵɦɢ ɫɜɨɣɫɬɜɚɦɢ ɤɨɦɩɨɧɟɧɬɚ TStringGrid. ɂɡɭɱɢɬɶ ɜɨɡɦɨɠɧɨɫɬɢ, ɩɪɟɞɨɫɬɚɜɥɹɟɦɵɟ ɢɧɬɟɝɪɢɪɨɜɚɧɧɵɦ ɨɬɥɚɞɱɢɤɨɦ. Ɋɟɡɭɥɶɬɚɬ ɨɛɭɱɟɧɢɹ: ɩɨɫɥɟ ɭɫɩɟɲɧɨɝɨ ɡɚɜɟɪɲɟɧɢɹ ɡɚɧɹɬɢɹ ɫɬɭɞɟɧɬ ɞɨɥɠɟɧ: – ɭɦɟɬɶ ɢɫɩɨɥɶɡɨɜɚɬɶ ɨɩɟɪɚɬɨɪ Try…Except ɢ ɤɨɦɩɨɧɟɧɬ TStringGrid ɜ ɩɪɨɝɪɚɦɦɚɯ; – ɭɦɟɬɶ ɭɩɪɚɜɥɹɬɶ ɜɵɩɨɥɧɟɧɢɟɦ ɩɪɨɝɪɚɦɦɵ. ɂɫɩɨɥɶɡɭɟɦɵɟ ɩɚɩɤɢ: Lab2, Lab3.
24
ɉɥɚɧ ɡɚɧɹɬɢɹ ɑɚɫɬɶ I. Ʉɨɦɩɨɧɟɧɬ TstringGrid. Ɉɛɪɚɛɨɬɤɚ ɢɫɤɥɸɱɢɬɟɥɶɧɵɯ ɫɢɬɭɚɰɢɣ. 1. Ɉɛɪɚɛɨɬɤɚ ɢɫɤɥɸɱɢɬɟɥɶɧɵɯ ɫɢɬɭɚɰɢɣ: ɪɚɛɨɬɚ ɩɨɞ ɪɭɤɨɜɨɞɫɬɜɨɦ ɩɪɟɩɨɞɚɜɚɬɟɥɹ 20 ɦɢɧɭɬ. 2. ɋɚɦɨɫɬɨɹɬɟɥɶɧɚɹ ɪɚɛɨɬɚ 60 ɦɢɧɭɬ. ɑɚɫɬɶ II. Ʉɨɦɩɢɥɹɰɢɹ ɢ ɨɬɥɚɞɤɚ ɩɪɨɝɪɚɦɦ. 1. Ʉɨɦɩɢɥɹɰɢɹ ɢ ɨɬɥɚɞɤɚ ɩɪɨɝɪɚɦɦ: ɪɚɛɨɬɚ ɩɨɞ ɪɭɤɨɜɨɞɫɬɜɨɦ ɩɪɟɩɨɞɚɜɚɬɟɥɹ 20 ɦɢɧɭɬ. 2. ɋɚɦɨɫɬɨɹɬɟɥɶɧɚɹ ɪɚɛɨɬɚ 60 ɦɢɧɭɬ. ɑɚɫɬɶ I. Ɉɛɪɚɛɨɬɤɚ ɢɫɤɥɸɱɢɬɟɥɶɧɵɯ ɫɢɬɭɚɰɢɣ 1. Ʉɨɦɩɨɧɟɧɬ TstringGrid. Ɉɛɪɚɛɨɬɤɚ ɢɫɤɥɸɱɢɬɟɥɶɧɵɯ ɫɢɬɭɚɰɢɣ Ʉɨɦɩɨɧɟɧɬ TsringGrid ɩɪɟɞɧɚɡɧɚɱɟɧ ɞɥɹ ɫɨɡɞɚɧɢɹ ɬɚɛɥɢɰ, ɜ ɹɱɟɣɤɚɯ ɤɨɬɨɪɵɯ ɪɚɫɩɨɥɚɝɚɸɬɫɹ ɩɪɨɢɡɜɨɥɶɧɵɟ ɬɟɤɫɬɨɜɵɟ ɫɬɪɨɤɢ. ɋɜɨɣɫɬɜɨ Cells[Acol,Arow] ɤɨɦɩɨɧɟɧɬɚ TstringGrid ɨɩɪɟɞɟɥɹɟɬ ɫɨɞɟɪɠɢɦɨɟ ɹɱɟɣɤɢ ɫ ɬɚɛɥɢɱɧɵɦɢ ɤɨɨɪɞɢɧɚɬɚɦɢ Acol, Arow (ɧɨɦɟɪ ɫɬɨɥɛɰɚ, ɧɨɦɟɪ ɫɬɪɨɤɢ). Ⱦɥɹ ɨɛɪɚɛɨɬɤɢ ɢɫɤɥɸɱɟɧɢɣ ɜ Object Pascal ɩɪɟɞɭɫɦɨɬɪɟɧ ɦɟɯɚɧɢɡɦ ɡɚɳɢɳɟɧɧɨɝɨ ɛɥɨɤɚ: try <ɨɩɟɪɚɬɨɪɵ> except <ɨɛɪɚɛɨɬɱɢɤɢ ɢɫɤɥɸɱɟɧɢɣ> else <ɨɩɟɪɚɬɨɪɵ> end; 1.1. ɉɨɞɝɨɬɨɜɢɬɟɥɶɧɵɟ ɞɟɣɫɬɜɢɹ ȼ ɫɜɨɟɦ ɢɧɞɢɜɢɞɭɚɥɶɧɨɦ ɤɚɬɚɥɨɝɟ ɫɨɡɞɚɣɬɟ ɤɚɬɚɥɨɝ Lab_3. 1.2. ɉɨɫɬɪɨɟɧɢɟ TstringGrid
ɩɪɢɥɨɠɟɧɢɹ
ɫ
ɢɫɩɨɥɶɡɨɜɚɧɢɟɦ
ɤɨɦɩɨɧɟɧɬɚ
ȼ ɩɪɢɥɨɠɟɧɢɢ ɪɟɲɚɟɬɫɹ ɡɚɞɚɱɚ ɩɨɞɫɱɟɬɚ ɫɪɟɞɧɟɝɨ ɛɚɥɥɚ ɤɚɠɞɨɝɨ ɫɬɭɞɟɧɬɚ. ɂɫɯɨɞɧɚɹ ɢɧɮɨɪɦɚɰɢɹ – ɨɰɟɧɤɢ ɤɚɠɞɨɝɨ ɫɬɭɞɟɧɬɚ, ɤɨɬɨɪɵɟ ɜɜɨɞɹɬɫɹ ɜ ɬɚɛɥɢɰɭ. ȼ ɩɨɫɥɟɞɧɟɦ ɫɬɨɥɛɰɟ ɬɚɛɥɢɰɵ ɨɬɪɚɠɚɟɬɫɹ ɪɟɡɭɥɶɬɚɬ ɪɚɫɱɟɬɚ – ɫɪɟɞɧɢɣ ɛɚɥɥ ɫɬɭɞɟɧɬɚ. Ɂɚɝɪɭɡɢɬɟ ɩɪɢɥɨɠɟɧɢɟ-ɩɪɢɦɟɪ. Ⱦɥɹ ɷɬɨɝɨ ɜɵɩɨɥɧɢɬɟ ɤɨɦɚɧɞɭ File/Open. ɉɪɢɥɨɠɟɧɢɟ-ɩɪɢɦɟɪ ɧɚɯɨɞɢɬɫɹ ɜ ɩɨɞɤɚɬɚɥɨɝɟ Lab2. ɉɪɢɦɟɱɚɧɢɟ: ɞɥɹ ɬɨɝɨ, ɱɬɨɛɵ ɡɚɝɪɭɡɢɬɶ ɩɪɢɥɨɠɟɧɢɟ ɧɟɨɛɯɨɞɢɦɨ ɨɬɤɪɵɬɶ ɮɚɣɥ ɩɪɨɟɤɬɚ. 1. Ɉɡɧɚɤɨɦɶɬɟɫɶ ɫ ɨɤɧɨɦ ɩɪɢɥɨɠɟɧɢɹ. 25
Ʉɨɦɩɨɧɟɧɬɵ, ɤɨɬɨɪɵɟ ɫɨɞɟɪɠɢɬ ɩɪɢɥɨɠɟɧɢɟ, ɩɟɪɟɱɢɫɥɟɧɵ ɜ ɬɚɛɥɢɰɟ. ȼ ɬɚɛɥɢɰɟ ɩɪɢɜɟɞɟɧɵ ɫɜɨɣɫɬɜɚ, ɫɤɨɪɪɟɤɬɢɪɨɜɚɧɧɵɟ ɨɬɧɨɫɢɬɟɥɶɧɨ ɡɚɞɚɧɧɵɯ ɩɨ ɭɦɨɥɱɚɧɢɸ ɪɢɫ. 3.2.1. Ʉɨɦɩɨɧɟɧɬ Panel1 BitBtn1 StringGrid1
Form1
ɋɜɨɣɫɬɜɚ Caption – ɨɱɢɫɬɢɬɶ Align – alBottom Kind – bkClose Align – alClient ColCount – 6 Rowcount – 11 DefaultColWidth – 100 Options | goEditing – True. (ȼ ɷɬɨɦ ɫɥɭɱɚɟ ɪɚɡɪɟɲɟɧɨ ɪɟɞɚɤɬɢɪɨɜɚɧɢɟ ɹɱɟɣɤɢ) Caption – ɥɚɛɨɪɚɬɨɪɧɚɹ ɪɚɛɨɬɚ ʋ 2
Ɋɢɫ. 3.2.1. Ɏɨɪɦɚ ɩɪɨɟɤɬɢɪɭɟɦɨɣ ɩɪɨɝɪɚɦɦɵ 2. Ɉɡɧɚɤɨɦɶɬɟɫɶ ɫ ɩɪɨɝɪɚɦɦɨɣ. ȼ ɩɪɨɝɪɚɦɦɟ ɢɫɩɨɥɶɡɭɟɬɫɹ ɫɨɛɵɬɢɟ ɤɨɦɩɨɧɟɧɬɚ StringGrid1 OnSetEditText (Sender: Tobject; Acol, Arow: LongInt; Const Value: String). ɗɬɨ ɫɨɛɵɬɢɟ ɜɨɡɧɢɤɚɟɬ ɩɪɢ ɡɚɜɟɪɲɟɧɢɢ ɪɟɞɚɤɬɢɪɨɜɚɧɢɹ ɹɱɟɣɤɢ (Aɫol, Arow). ȼ ɩɚɪɚɦɟɬɪɟ Value ɨɛɪɚɛɨɬɱɢɤ ɩɨɥɭɱɚɟɬ ɪɟɡɭɥɶɬɚɬ ɜɜɨɞɚ ɢɥɢ ɪɟɞɚɤɬɢɪɨɜɚɧɢɹ ɬɟɤɫɬɚ. ɂɫɩɨɥɶɡɨɜɚɧɧɨɟ ɜ ɩɪɨɝɪɚɦɦɟ ɫɜɨɣɫɬɜɨ ɤɨɦɩɨɧɟɧɬɚ TstringGrid Cells (Acol, Arow) ɨɩɪɟɞɟɥɹɟɬ ɫɨɞɟɪɠɢɦɨɟ ɹɱɟɣɤɢ ɫ ɬɚɛɥɢɱɧɵɦɢ ɤɨɨɪɞɢɧɚɬɚɦɢ (Acol, Arow). Ɉɛɪɚɬɢɬɟ ɜɧɢɦɚɧɢɟ, ɧɚ ɩɟɪɜɨɦ ɦɟɫɬɟ ɫɬɨɢɬ ɧɨɦɟɪ ɫɬɨɥɛɰɚ, ɧɚ ɜɬɨɪɨɦ ɦɟɫɬɟ – ɧɨɦɟɪ ɫɬɪɨɤɢ. ȼ ɉɚɫɤɚɥɟ ɦɵ ɩɪɢɜɵɤɥɢ, ɱɬɨ ɧɚ ɩɟɪɜɨɦ ɦɟɫɬɟ ɫɬɨɢɬ ɧɨɦɟɪ ɫɬɪɨɤɢ. Ɇɚɫɫɢɜ Ⱥ ɹɜɥɹɟɬɫɹ ɬɪɚɧɫɩɨɪɬɢɪɨɜɚɧɧɵɦ ɩɨ ɨɬɧɨɲɟɧɢɸ ɤ ɦɚɫɫɢɜɭ Cells. Ʌɢɫɬɢɧɝ ɩɪɨɝɪɚɦɦɵ: unit Unit1; { 26
ɇɚɡɧɚɱɟɧɢɟ: ɉɨɞɫɱɟɬ ɫɪɟɞɧɟɝɨ ɛɚɥɥɚ ɤɚɠɞɨɝɨ ɫɬɭɞɟɧɬɚ ȼɯɨɞɧɵɟ ɞɚɧɧɵɟ: Ɉɰɟɧɤɢ ɤɚɠɞɨɝɨ ɫɬɭɞɟɧɬɚ ȼɵɯɨɞɧɵɟ ɞɚɧɧɵɟ: ɋɪɟɞɧɢɟ ɨɰɟɧɤɢ ɫɬɭɞɟɧɬɨɜ } interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, ExtCtrls, StdCtrls, Buttons, Grids; type TForm1 = class(TForm) Panel1: TPanel; StringGrid1: TStringGrid; BitBtn1: TBitBtn; procedure FormActivate(Sender: TObject); procedure StringGrid1SetEditText(Sender: TObject; ACol, ARow: Integer; const Value: String); private { Private declarations } public { Public declarations } end; const nn = 10; //Ɇɚɤɫɢɦɚɥɶɧɨɟ ɤɨɥɢɱɟɫɬɜɨ ɭɱɟɧɢɤɨɜ = 10 mm = 5; //Ɇɚɤɫɢɦɚɥɶɧɨɟ ɤɨɥɢɱɟɫɬɜɨ ɷɤɡɚɦɟɧɨɜ = 5 var Form1: TForm1; a : array [1..nn, 1..mm] of Real; //a - ɦɚɫɫɢɜ ɨɰɟɧɨɤ ss : array [1..nn] of Real; //ss - ɦɚɫɫɢɜ ɞɥɹ ɫɪɟɞɧɟɝɨ ɛɚɥɥɚ ɭɱɟɧɢɤɨɜ implementation {$R *.dfm} procedure TForm1.FormActivate(Sender: TObject); var i : integer; begin stringGrid1.Cells[0,0] := 'ɇɨɦɟɪ ɫɬɭɞɟɧɬɚ'; for i:=1 to 10 do stringGrid1.Cells[0,i]:='ʋ '+IntToStr(i); for i:=1 to 4 do stringGrid1.Cells[i,0]:='Ɉɰɟɧɤɚ ʋ'+IntToStr(i); stringGrid1.Cells[5,0]:='ɋɪɟɞɧɹɹ ɨɰɟɧɤɚ' end; { TForm1.FormActivate } procedure TForm1.StringGrid1SetEditText(Sender: TObject; ACol, ARow: 27
Integer; const Value: String); var B : integer; //b -ɰɟɥɨɟ ɡɧɚɱɟɧɢɟ ɫɬɪɨɤɢ ɪɟɞɚɤɬɢɪɨɜɚɧɢɹ j : byte; //j - ɩɚɪɚɦɟɬɪ ɰɢɤɥɚ ɞɥɹ ɬɟɤɭɳɟɝɨ ɧɨɦɟɪɚ ɫɬɨɥɛɰɚ ɦɚɬɪɢɰɵ ɚ begin with StringGrid1 do begin if Value = '' then Exit; //ȿɫɥɢ ɧɢɱɟɝɨ ɧɟ ɜɜɟɞɟɧɨ, ɬɨ ɜɵɯɨɞ ɢɡ ɩɪɨɰɟɞɭɪɵ
//ɇɚɱɚɥɨ ɡɚɳɢɳɟɧɧɨɝɨ ɛɥɨɤɚ try b := StrToInt(Value) except ShowMessage('ɇɟ ɜɟɪɧɵɣ ɫɢɦɜɨɥ!'); b:=0 end; //Ʉɨɧɟɰ ɡɚɳɢɳɟɧɧɨɝɨ ɛɥɨɤɚ. // ɂɝɧɨɪɢɪɨɜɚɬɶ ɧɟɜɟɪɧɨ ɜɜɟɞɟɧɧɭɸ ɨɰɟɧɤɭ if (b<1) or (b>5) then begin Cells[Acol,Arow] :=''; Exit; end; Cells[Acol,Arow] := Value; //Ɉɬɪɚɡɢɬɶ ɨɰɟɧɤɭ ɜ ɬɚɛɥɢɰɟ A[arow,Acol] := b; //Ɂɚɩɢɫɚɬɶ ɨɰɟɧɤɭ ɜ ɦɚɫɫɢɜ //Ⱦɚɥɟɟ ɩɨɞɫɱɟɬ ɫɪɟɞɧɟɝɨ ɛɚɥɥɚ. SS[Arow] := 0; k :=0; //ɋɱɟɬɱɢɤ ɱɢɫɥɚ ɜɜɟɞɟɧɧɵɯ ɨɰɟɧɨɤ for j:=1 To 4 Do begin SS[Arow] := SS[Arow]+a[Arow,j]; if StringGrid1.Cells[j,Arow]<>'' then k:=k+1; end; if k<>0 then SS[Arow] := SS[Arow]/k else SS[Arow]:=0; //Ɉɬɨɛɪɚɡɢɬɶ ɫɪɟɞɧɢɣ ɛɚɥɥ ɜ 5-ɨɦ ɫɬɨɥɛɰɟ ɬɚɛɥɢɰɵ. Cells[5, Arow] := FormatFloat('##.##', SS[Arow]) end; end;{ TForm1.StringGrid1SetEditText } end. Ɉɤɧɨ ɪɚɛɨɬɚɸɳɟɣ ɩɪɨɝɪɚɦɦɵ ɩɪɟɞɫɬɚɜɥɟɧɨ ɧɚ ɪɢɫ. 3.2.2. 28
ɚ) ɛ) Ɋɢɫ. 3.2.2. Ɏɨɪɦɚ ɩɪɨɟɤɬɢɪɭɟɦɨɣ ɩɪɨɝɪɚɦɦɵ: ɚ – ɨɫɧɨɜɧɨɟ ɦɟɧɸ; ɛ – ɫɨɨɛɳɟɧɢɟ «ɇɟɜɟɪɧɵɣ ɫɢɦɜɨɥ» 1.3. Ɇɟɯɚɧɢɡɦ ɡɚɳɢɳɟɧɧɨɝɨ ɛɥɨɤɚ 1. ɉɪɢ ɤɚɠɞɨɣ ɢɫɤɥɸɱɢɬɟɥɶɧɨɣ ɫɢɬɭɚɰɢɢ ɫɪɟɞɚ Delphi ɩɟɪɟɯɜɚɬɵɜɚɟɬ ɭɩɪɚɜɥɟɧɢɟ ɩɪɨɝɪɚɦɦɨɣ. Ⱦɥɹ ɬɨɝɨ ɱɬɨɛɵ ɫɚɦɨɦɭ ɭɩɪɚɜɥɹɬɶ ɢɫɤɥɸɱɢɬɟɥɶɧɨɣ ɫɢɬɭɚɰɢɟɣ, ɧɟɨɛɯɨɞɢɦɨ ɨɬɦɟɧɢɬɶ ɬɚɤɨɟ ɩɨɜɟɞɟɧɢɟ ɫɪɟɞɵ. Ⱦɥɹ ɷɬɨɝɨ ɜɵɡɨɜɢɬɟ ɨɩɰɢɸ Tools/Debugger ɢ ɧɚ ɫɬɪɚɧɢɰɟ Language Exceptions ɭɛɟɪɢɬɟ ɜɵɛɨɪ ɜ ɩɟɪɟɤɥɸɱɚɬɟɥɟ Stop on Delphi Exceptions. 2. ȼ ɩɪɨɝɪɚɦɦɟ ɢɫɩɨɥɶɡɭɟɬɫɹ ɦɟɯɚɧɢɡɦ ɡɚɳɢɳɟɧɧɨɝɨ ɛɥɨɤɚ. ȿɫɥɢ ɜ ɹɱɟɣɤɭ ɜɜɨɞɢɬɫɹ ɤɚɤɨɣ-ɥɢɛɨ ɫɢɦɜɨɥ ɤɪɨɦɟ ɰɢɮɪɵ ɢ ɞɟɫɹɬɢɱɧɨɣ ɬɨɱɤɢ, ɬɨ ɧɚ ɷɤɪɚɧ ɜɵɜɨɞɢɬɫɹ ɫɨɨɛɳɟɧɢɟ: «ɇɟɜɟɪɧɵɣ ɫɢɦɜɨɥ!» ɪɢɫ. 3.2.2ɛ. ɇɨɜɵɟ ɤɨɦɩɨɧɟɧɬɵ, ɫɜɨɣɫɬɜɚ, ɫɨɛɵɬɢɹ TstringGrid ColCount RowCount DefaultColWidt h Cells[ACol, ARow] Options/goEditin g OnSetEditText
Ʉɨɥɢɱɟɫɬɜɨ ɫɬɨɥɛɰɨɜ ɬɚɛɥɢɰɵ Ʉɨɥɢɱɟɫɬɜɨ ɫɬɪɨɤ ɬɚɛɥɢɰɵ ɒɢɪɢɧɚ ɫɬɨɥɛɰɚ ɬɚɛɥɢɰɵ Ɉɩɪɟɞɟɥɹɟɬ ɫɨɞɟɪɠɢɦɨɟ ɹɱɟɣɤɢ ɫ ɬɚɛɥɢɱɧɵɦɢ ɤɨɨɪɞɢɧɚɬɚɦɢ (ACol, ARow) Ɂɚɞɚɧɨ True. ȼ ɷɬɨɦ ɫɥɭɱɚɟ ɪɚɡɪɟɲɟɧɨ ɪɟɞɚɤɬɢɪɨɜɚɧɢɟ ɹɱɟɣɤɢ ɋɨɛɵɬɢɹ ȼɨɡɧɢɤɚɟɬ ɩɪɢ ɡɚɜɟɪɲɟɧɢɢ ɪɟɞɚɤɬɢɪɨɜɚɧɢɹ ɹɱɟɣɤɢ (Aɋol, ARow). ȼ ɩɚɪɚɦɟɬɪɟ Value ɨɛɪɚɛɨɬɱɢɤ ɩɨɥɭɱɚɟɬ ɪɟɡɭɥɶɬɚɬ ɜɜɨɞɚ ɢɥɢ ɪɟɞɚɤɬɢɪɨɜɚɧɢɹ ɬɟɤɫɬɚ
3. ȼɵɡɨɜɢɬɟ ɩɭɧɤɬ ɦɟɧɸ File| Save project as ɢ ɫɨɯɪɚɧɢɬɟ ɦɨɞɭɥɶ ɤɚɤ U2, ɩɪɨɟɤɬ ɤɚɤ Project2 ɜ ɤɚɬɚɥɨɝ Lab_2. 29
2. ɋɚɦɨɫɬɨɹɬɟɥɶɧɚɹ ɪɚɛɨɬɚ Ɂɚɞɚɧɢɟ.
ȼɚɪɢɚɧɬɵ
1
2
3
4
5
ɋɨɡɞɚɣɬɟ ɩɪɢɥɨɠɟɧɢɟ ɫ ɢɫɩɨɥɶɡɨɜɚɧɢɟɦ ɤɨɦɩɨɧɟɧɬɚ TStringGrid. ȼ ɩɪɨɝɪɚɦɦɟ ɧɚɣɞɢɬɟ ɩɪɢɦɟɧɟɧɢɟ ɦɟɯɚɧɢɡɦɭ ɡɚɳɢɳɟɧɧɨɝɨ ɛɥɨɤɚ. ɂɫɯɨɞɧɵɟ ɞɚɧɧɵɟ Ɋɚɡɪɚɛɨɬɚɬɶ ɩɪɢɥɨɠɟɧɢɟ ɞɥɹ ɨɛɪɚɛɨɬɤɢ ɪɟɡɭɥɶɬɚɬɨɜ ɫɨɪɟɜɧɨɜɚɧɢɣ. ɂɫɯɨɞɧɵɟ ɞɚɧɧɵɟ: ɜɪɟɦɹ ɫɬɚɪɬɚ, ɜɪɟɦɹ ɮɢɧɢɲɚ, ɤɨɧɬɪɨɥɶɧɨɟ ɜɪɟɦɹ. Ɉɬɦɟɬɢɬɶ ɬɟ ɪɟɡɭɥɶɬɚɬɵ, ɤɨɬɨɪɵɟ ɭɤɥɚɞɵɜɚɸɬɫɹ ɜ ɤɨɧɬɪɨɥɶɧɨɟ ɜɪɟɦɹ. ȼɪɟɦɹ ɫɬɚɪɬɚ ɢ ɜɪɟɦɹ ɮɢɧɢɲɚ ɜɜɨɞɢɬɶ ɜ ɬɚɛɥɢɰɭ. Ɉɬɦɟɬɢɬɶ ɫɩɨɪɬɫɦɟɧɨɜ, ɭɥɨɠɢɜɲɢɯɫɹ ɜ ɤɨɧɬɪɨɥɶɧɨɟ ɜɪɟɦɹ, ɫɩɟɰɢɚɥɶɧɵɦ ɫɢɦɜɨɥɨɦ ɢɥɢ ɫɨɨɛɳɟɧɢɟɦ «ɇɨɪɦɚ ɜɵɩɨɥɧɟɧɚ» ɜ ɫɜɨɛɨɞɧɨɦ ɫɬɨɥɛɰɟ ɬɚɛɥɢɰɵ ɋ ɩɨɦɨɳɶɸ ɬɚɛɥɢɰɵ TStringGrid ɜɜɟɫɬɢ ɷɥɟɦɟɧɬɵ ɦɚɬɪɢɰɵ ɢ ɩɨɞɫɱɢɬɚɬɶ ɫɭɦɦɭ ɤɜɚɞɪɚɬɨɜ ɟɝɨ ɫɬɨɥɛɰɨɜ Ɋɚɫɫɱɢɬɚɬɶ ɫɪɟɞɧɢɟ ɩɚɪɚɦɟɬɪɵ ɝɪɭɩɩɵ ɫɬɭɞɟɧɬɨɜ. ɂɫɯɨɞɧɵɟ ɞɚɧɧɵɟ: ɤɨɥɢɱɟɫɬɜɨ ɛɚɥɥɨɜ, ɧɚɛɪɚɧɧɵɯ ɤɚɠɞɵɦ ɫɬɭɞɟɧɬɨɦ ɩɪɢ ɬɟɫɬɢɪɨɜɚɧɢɢ; ɪɨɫɬ ɢ ɜɟɫ ɤɚɠɞɨɝɨ ɫɬɭɞɟɧɬɚ. Ɋɚɫɫɱɢɬɚɬɶ ɫɪɟɞɧɢɣ ɛɚɥɥ, ɫɪɟɞɧɢɣ ɜɟɫ ɢ ɫɪɟɞɧɢɣ ɪɨɫɬ ɫɬɭɞɟɧɬɨɜ ɜ ɝɪɭɩɩɟ. ȼ ɩɪɢɥɨɠɟɧɢɢ ɢɫɩɨɥɶɡɨɜɚɬɶ ɬɚɛɥɢɰɭ TStringGrid ɞɥɹ ɜɜɨɞɚ ɢ ɜɵɜɨɞɚ ɢɧɮɨɪɦɚɰɢɢ ɉɪɟɞɫɬɚɜɢɬɶ ɜ ɜɢɞɟ ɬɚɛɥɢɰɵ ɢɬɨɝɢ ɞɟɹɬɟɥɶɧɨɫɬɢ ɱɟɬɵɪɟɯ ɚɝɟɧɬɨɜ ɮɢɪɦɵ ɩɨ ɫɛɵɬɭ n-ɨɣ ɩɪɨɞɭɤɰɢɢ. ɂɫɯɨɞɧɨɣ ɢɧɮɨɪɦɚɰɢɟɣ ɫɱɢɬɚɬɶ ɨɛɴɟɦ ɩɪɨɞɚɠ ɩɨ ɤɜɚɪɬɚɥɚɦ. Ɋɚɫɫɱɢɬɚɬɶ ɨɛɴɟɦ ɩɪɨɞɚɠ ɤɚɠɞɨɝɨ ɚɝɟɧɬɚ ɡɚ ɝɨɞ ɉɪɟɞɫɬɚɜɢɬɶ ɜ ɜɢɞɟ ɬɚɛɥɢɰɵ ɜɟɞɨɦɨɫɬɶ ɫɜɟɞɟɧɢɣ ɨ ɩɪɨɩɭɫɤɚɯ ɡɚɧɹɬɢɣ ɫɬɭɞɟɧɬɚɦɢ. ɂɫɯɨɞɧɨɣ ɢɧɮɨɪɦɚɰɢɟɣ ɹɜɥɹɟɬɫɹ: ɤɨɥɢɱɟɫɬɜɨ ɱɚɫɨɜ, ɩɪɨɩɭɳɟɧɧɵɯ ɩɨ ɭɜɚɠɢɬɟɥɶɧɨɣ ɢ ɧɟɭɜɚɠɢɬɟɥɶɧɨɣ ɩɪɢɱɢɧɟ. Ⱦɥɹ ɜɜɨɞɚ ɢ ɯɪɚɧɟɧɢɹ ɢɧɮɨɪɦɚɰɢɢ ɢɫɩɨɥɶɡɨɜɚɬɶ ɬɚɛɥɢɰɭ TStringGrid. ɋɬɭɞɟɧɬɨɜ, ɩɪɨɩɭɫɬɢɜɲɢɯ ɛɨɥɟɟ ɏɏɏ ɱɚɫɨɜ ɩɨ ɧɟɭɜɚɠɢɬɟɥɶɧɨɣ ɩɪɢɱɢɧɟ, ɨɬɦɟɬɢɬɶ ɜ ɫɜɨɛɨɞɧɨɦ ɫɬɨɥɛɰɟ ɬɚɛɥɢɰɵ ɫɩɟɰɢɚɥɶɧɵɦ ɫɨɨɛɳɟɧɢɟɦ. ɏɏɏ – ɜɜɨɞɢɦɚɹ ɜɟɥɢɱɢɧɚ
ɑɚɫɬɶ II. Ʉɨɦɩɢɥɹɰɢɹ ɢ ɨɬɥɚɞɤɚ ɩɪɨɝɪɚɦɦ 1. Ʉɨɦɩɢɥɹɰɢɹ ɢ ɨɬɥɚɞɤɚ ɩɪɨɝɪɚɦɦ Ⱦɥɹ ɭɩɪɚɜɥɟɧɢɹ ɜɵɩɨɥɧɟɧɢɟɦ ɩɪɨɝɪɚɦɦɵ ɢɫɩɨɥɶɡɭɸɬɫɹ ɫɥɟɞɭɸɳɢɟ ɤɨɦɚɧɞɵ ɩɭɧɤɬɚ ɦɟɧɸ Run. Ʉɨɦɚɧɞɚ Ɉɩɢɫɚɧɢɟ ɉɪɨɝɪɚɦɦɚ ɜɵɩɨɥɧɹɟɬɫɹ ɛɟɡ ɨɫɬɚɧɨɜɤɢ ɧɚ ɤɚɠɞɨɣ ɫɬɪɨɤɟ. Run (F9) ɗɬɚ ɤɨɦɚɧɞɚ ɷɤɜɢɜɚɥɟɧɬɧɚ ɜɵɩɨɥɧɟɧɢɸ ɩɪɨɝɪɚɦɦɵ ɜɧɟ ɨɬ30
ɥɚɞɱɢɤɚ Step Over (F8) ɉɪɨɝɪɚɦɦɚ ɜɵɩɨɥɧɹɟɬɫɹ ɩɨɫɬɪɨɱɧɨ. ɉɨɞɩɪɨɝɪɚɦɦɵ ɜɵɩɨɥ-
ɧɹɸɬɫɹ ɤɚɤ ɨɞɧɚ ɫɬɪɨɤɚ Trance (F7)
Into ɉɪɨɝɪɚɦɦɚ ɜɵɩɨɥɧɹɟɬɫɹ ɩɨɫɬɪɨɱɧɨ. Ɍɚɤɠɟ ɜɵɩɨɥɧɹɟɬɫɹ
ɤɚɠɞɚɹ ɫɬɪɨɤɚ ɩɨɞɩɪɨɝɪɚɦɦɵ
Run To Cursor ɉɪɨɝɪɚɦɦɚ ɜɵɩɨɥɧɹɟɬɫɹ ɞɨ ɬɨɣ ɫɬɪɨɤɢ, ɧɚ ɤɨɬɨɪɨɣ ɧɚɯɨ(F4) ɞɢɬɫɹ ɤɭɪɫɨɪ ɜ ɨɤɧɟ Code Editor Program Pause Program Reset (Ctrl F2) Add Breakpoint
ȼɵɩɨɥɧɟɧɢɟ ɩɪɨɝɪɚɦɦɵ ɩɪɢɨɫɬɚɧɚɜɥɢɜɚɟɬɫɹ ȼɵɩɨɥɧɟɧɢɟ ɩɪɨɝɪɚɦɦɵ ɡɚɜɟɪɲɚɟɬɫɹ Ɇɨɠɧɨ ɭɤɚɡɚɬɶ ɬɨɱɤɢ ɩɪɟɪɵɜɚɧɢɹ ɩɪɢ ɜɵɩɨɥɧɟɧɢɢ ɩɪɨɝɪɚɦɦɵ
Ɍɨɱɤɚ ɤɨɧɬɪɨɥɶɧɨɝɨ ɨɫɬɚɧɨɜɚ ɨɩɪɟɞɟɥɹɟɬ ɨɩɟɪɚɬɨɪ ɜ ɩɪɨɝɪɚɦɦɟ, ɩɟɪɟɞ ɜɵɩɨɥɧɟɧɢɟɦ ɤɨɬɨɪɨɝɨ ɩɪɨɝɪɚɦɦɚ ɩɪɟɪɜɟɬ ɪɚɛɨɬɭ, ɢ ɭɩɪɚɜɥɟɧɢɟ ɛɭɞɟɬ ɩɟɪɟɞɚɧɨ ɫɪɟɞɟ Delphi. Ɍɨɱɤɚ ɨɫɬɚɧɨɜɚ ɡɚɞɚɟɬɫɹ ɫ ɩɨɦɨɳɶɸ ɨɩɰɢɢ View/Debug Windows/Breakpoints. Ʌɟɝɱɟ ɩɪɨɫɬɨ ɳɟɥɤɧɭɬɶ ɥɟɜɨɣ ɤɧɨɩɤɨɣ ɦɵɲɢ ɜ ɥɟɜɨɦ ɭɝɥɭ ɫɬɪɨɤɢ, ɧɚ ɤɨɬɨɪɨɣ ȼɵ ɯɨɬɢɬɟ ɭɫɬɚɧɨɜɢɬɶ ɬɨɱɤɭ ɩɪɟɪɵɜɚɧɢɹ. ɇɚɛɥɸɞɚɬɶ ɡɚ ɫɨɫɬɨɹɧɢɟɦ ɩɟɪɟɦɟɧɧɨɣ ɢɥɢ ɜɵɪɚɠɟɧɢɹ ɦɨɠɧɨ ɫ ɩɨɦɨɳɶɸ ɫɩɟɰɢɚɥɶɧɨɝɨ ɨɤɧɚ, ɜɵɡɵɜɚɟɦɨɝɨ ɨɩɰɢɟɣ View/Debug windows/Watches. ɂɡɦɟɧɢɬɶ ɬɟɤɭɳɟɟ ɡɧɚɱɟɧɢɟ ɩɟɪɟɦɟɧɧɨɣ ɦɨɠɧɨ ɫ ɩɨɦɨɳɶɸ ɨɤɧɚ Evaluate/Modify, ɜɵɡɵɜɚɟɦɨɝɨ ɧɚɠɚɬɢɟɦ . ȼ ɫɬɪɨɤɟ Expression ɫɥɟɞɭɟɬ ɧɚɩɢɫɚɬɶ ɢɦɹ ɩɟɪɟɦɟɧɧɨɣ, ɧɚɠɚɬɶ ɤɧɨɩɤɭ Modify ɢ ɜɜɟɫɬɢ ɧɨɜɨɟ ɡɧɚɱɟɧɢɟ ɜ ɫɬɪɨɤɟ New Value. ɉɨɞɝɨɬɨɜɢɬɟɥɶɧɵɟ ɞɟɣɫɬɜɢɹ ȼ ɫɜɨɟɦ ɤɚɬɚɥɨɝɟ ɫɨɡɞɚɣɬɟ ɤɚɬɚɥɨɝ Lab_3. 1.2. Ɇɨɞɢɮɢɤɚɰɢɹ ɡɚɞɚɱɢ ɉɪɟɠɞɟ, ɱɟɦ ɢɡɭɱɚɬɶ ɤɨɦɚɧɞɵ ɜɵɩɨɥɧɟɧɢɹ ɢ ɨɬɥɚɞɤɢ ɩɪɨɝɪɚɦɦɵ, ɭɫɥɨɠɧɢɦ ɩɪɟɞɵɞɭɳɢɣ ɩɪɢɦɟɪ. Ɂɚɝɪɭɡɢɬɟ ɩɪɢɥɨɠɟɧɢɟ-ɩɪɢɦɟɪ. Ⱦɥɹ ɷɬɨɝɨ ɜɵɩɨɥɧɢɬɟ ɤɨɦɚɧɞɭ File/Open. ɉɪɢɥɨɠɟɧɢɟ–ɩɪɢɦɟɪ ɧɚɯɨɞɢɬɫɹ Lab3. ȼ ɩɪɢɥɨɠɟɧɢɢ ɪɟɲɚɟɬɫɹ ɡɚɞɚɱɚ ɩɨɞɫɱɟɬɚ ɫɪɟɞɧɟɝɨ ɛɚɥɥɚ ɤɚɠɞɨɝɨ ɫɬɭɞɟɧɬɚ, ɨɬɞɟɥɶɧɨ ɫɪɟɞɧɟɝɨ ɛɚɥɥɚ ɦɚɥɶɱɢɤɨɜ ɢ ɞɟɜɨɱɟɤ, ɨɛɳɟɝɨ ɫɪɟɞɧɟɝɨ ɛɚɥɥɚ. ɂɫɯɨɞɧɨɣ ɢɧɮɨɪɦɚɰɢɟɣ ɹɜɥɹɟɬɫɹ: ɮɚɦɢɥɢɹ, ɩɨɥ, ɨɰɟɧɤɢ ɤɚɠɞɨɝɨ ɫɬɭɞɟɧɬɚ. Ɏɚɦɢɥɢɹ ɜɜɨɞɢɬɫɹ ɜ ɨɤɧɟ ɨɞɧɨɫɬɪɨɱɧɨɝɨ ɪɟɞɚɤɬɨɪɚ. ɉɨɥ ɡɚɞɚɟɬɫɹ ɫ ɩɨɦɨɳɶɸ ɤɨɦɩɨɧɟɧɬɚ TRadioGroup. Ɉɰɟɧɤɢ ɜɜɨɞɹɬɫɹ ɜ ɬɚɛɥɢɰɭ. ɉɪɢɡɧɚɤ ɪɚɫɱɟɬɚ ɡɚɞɚɟɬɫɹ ɫ ɩɨɦɨɳɶɸ ɤɨɦɩɨɧɟɧɬɚ TRadioGroup. 1. Ɉɡɧɚɤɨɦɶɬɟɫɶ ɫ ɨɤɧɨɦ ɩɪɢɥɨɠɟɧɢɹ. 31
Ʉɨɦɩɨɧɟɧɬɵ, ɤɨɬɨɪɵɟ ɫɨɞɟɪɠɢɬ ɩɪɢɥɨɠɟɧɢɟ, ɩɟɪɟɱɢɫɥɟɧɵ ɜ ɬɚɛɥɢɰɟ. ȼ ɬɚɛɥɢɰɟ ɩɪɢɜɟɞɟɧɵ ɫɜɨɣɫɬɜɚ, ɫɤɨɪɪɟɤɬɢɪɨɜɚɧɧɵɟ ɨɬɧɨɫɢɬɟɥɶɧɨ ɡɚɞɚɧɧɵɯ ɩɨ ɭɦɨɥɱɚɧɢɸ. Ʉɨɦɩɨɧɟɧɬ Panel1 Edit1, Edit2 Label1 Label2 RadioGroup1
RadioGroup2
BitBtn1 BitBtn2 StringGrid1
Form1
ɋɜɨɣɫɬɜɚ Caption – ɨɱɢɫɬɢɬɶ Align – alBottom Text – ɨɱɢɫɬɢɬɶ Caption – ɮɚɦɢɥɢɹ Caption – ɪɟɡɭɥɶɬɚɬ Caption – ɩɨɥ ItemIndex – 0 Items – ɦɭɠɫɤ., ɠɟɧɫɤ. Items – ɫɪɟɞɧɢɣ ɛɚɥɥ ɦɚɥɶɱɢɤɨɜ, ɫɪɟɞɧɢɣ ɛɚɥɥ ɞɟɜɨɱɟɤ, ɨɛɳɢɣ ɫɪɟɞɧɢɣ ɛɚɥɥ Caption – ɩɪɢɡɧɚɤ ɪɚɫɱɟɬɚ Caption – ɡɚɩɢɫɚɬɶ Kind – bkOK Kind – bkClose Align – alClient ColCount – 6 RowCount – 11 DefaultColWidth – 100 Options | goEditing – True Caption – ɥɚɛɨɪɚɬɨɪɧɚɹ ɪɚɛɨɬɚ ʋ 3
2. Ɉɡɧɚɤɨɦɶɬɟɫɶ ɫ ɩɪɨɝɪɚɦɦɨɣ. unit Unit1; { ɇɚɡɧɚɱɟɧɢɟ: ɉɨɞɫɱɟɬ ɫɪɟɞɧɟɝɨ ɛɚɥɥɚ ɤɚɠɞɨɝɨ ɫɬɭɞɟɧɬɚ ȼɯɨɞɧɵɟ ɞɚɧɧɵɟ: Ɉɰɟɧɤɢ ɤɚɠɞɨɝɨ ɫɬɭɞɟɧɬɚ ȼɵɯɨɞɧɵɟ ɞɚɧɧɵɟ: ɋɪɟɞɧɢɟ ɨɰɟɧɤɢ ɫɬɭɞɟɧɬɨɜ } interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, ExtCtrls, StdCtrls, Buttons, Grids; type TForm1 = class(TForm) Panel1: TPanel; StringGrid1: TStringGrid; BitBtn2: TBitBtn; Edit1: TEdit; Label1: TLabel; 32
RadioGroup1: TRadioGroup; RadioGroup2: TRadioGroup; BitBtn1: TBitBtn; Label2: TLabel; Edit2: TEdit; procedure StringGrid1SetEditText(Sender: TObject; ACol, ARow: Integer; const Value: String); procedure FormActivate(Sender: TObject); procedure BitBtn1Click(Sender: TObject); procedure RadioGroup2Click(Sender: TObject); ɪrivate { Private declarations } public { Public declarations } end; const nn = 20; //Ɇɚɤɫɢɦɚɥɶɧɨɟ ɤɨɥɢɱɟɫɬɜɨ ɭɱɟɧɢɤɨɜ = 10 mm = 5; //Ɇɚɤɫɢɦɚɥɶɧɨɟ ɤɨɥɢɱɟɫɬɜɨ ɷɤɡɚɦɟɧɨɜ = 5 pp : array [0..1] of String[1]=('ɦ','ɠ'); //Ɇɚɫɫɢɜ, ɫɨɞɟɪɠɚɳɢɣ ɩɨɥɨɜɨɣ ɩɪɢɡɧɚɤ var Form1: TForm1; n: Integer; //n - ɬɟɤɭɳɢɣ ɧɨɦɟɪ ɭɱɟɧɢɤɚ. f: array [1..nn] of String [30]; //f - ɦɚɫɫɢɜ ɮɚɦɢɥɢɣ p : array [1..nn] of String[1]; //p - ɦɚɫɫɢɜ ɞɥɹ ɢɞɟɧɬɢɮɢɤɚɰɢɢ ɩɨɥɚ a : array [1..nn, 1..mm] of Real; //a - ɦɚɫɫɢɜ ɨɰɟɧɨɤ ss : array [1..nn] Of Real; //s - ɦɚɫɫɢɜ ɞɥɹ ɫɪɟɞɧɟɝɨ ɛɚɥɥɚ ɭɱɟɧɢɤɨɜ implementation {$R *.dfm} procedure TForm1.StringGrid1SetEditText (Sender: TObject; ACol, ARow: Integer; const Value: String); var b, k : integer; //b -ɰɟɥɨɟ ɡɧɚɱɟɧɢɟ ɫɬɪɨɤɢ ɪɟɞɚɤɬɢɪɨɜɚɧɢɹ j : Byte; //j - ɩɚɪɚɦɟɬɪ ɰɢɤɥɚ ɞɥɹ ɬɟɤɭɳɟɝɨ ɧɨɦɟɪɚ ɫɬɨɥɛɰɚ ɦɚɬɪɢɰɵ ɚ begin with StringGrid1 do begin if Value = '' then Exit; //ȿɫɥɢ ɧɢɱɟɝɨ ɧɟ ɜɜɟɞɟɧɨ, ɬɨ ɜɵɯɨɞ ɢɡ ɩɪɨɰɟɞɭɪɵ
Try //ɇɚɱɚɥɨ ɡɚɳɢɳɟɧɧɨɝɨ ɛɥɨɤɚ b := StrToInt(Value) except 33
ShowMessage('ɇɟ ɜɟɪɧɵɣ ɫɢɦɜɨɥ!'); b:=0 end; //Ʉɨɧɟɰ ɡɚɳɢɳɟɧɧɨɝɨ ɛɥɨɤɚ //ɂɝɧɨɪɢɪɨɜɚɬɶ ɧɟɜɟɪɧɨ ɜɜɟɞɟɧɧɭɸ ɨɰɟɧɤɭ if (b<1) or (b>5) then begin Cells[Acol,Arow]:=''; Exit; end; Cells[Acol,Arow]:=Value; //Ɉɬɪɚɡɢɬɶ ɨɰɟɧɤɭ ɜ ɬɚɛɥɢɰɟ A[arow,Acol]:=b; //Ɂɚɩɢɫɚɬɶ ɨɰɟɧɤɭ ɜ ɦɚɫɫɢɜ //Ⱦɚɥɟɟ ɩɨɞɫɱɟɬ ɫɪɟɞɧɟɝɨ ɛɚɥɥɚ. SS[Arow]:=0; k:=0; //ɋɱɟɬɱɢɤ ɱɢɫɥɚ ɜɜɟɞɟɧɧɵɯ ɨɰɟɧɨɤ for j:=1 to 4 do begin SS[Arow]:=SS[Arow]+a[Arow,j]; if StringGrid1.Cells[j,Arow]<>'' then k:=k+1; end; if k<>0 then SS[Arow]:= SS[Arow]/k else SS[Arow]:=0; //Ɉɬɨɛɪɚɡɢɬɶ ɫɪɟɞɧɢɣ ɛɚɥɥ ɜ 5-ɨɦ ɫɬɨɥɛɰɟ ɬɚɛɥɢɰɵ Cells[5, Arow] := FormatFloat('##.##', SS[Arow]) end; end; { TForm1.StringGrid1SetEditText} procedure TForm1.FormActivate(Sender: TObject); { Ɉɛɪɚɛɨɬɱɢɤ ɞɥɹ ɡɚɞɚɧɢɹ ɡɧɚɱɟɧɢɣ ɮɢɤɫɢɪɨɜɚɧɧɨɣ ɫɬɪɨɤɢ ɬɚɛɥɢɰɵ. Ɉɛɧɭɥɟɧɢɟ ɧɚɱɚɥɶɧɨɝɨ ɡɧɚɱɟɧɢɹ ɧɨɦɟɪɚ ɭɱɟɧɢɤɚ } begin n:=0; stringGrid1.Cells[0,0]:='Ɏɚɦɢɥɢɹ ɫɬɭɞɟɧɬɚ'; Edit1.SetFocus; with StringGrid1 do begin Cells[1,0] :='Ɏɢɡɢɤɚ'; Cells[2,0] :='Ɇɚɬɟɦɚɬ.'; Cells[3,0] :='ɂɫɬɨɪɢɹ'; Cells[4,0] :='ɂɧɨɫɬɪ. ɹɡ.'; Cells[5,0] :='ɋɪɟɞɧɢɣ ɛɚɥɥ'; end; 34
stringGrid1.Cells[5,0]:='ɋɪɟɞɧɹɹ ɨɰɟɧɤɚ' end; { TForm1.FormActivate } procedure TForm1.BitBtn1Click(Sender: TObject); { Ɉɛɪɚɛɨɬɱɢɤ ɤɧɨɩɤɢ «Ɂɚɩɢɫɚɬɶ» ɨɫɭɳɟɫɬɜɥɹɟɬ ɜɜɨɞ ɮɚɦɢɥɢɢ ɢ ɩɨɥɚ ɉɟɪɟɧɨɫɢɬ ɡɧɚɱɟɧɢɹ ɮɚɦɢɥɢɢ ɜ ɮɢɤɫɢɪɨɜɚɧɧɵɣ ɫɬɨɥɛɟɰ ɬɚɛɥɢɰɵ } begin n := n+1; f[n] := Edit1.Text; p[n] := pp[RadioGroup1.ItemIndex]; StringGrid1.Cells[0,n] := f[n]; Edit1.SetFocus; Edit1.Clear; end; { TForm1.BitBtn1Click } procedure TForm1.RadioGroup2Click(Sender: TObject); // ɋɨɛɵɬɢɟ ɜɨɡɧɢɤɚɟɬ ɩɪɢ ɫɦɟɧɟ ɩɪɢɡɧɚɤɚ ɪɚɫɱɟɬɚ var S : Real; k, i: Byte; begin S := 0; k:=0; with RadioGroup2 do begin case ItemIndex of 0: begin //Ɋɚɫɱɟɬ ɫɪɟɞɧɟɝɨ ɛɚɥɥɚ ɦɚɥɶɱɢɤɨɜ for i := 1 to n do if p[i]='ɦ' then begin S := S+ss[i]; k:=k+1 end; if k=0 then S:=0 else S := S/k; end; 1: begin //Ɋɚɫɱɟɬ ɫɪɟɞɧɟɝɨ ɛɚɥɥɚ ɞɟɜɨɱɟɤ for i := 1 to n do if p[i]='ɠ' then begin S := S+ss[i]; k:=k+1 end; if k=0 then S:=0 35
else S := S/k; end; 2: begin //Ɋɚɫɱɟɬ ɨɛɳɟɝɨ ɫɪɟɞɧɟɝɨ ɛɚɥɥɚ for i := 1 to n do S := S+ss[i]; if n=0 then S:=0 else S := S/n; end; end; //ȼɵɜɨɞ ɪɟɡɭɥɶɬɚɬɚ ɜ ɨɤɧɨ ɪɟɞɚɤɬɨɪɚ Edit2.Text := FormatFloat('##.##',S); end; end; { TForm1.RadioGroup2Click } end. 1.3. Ʉɨɦɩɢɥɹɰɢɹ ɢ ɨɬɥɚɞɤɚ ɩɪɢɥɨɠɟɧɢɹ 1. ɉɨɞɝɨɬɨɜɤɚ ɩɪɢɥɨɠɟɧɢɹ ɤ ɨɬɥɚɞɤɟ. – ɉɪɟɠɞɟ ɱɟɦ ɨɬɥɚɠɢɜɚɬɶ ɩɪɢɥɨɠɟɧɢɟ, ɟɝɨ ɧɟɨɛɯɨɞɢɦɨ ɨɬɤɨɦɩɢɥɢɪɨɜɚɬɶ ɫɩɟɰɢɚɥɶɧɵɦ ɨɛɪɚɡɨɦ. Ⱦɥɹ ɷɬɨɝɨ ɫɥɟɞɭɟɬ ɜɵɩɨɥɧɢɬɶ ɤɨɦɚɧɞɭ Project/Options ɢ ɜɵɛɪɚɬɶ ɫɬɪɚɧɢɰɭ Compiler. ɇɚ ɷɬɨɣ ɫɬɪɚɧɢɰɟ ɧɟɨɛɯɨɞɢɦɨ ɩɨɦɟɬɢɬɶ ɨɩɰɢɢ Debug Information, Local Symbols ɢ Reference Info. ɉɨɫɥɟ ɷɬɨɝɨ ɧɟɨɛɯɨɞɢɦɨ ɜɵɩɨɥɧɢɬɶ ɤɨɦɚɧɞɭ Project/Compile (ɤɨɦɛɢɧɚɰɢɹ ɤɥɚɜɢɲ ). Ɍɟɩɟɪɶ ɩɪɢɥɨɠɟɧɢɟ ɝɨɬɨɜɨ ɤ ɨɬɥɚɞɤɟ. – Ʉɨɦɚɧɞɨɣ View/Debug windows/Watches ɜɵɡɨɜɢɬɟ ɨɤɧɨ ɧɚɛɥɸɞɟɧɢɣ. Ɉɤɧɨ ɧɚɛɥɸɞɟɧɢɣ ɢɫɩɨɥɶɡɭɟɬɫɹ ɜ ɨɬɥɚɞɨɱɧɨɦ ɪɟɠɢɦɟ ɞɥɹ ɧɚɛɥɸɞɟɧɢɹ ɡɚ ɢɡɦɟɧɟɧɢɟɦ ɡɧɚɱɟɧɢɣ ɜɵɪɚɠɟɧɢɣ, ɩɨɦɟɳɟɧɧɵɯ ɜ ɷɬɨ ɨɤɧɨ. Ⱦɥɹ ɞɨɛɚɜɥɟɧɢɹ ɧɨɜɨɝɨ ɜɵɪɚɠɟɧɢɹ ɳɟɥɤɧɢɬɟ ɩɨ ɨɤɧɭ ɩɪɚɜɨɣ ɤɧɨɩɤɨɣ ɦɵɲɢ ɢ ɜɵɛɟɪɢɬɟ ɨɩɰɢɸ Add Watch. ȼ ɫɬɪɨɤɟ Expression ɜɜɟɞɢɬɟ ɜɵɪɚɠɟɧɢɟ Aɋol. Ɉɤɧɨ Repeat count ɨɩɪɟɞɟɥɹɟɬ ɤɨɥɢɱɟɫɬɜɨ ɩɨɤɚɡɵɜɚɟɦɵɯ ɷɥɟɦɟɧɬɨɜ ɦɚɫɫɢɜɨɜ ɞɚɧɧɵɯ; ɨɤɧɨ Digits ɭɤɚɡɵɜɚɟɬ ɤɨɥɢɱɟɫɬɜɨ ɡɧɚɱɚɳɢɯ ɰɢɮɪ ɞɥɹ ɨɬɨɛɪɚɠɟɧɢɹ ɜɟɳɟɫɬɜɟɧɧɵɯ ɞɚɧɧɵɯ; ɩɟɪɟɤɥɸɱɚɬɟɥɶ Enabled ɪɚɡɪɟɲɚɟɬ ɢɥɢ ɡɚɩɪɟɳɚɟɬ ɜɵɱɢɫɥɟɧɢɟ ɜɵɪɚɠɟɧɢɹ. Ɉɫɬɚɥɶɧɵɟ ɷɥɟɦɟɧɬɵ ɨɩɪɟɞɟɥɹɸɬ ɜɢɞ ɩɪɟɞɫɬɚɜɥɟɧɢɹ ɡɧɚɱɟɧɢɹ. ȼ ɨɬɥɚɞɨɱɧɨɦ ɪɟɠɢɦɟ ɬɟɤɭɳɟɟ ɡɧɚɱɟɧɢɟ ɥɸɛɨɣ ɩɟɪɟɦɟɧɧɨɣ ɦɨɠɧɨ ɩɨɫɦɨɬɪɟɬɶ, ɭɤɚɡɚɜ ɧɚ ɧɟɟ ɤɭɪɫɨɪɨɦ: ɡɧɚɱɟɧɢɟ ɩɨɹɜɢɬɫɹ ɜ ɹɪɥɵɱɤɟ ɪɹɞɨɦ ɫ ɤɭɪɫɨɪɨɦ. – ɍɫɬɚɧɨɜɢɬɟ ɞɜɟ ɬɨɱɤɢ ɤɨɧɬɪɨɥɶɧɨɝɨ ɨɫɬɚɧɨɜɚ: ɳɟɥɤɧɢɬɟ ɦɵɲɶɸ ɩɨ ɫɥɭɠɟɛɧɨɣ ɡɨɧɟ ɫɥɟɜɚ ɨɬ ɧɭɠɧɨɣ ɫɬɪɨɤɢ ɜ ɩɪɨɝɪɚɦɦɟ (ɜɵɛɟɪɢɬɟ ɫɬɪɨɤɢ, ɫɨɞɟɪɠɚɳɢɟ ACol). 2. ȼɵɩɨɥɧɢɬɟ ɩɪɨɝɪɚɦɦɭ (). ɉɨɫɥɟ ɨɫɬɚɧɨɜɚ ɜɵɩɨɥɧɹɣɬɟ ɩɪɨɝɪɚɦɦɭ ɩɨɫɬɪɨɱɧɨ. ɉɪɨɫɦɨɬɪɢɬɟ ɡɧɚɱɟɧɢɹ ɩɟɪɟɦɟɧɧɵɯ ɩɪɢ ɩɨɦɨɳɢ ɭɫɬɚɧɨɜɤɢ ɧɚ ɧɢɯ ɤɭɪɫɨɪɚ. 3. ɉɨɩɪɨɛɭɣɬɟ ɞɪɭɝɢɟ ɦɟɬɨɞɵ ɨɬɥɚɞɤɢ, ɧɚɩɪɢɦɟɪ Run To Cursor, Program Pause, Program Reset. 36
4. ȼɵɡɨɜɢɬɟ ɩɭɧɤɬ ɦɟɧɸ File | Save project as ɢ ɫɨɯɪɚɧɢɬɟ ɦɨɞɭɥɶ ɤɚɤ U3, ɩɪɨɟɤɬ ɤɚɤ Project3 ɜ ɤɚɬɚɥɨɝ Lab_3. 2. ɋɚɦɨɫɬɨɹɬɟɥɶɧɚɹ ɪɚɛɨɬɚ Ɂɚɞɚɧɢɟ. Ɉɬɤɪɨɣɬɟ ɩɪɨɟɤɬ, ɤɨɬɨɪɵɣ ɜɵ ɫɨɡɞɚɥɢ ɧɚ ɩɪɟɞɵɞɭɳɟɦ ɡɚɧɹɬɢɢ ɢ ɫɤɨɪɪɟɤɬɢɪɭɣɬɟ ɟɝɨ ɜ ɫɨɨɬɜɟɬɫɬɜɢɢ ɫ ɧɨɜɵɦ ɡɚɞɚɧɢɟɦ. ȼɚɪɢɚɧɬɵ
1
2
3
4
5
ɂɫɯɨɞɧɵɟ ɞɚɧɧɵɟ Ɋɚɡɪɚɛɨɬɚɬɶ ɩɪɢɥɨɠɟɧɢɟ ɞɥɹ ɨɛɪɚɛɨɬɤɢ ɪɟɡɭɥɶɬɚɬɨɜ ɫɨɪɟɜɧɨɜɚɧɢɣ. ɂɫɯɨɞɧɵɟ ɞɚɧɧɵɟ: ɮɚɦɢɥɢɹ ɫɩɨɪɬɫɦɟɧɚ, ɜɪɟɦɹ ɫɬɚɪɬɚ, ɜɪɟɦɹ ɮɢɧɢɲɚ, ɤɨɧɬɪɨɥɶɧɨɟ ɜɪɟɦɹ. ȼɵɜɟɫɬɢ ɮɚɦɢɥɢɢ ɫɩɨɪɬɫɦɟɧɨɜ, ɭɥɨɠɢɜɲɢɯɫɹ ɜ ɤɨɧɬɪɨɥɶɧɨɟ ɜɪɟɦɹ. Ɋɟɤɨɦɟɧɞɚɰɢɢ: ɮɚɦɢɥɢɢ ɫɩɨɪɬɫɦɟɧɨɜ ɡɚɞɚɬɶ ɜ ɜɢɞɟ ɬɢɩɢɡɢɪɨɜɚɧɧɨɣ ɤɨɧɫɬɚɧɬɵ-ɦɚɫɫɢɜɚ; ɜɪɟɦɹ ɫɬɚɪɬɚ ɢ ɜɪɟɦɹ ɮɢɧɢɲɚ ɜɜɨɞɢɬɶ ɜ ɬɚɛɥɢɰɭ; ɪɟɡɭɥɶɬɚɬ ɨɬɪɚɡɢɬɶ ɜ ɤɨɦɩɨɧɟɧɬɟ TMemo ɋ ɩɨɦɨɳɶɸ ɬɚɛɥɢɰɵ TStringGrid ɜɜɟɫɬɢ ɷɥɟɦɟɧɬɵ ɦɚɬɪɢɰɵ ɢ ɩɨɞɫɱɢɬɚɬɶ ɫɭɦɦɭ ɤɜɚɞɪɚɬɨɜ ɟɝɨ ɫɬɨɥɛɰɨɜ. Ɉɪɝɚɧɢɡɨɜɚɬɶ ɩɨ ɜɵɛɨɪɭ ɪɚɫɱɟɬ ɧɚɢɛɨɥɶɲɟɣ ɫɭɦɦɵ ɷɥɟɦɟɧɬɨɜ ɫɬɨɥɛɰɨɜ ɢɥɢ ɧɚɢɛɨɥɶɲɟɣ ɫɭɦɦɵ ɷɥɟɦɟɧɬɨɜ ɫɬɪɨɤ. Ɋɟɡɭɥɶɬɚɬ ɨɬɨɛɪɚɡɢɬɶ ɜ ɤɨɦɩɨɧɟɧɬɟ TEdit Ɋɚɫɫɱɢɬɚɬɶ ɫɪɟɞɧɢɟ ɩɚɪɚɦɟɬɪɵ ɝɪɭɩɩɵ ɫɬɭɞɟɧɬɨɜ. ɂɫɯɨɞɧɵɟ ɞɚɧɧɵɟ: ɮɚɦɢɥɢɢ ɫɬɭɞɟɧɬɨɜ, ɤɨɥɢɱɟɫɬɜɨ ɛɚɥɥɨɜ, ɧɚɛɪɚɧɧɵɯ ɤɚɠɞɵɦ ɫɬɭɞɟɧɬɨɦ ɩɪɢ ɬɟɫɬɢɪɨɜɚɧɢɢ; ɪɨɫɬ ɢ ɜɟɫ ɤɚɠɞɨɝɨ ɫɬɭɞɟɧɬɚ. Ɋɚɫɫɱɢɬɚɬɶ ɫɪɟɞɧɢɣ ɛɚɥɥ, ɫɪɟɞɧɢɣ ɜɟɫ ɢ ɫɪɟɞɧɢɣ ɪɨɫɬ ɫɬɭɞɟɧɬɨɜ ɜ ɝɪɭɩɩɟ ɉɪɟɞɫɬɚɜɢɬɶ ɜ ɜɢɞɟ ɬɚɛɥɢɰɵ ɢɬɨɝɢ ɞɟɹɬɟɥɶɧɨɫɬɢ ɱɟɬɵɪɟɯ ɚɝɟɧɬɨɜ ɮɢɪɦɵ ɩɨ ɫɛɵɬɭ n-ɨɣ ɩɪɨɞɭɤɰɢɢ. ɂɫɯɨɞɧɨɣ ɢɧɮɨɪɦɚɰɢɟɣ ɫɱɢɬɚɬɶ ɮɚɦɢɥɢɢ ɚɝɟɧɬɨɜ ɢ ɨɛɴɟɦ ɩɪɨɞɚɠ ɩɨ ɤɜɚɪɬɚɥɚɦ. Ɋɚɫɫɱɢɬɚɬɶ ɨɛɴɟɦ ɩɪɨɞɚɠ ɤɚɠɞɨɝɨ ɚɝɟɧɬɚ ɡɚ ɝɨɞ ɢ ɜɵɜɟɫɬɢ ɮɚɦɢɥɢɸ ɚɝɟɧɬɚ, ɢɦɟɸɳɟɝɨ ɧɚɢɥɭɱɲɢɣ ɪɟɡɭɥɶɬɚɬ ɉɪɟɞɫɬɚɜɢɬɶ ɜ ɜɢɞɟ ɬɚɛɥɢɰɵ ɜɟɞɨɦɨɫɬɶ ɫɜɟɞɟɧɢɣ ɨ ɩɪɨɩɭɫɤɚɯ ɡɚɧɹɬɢɣ ɫɬɭɞɟɧɬɚɦɢ. ɂɫɯɨɞɧɨɣ ɢɧɮɨɪɦɚɰɢɟɣ ɹɜɥɹɟɬɫɹ: ɮɚɦɢɥɢɹ, ɧɨɦɟɪ ɝɪɭɩɩɵ, ɤɨɥɢɱɟɫɬɜɨ ɱɚɫɨɜ, ɩɪɨɩɭɳɟɧɧɵɯ ɩɨ ɭɜɚɠɢɬɟɥɶɧɨɣ ɢ ɧɟɭɜɚɠɢɬɟɥɶɧɨɣ ɩɪɢɱɢɧɟ. ɉɨɥɭɱɢɬɶ ɫɩɢɫɨɤ ɫɬɭɞɟɧɬɨɜ, ɩɪɨɩɭɫɬɢɜɲɢɯ ɛɨɥɟɟ ɏɏɏ ɱɚɫɨɜ ɩɨ ɧɟɭɜɚɠɢɬɟɥɶɧɨɣ ɩɪɢɱɢɧɟ. ɏɏɏ – ɜɜɨɞɢɦɚɹ ɜɟɥɢɱɢɧɚ
3.3. ɋɨɫɬɚɜ ɩɪɨɟɤɬɚ Delphi. Ɇɟɧɟɞɠɟɪ ɩɪɨɟɤɬɨɜ. ɍɫɬɚɧɨɜɤɚ ɩɚɪɚɦɟɬɪɨɜ ɩɪɨɟɤɬɚ. Ⱥɬɪɢɛɭɬɵ ɢ ɫɬɢɥɢ ɮɨɪɦɵ. ɋɨɡɞɚɧɢɟ ɢ ɭɧɢɱɬɨɠɟɧɢɟ ɮɨɪɦɵ. ɂɫɩɨɥɶɡɨɜɚɧɢɟ ɧɟɫɤɨɥɶɤɢɯ ɮɨɪɦ ɜ ɩɪɢɥɨɠɟɧɢɢ ɐɟɥɶ: ɢɡɭɱɢɬɶ ɫɨɫɬɚɜ ɩɪɨɟɤɬɚ Delphi, ɧɚɭɱɢɬɶɫɹ ɭɩɪɚɜɥɹɬɶ ɩɪɨɟɤɬɚɦɢ. ɂɡɭɱɢɬɶ ɧɚɢɛɨɥɟɟ ɜɚɠɧɵɟ ɫɜɨɣɫɬɜɚ ɢ ɦɟɬɨɞɵ ɤɥɚɫɫɚ TForm. 37
Ɋɟɡɭɥɶɬɚɬ ɨɛɭɱɟɧɢɹ: ɩɨɫɥɟ ɭɫɩɟɲɧɨɝɨ ɡɚɜɟɪɲɟɧɢɹ ɡɚɧɹɬɢɹ ɩɨɥɶɡɨɜɚɬɟɥɶ ɞɨɥɠɟɧ: – ɡɧɚɬɶ, ɢɡ ɤɚɤɢɯ ɨɫɧɨɜɧɵɯ ɮɚɣɥɨɜ ɫɨɫɬɨɢɬ ɩɪɨɟɤɬ Delphi; – ɭɦɟɬɶ ɞɨɛɚɜɥɹɬɶ/ɭɞɚɥɹɬɶ ɦɨɞɭɥɢ ɩɪɨɟɤɬɚ; – ɨɫɭɳɟɫɬɜɥɹɬɶ ɭɫɬɚɧɨɜɤɭ ɩɚɪɚɦɟɬɪɨɜ ɩɪɨɟɤɬɚ; – ɡɧɚɬɶ ɧɚɡɧɚɱɟɧɢɟ ɢ ɫɨɫɬɚɜ ɪɟɩɨɡɢɬɨɪɢɹ Delphi; – ɡɧɚɬɶ, ɤɚɤ ɫɨɡɞɚɸɬɫɹ ɢ ɭɧɢɱɬɨɠɚɸɬɫɹ ɮɨɪɦɵ ɜ ɩɪɢɥɨɠɟɧɢɢ; – ɭɦɟɬɶ ɨɪɝɚɧɢɡɨɜɵɜɚɬɶ ɜɡɚɢɦɨɞɟɣɫɬɜɢɟ ɮɨɪɦ ɜ ɩɪɢɥɨɠɟɧɢɢ; – ɢɡɭɱɢɬɶ ɫɜɨɣɫɬɜɚ BorderIcons ɢ BorderStyle; – ɭɦɟɬɶ ɩɪɢɦɟɧɹɬɶ ɦɟɬɨɞɵ Create, Release, Close, Show, Hide ɞɥɹ ɮɨɪɦ. ɂɫɩɨɥɶɡɭɟɦɚɹ ɩɚɩɤɚ: Lab4. ɉɥɚɧ ɡɚɧɹɬɢɹ ɑɚɫɬɶ I. ɋɨɫɬɚɜ ɩɪɨɟɤɬɚ Delphi. Ɇɟɧɟɞɠɟɪ ɩɪɨɟɤɬɨɜ. ɍɫɬɚɧɨɜɤɚ ɩɚɪɚɦɟɬɪɨɜ ɩɪɨɟɤɬɚ. Ɇɟɧɟɞɠɟɪ ɩɪɨɟɤɬɚ. ɍɫɬɚɧɨɜɤɚ ɩɚɪɚɦɟɬɪɨɜ ɩɪɨɟɤɬɚ. 1. ɋɨɫɬɚɜ ɩɪɨɟɤɬɚ. Ɇɟɧɟɞɠɟɪ ɩɪɨɟɤɬɚ. ɍɫɬɚɧɨɜɤɚ ɩɚɪɚɦɟɬɪɨɜ ɩɪɨɟɤɬɚ: ɪɚɛɨɬɚ ɩɨɞ ɪɭɤɨɜɨɞɫɬɜɨɦ ɩɪɟɩɨɞɚɜɚɬɟɥɹ 40 ɦɢɧɭɬ. 2. ɋɚɦɨɫɬɨɹɬɟɥɶɧɚɹ ɪɚɛɨɬɚ 40 ɦɢɧɭɬ. ɑɚɫɬɶ II. Ⱥɬɪɢɛɭɬɵ ɢ ɫɬɢɥɢ ɮɨɪɦɵ. ɋɨɡɞɚɧɢɟ ɢ ɭɧɢɱɬɨɠɟɧɢɟ ɮɨɪɦɵ. ȼɢɡɭɚɥɢɡɚɰɢɹ ɮɨɪɦɵ. ɂɫɩɨɥɶɡɨɜɚɧɢɟ ɧɟɫɤɨɥɶɤɢɯ ɮɨɪɦ ɜ ɩɪɢɥɨɠɟɧɢɢ. 1. Ⱥɬɪɢɛɭɬɵ ɢ ɫɬɢɥɢ ɮɨɪɦɵ. ɋɨɡɞɚɧɢɟ ɢ ɭɧɢɱɬɨɠɟɧɢɟ ɮɨɪɦɵ. ȼɢɡɭɚɥɢɡɚɰɢɹ ɮɨɪɦɵ. ɂɫɩɨɥɶɡɨɜɚɧɢɟ ɧɟɫɤɨɥɶɤɢɯ ɮɨɪɦ ɜ ɩɪɢɥɨɠɟɧɢɢ: Ɋɚɛɨɬɚ ɩɨɞ ɪɭɤɨɜɨɞɫɬɜɨɦ ɩɪɟɩɨɞɚɜɚɬɟɥɹ 20 ɦɢɧɭɬ. 2. ɋɚɦɨɫɬɨɹɬɟɥɶɧɚɹ ɪɚɛɨɬɚ 60 ɦɢɧɭɬ. ȼ Delphi ɜɵ ɪɚɛɨɬɚɟɬɟ ɫ ɩɪɨɟɤɬɚɦɢ – ɧɚɛɨɪɚɦɢ ɮɚɣɥɨɜ, ɢɡ ɤɨɬɨɪɵɯ ɫɨɫɬɨɢɬ ɫɨɡɞɚɜɚɟɦɨɟ ɜɚɦɢ ɩɪɢɥɨɠɟɧɢɟ. ɂɦɢ ɦɨɝɭɬ ɛɵɬɶ ɮɚɣɥɵ, ɫɨɡɞɚɜɚɟɦɵɟ ɜ ɫɪɟɞɟ Delphi, – ɮɚɣɥɵ ɫ ɢɫɯɨɞɧɵɦ ɬɟɤɫɬɨɦ ɦɨɞɭɥɟɣ, ɮɨɪɦɵ, ɹɜɥɹɸɳɢɟɫɹ ɝɪɚɮɢɱɟɫɤɢɦ ɩɪɟɞɫɬɚɜɥɟɧɢɟɦ ɜɚɲɟɝɨ ɩɪɢɥɨɠɟɧɢɹ, ɢ ɫɚɦɢ ɮɚɣɥɵ ɩɪɨɟɤɬɨɜ ɢ ɞɪ. ɍɩɪɚɜɥɹɬɶ ɩɪɨɟɤɬɚɦɢ ɦɨɠɧɨ, ɢɫɩɨɥɶɡɭɹ ɫɨɨɬɜɟɬɫɬɜɭɸɳɢɟ ɨɩɰɢɢ ɝɥɚɜɧɨɝɨ ɦɟɧɸ. Ⱦɥɹ ɭɩɪɚɜɥɟɧɢɹ ɩɪɨɟɤɬɚɦɢ ɬɚɤɠɟ ɩɪɟɞɧɚɡɧɚɱɟɧɚ ɫɩɟɰɢɚɥɶɧɚɹ ɩɪɨɝɪɚɦɦɚ – ɦɟɧɟɞɠɟɪ ɩɪɨɟɤɬɨɜ. ȼ ɦɟɧɟɞɠɟɪɟ ɩɪɨɟɤɬɨɜ ɩɪɟɞɨɫɬɚɜɥɹɟɬɫɹ ɜɨɡɦɨɠɧɨɫɬɶ ɞɨɛɚɜɥɹɬɶ ɢ ɭɞɚɥɹɬɶ ɮɚɣɥɵ, ɜɯɨɞɹɳɢɟ ɜ ɩɪɨɟɤɬ, ɩɟɪɟɦɟɳɚɬɶɫɹ ɩɨ ɮɚɣɥɚɦ ɫ ɢɫɯɨɞɧɵɦ ɬɟɤɫɬɨɦ ɢ ɜɵɩɨɥɧɹɬɶ ɪɹɞ ɞɪɭɝɢɯ ɨɩɟɪɚɰɢɣ. 1.1. ɉɨɞɝɨɬɨɜɢɬɟɥɶɧɵɟ ɞɟɣɫɬɜɢɹ ȼ ɫɜɨɟɦ ɤɚɬɚɥɨɝɟ ɫɨɡɞɚɣɬɟ ɤɚɬɚɥɨɝ ɫ ɢɦɟɧɟɦ Lab_4. 1.2. ɋɨɫɬɚɜ ɩɪɨɟɤɬɚ 1. ɋɜɟɪɧɢɬɟ ɨɤɧɨ Delphi. Ɉɬɤɪɨɣɬɟ ɫɨɡɞɚɧɧɵɣ ɜɚɦɢ ɤɚɬɚɥɨɝ Lab2. Ⱦɚɧɧɵɣ ɤɚɬɚɥɨɝ ɫɨɞɟɪɠɢɬ ɮɚɣɥɵ, ɫɨɡɞɚɧɧɨɝɨ ɜɚɦɢ ɩɪɨɫɬɨɝɨ ɩɪɨɟɤɬɚ. Ɉɡɧɚɤɨɦɶɬɟɫɶ ɫ ɷɬɢɦɢ ɮɚɣɥɚɦɢ: – *.dpr – ɮɚɣɥ ɩɪɨɟɤɬɚ; 38
– *.pas – ɮɚɣɥ ɩɪɨɝɪɚɦɦɧɨɝɨ ɦɨɞɭɥɹ; – *.dfm – ɮɚɣɥ ɮɨɪɦɵ; – *.dcu – ɮɚɣɥɵ ɨɬɤɨɦɩɢɥɢɪɨɜɚɧɧɨɣ ɜɟɪɫɢɢ ɩɪɨɝɪɚɦɦɧɨɝɨ ɦɨɞɭɥɹ; – *.res – ɮɚɣɥ ɪɟɫɭɪɫɨɜ (ɫɨɞɟɪɠɢɬ ɢɫɩɨɥɶɡɭɟɦɭɸ ɩɪɨɟɤɬɨɦ ɩɢɤɬɨɝɪɚɦɦɭ); – *.cfg – ɨɬɤɨɦɩɢɥɢɪɨɜɚɧɧɵɣ ɮɚɣɥ ɧɚɫɬɪɨɟɤ ɩɪɨɟɤɬɚ; – *.dof – ɬɟɤɫɬɨɜɵɣ ɮɚɣɥ ɧɚɫɬɪɨɟɤ ɩɪɨɟɤɬɚ; – *.§dpr, *.§pas, *.§dfm – ɮɚɣɥɵ ɪɟɡɟɪɜɧɵɯ ɤɨɩɢɣ ɩɪɨɟɤɬɚ, ɩɪɨɝɪɚɦɦɧɨɝɨ ɦɨɞɭɥɹ, ɮɨɪɦɵ; – *.exe – ɢɫɩɨɥɧɹɟɦɵɣ ɮɚɣɥ ɩɪɢɥɨɠɟɧɢɹ. ȼɟɪɧɢɬɟɫɶ ɜ Delphi. 2. Ɏɚɣɥ ɩɪɨɟɤɬɚ – ɑɬɨɛɵ ɭɜɢɞɟɬɶ ɫɨɞɟɪɠɢɦɨɟ ɩɪɨɝɪɚɦɦɵ ɩɪɨɟɤɬɚ, ɳɟɥɤɧɢɬɟ ɩɨ ɨɩɰɢɢ Project /View Source ɝɥɚɜɧɨɝɨ ɦɟɧɸ. Ɉɡɧɚɤɨɦɶɬɟɫɶ ɫ ɫɨɞɟɪɠɢɦɵɦ ɩɪɨɝɪɚɦɦɵ. – ȼɵɡɨɜɢɬɟ ɤɨɧɬɟɤɫɬɧɨɟ ɦɟɧɸ ɢ ɜɵɛɟɪɢɬɟ ɨɩɰɢɸ Close Page. Ɏɚɣɥ ɩɪɨɟɤɬɚ ɩɨɥɧɨɫɬɶɸ ɮɨɪɦɢɪɭɟɬɫɹ Delphi ɢ ɧɟ ɩɪɟɞɧɚɡɧɚɱɟɧ ɞɥɹ ɪɟɞɚɤɬɢɪɨɜɚɧɢɹ. 3. Ɏɚɣɥ ɩɪɨɝɪɚɦɦɧɨɝɨ ɦɨɞɭɥɹ Ⱦɥɹ ɤɚɠɞɨɣ ɮɨɪɦɵ, ɜɤɥɸɱɚɟɦɨɣ ɜ ɩɪɨɟɤɬ, ɫɨɡɞɚɟɬɫɹ ɨɬɞɟɥɶɧɵɣ ɦɨɞɭɥɶ. ȼ ɷɬɨɦ ɮɚɣɥɟ ɯɪɚɧɢɬɫɹ ɤɨɞ, ɤɨɬɨɪɵɣ ɜɵ ɩɢɲɢɬɟ ɜ ɩɪɨɰɟɫɫɟ ɫɨɡɞɚɧɢɹ ɩɪɢɥɨɠɟɧɢɹ, – ɨɛɴɹɜɥɟɧɢɹ ɩɟɪɟɦɟɧɧɵɯ, ɬɢɩɨɜ, ɤɨɞ ɨɛɪɚɛɨɬɱɢɤɨɜ ɫɨɨɛɳɟɧɢɣ ɞɥɹ ɢɧɬɟɪɮɟɣɫɧɵɯ ɷɥɟɦɟɧɬɨɜ, ɞɨɩɨɥɧɢɬɟɥɶɧɵɣ ɤɨɞ ɢ ɬ. ɩ. ȼ ɩɪɨɟɤɬ ɦɨɠɧɨ ɜɤɥɸɱɚɬɶ ɢ ɦɨɞɭɥɢ, ɧɟ ɫɜɹɡɚɧɧɵɟ ɫ ɮɨɪɦɚɦɢ. ȼɧɢɦɚɬɟɥɶɧɨ ɩɪɨɫɦɨɬɪɢɬɟ ɤɨɞ ɩɪɨɝɪɚɦɦɧɨɝɨ ɦɨɞɭɥɹ ɢ ɨɩɪɟɞɟɥɢɬɟ ɫɦɵɫɥ ɤɚɠɞɨɣ ɫɬɪɨɤɢ. 4. Ɏɚɣɥ ɮɨɪɦɵ ɏɪɚɧɢɬ ɢɧɮɨɪɦɚɰɢɸ ɨ ɮɨɪɦɟ. ɗɬɨɬ ɮɚɣɥ ɛɢɧɚɪɧɵɣ, ɢ ɨɧ ɩɨɞɤɥɸɱɚɟɬɫɹ ɤ ɢɫɩɨɥɧɹɟɦɨɦɭ ɮɚɣɥɭ ɜ ɦɨɦɟɧɬ ɤɨɦɩɢɥɹɰɢɢ ɩɪɨɝɪɚɦɦɵ. – ɉɪɨɫɦɨɬɪɢɬɟ ɫɨɞɟɪɠɢɦɨɟ ɮɚɣɥɚ ɮɨɪɦɵ. Ⱦɥɹ ɷɬɨɝɨ ɜɵɩɨɥɧɢɬɟ ɤɨɦɚɧɞɭ File/Open ɢ ɜɵɛɟɪɢɬɟ ɬɢɩ ɮɚɣɥ dfm. Ɉɬɤɪɨɣɬɟ ɥɸɛɨɣ ɮɚɣɥ ɮɨɪɦɵ. Ɏɚɣɥ ɮɨɪɦɵ – ɷɬɨ ɫɩɢɫɨɤ ɫɜɨɣɫɬɜ ɜɫɟɯ ɤɨɦɩɨɧɟɧɬɨɜ, ɜɤɥɸɱɟɧɧɵɯ ɜ ɮɨɪɦɭ, ɡɧɚɱɟɧɢɹ ɤɨɬɨɪɵɯ ɛɵɥɢ ɢɡɦɟɧɟɧɵ ɩɨ ɫɪɚɜɧɟɧɢɸ ɫɨ ɡɧɚɱɟɧɢɹɦɢ, ɡɚɞɚɧɧɵɦɢ ɩɨ ɭɦɨɥɱɚɧɢɸ ɜ ɤɨɧɫɬɪɭɤɬɨɪɟ ɫɨɨɬɜɟɬɫɬɜɭɸɳɟɝɨ ɨɛɴɟɤɬɚ. – ȼɵɡɨɜɢɬɟ ɤɨɧɬɟɤɫɬɧɨɟ ɦɟɧɸ ɢ ɜɵɛɟɪɢɬɟ ɨɩɰɢɸ Close Page. 5. Ƚɪɭɩɩɚ ɩɪɨɟɤɬɨɜ ȼ Delphi ɦɨɠɟɬ ɫɭɳɟɫɬɜɨɜɚɬɶ ɝɪɭɩɩɚ ɩɪɨɟɤɬɨɜ, ɤɨɬɨɪɚɹ ɨɛɴɟɞɢɧɹɟɬ ɞɥɹ ɫɨɜɦɟɫɬɧɨɣ ɪɚɡɪɚɛɨɬɤɢ ɧɟɫɤɨɥɶɤɨ ɩɪɨɟɤɬɨɜ. Ɏɚɣɥ ɝɪɭɩɩɵ ɩɪɨɟɤɬɨɜ ɢɦɟɟɬ ɪɚɫɲɢɪɟɧɢɟ bpg ɢ ɩɪɟɞɫɬɚɜɥɹɟɬ ɫɨɛɨɣ ɬɟɤɫɬɨɜɵɣ ɮɚɣɥ ɫ ɫɢɫɬɟɦɧɨɣ ɢɧɮɨɪɦɚɰɢɟɣ ɢ ɨɩɢɫɚɧɢɟɦ ɩɪɨɟɤɬɨɜ, ɜɯɨɞɹɳɢɯ ɜ ɝɪɭɩɩɭ. ɋɬɪɨɝɨ ɝɨɜɨɪɹ, ɟɞɢɧɢɱɧɵɣ ɩɪɨɟɤɬ ɧɚ ɫɚɦɨɦ ɞɟɥɟ ɹɜɥɹɟɬɫɹ ɝɪɭɩɩɨɣ ɩɪɨɟɤɬɨɜ, ɫɨɞɟɪɠɚɳɟɣ ɜɫɟɝɨ ɨɞɢɧ ɷɥɟɦɟɧɬ. ȼ ɷɬɨɦ ɥɟɝɤɨ ɭɛɟɞɢɬɶɫɹ, ɡɚɝɥɹɧɭɜ ɜ ɦɟɧɟɞɠɟɪ ɩɪɨɟɤɬɚ 39
(Project Manager ɩɭɧɤɬɚ ɦɟɧɸ View): ɞɚɠɟ ɜ ɬɨɥɶɤɨ ɱɬɨ ɫɨɡɞɚɧɧɨɦ ɩɪɨɟɤɬɟ ɧɚ ɩɟɪɜɨɦ ɦɟɫɬɟ ɫɩɢɫɤɚ ɧɚɯɨɞɢɬɫɹ ɝɪɭɩɩɚ, ɩɨ ɭɦɨɥɱɚɧɢɸ ɢɦɟɸɳɚɹ ɧɚɡɜɚɧɢɟ ProjectGroup1. 1.3. Ɇɟɧɟɞɠɟɪ ɩɪɨɟɤɬɚ ɉɪɟɞɧɚɡɧɚɱɟɧ ɞɥɹ ɭɩɪɚɜɥɟɧɢɹ ɫɨɫɬɚɜɧɵɦɢ ɱɚɫɬɹɦɢ ɩɪɨɟɤɬɚ ɢɥɢ ɝɪɭɩɩɵ ɩɪɨɟɤɬɨɜ. ɍɩɪɚɜɥɟɧɢɟ ɷɥɟɦɟɧɬɚɦɢ ɩɪɨɟɤɬɚ ɨɫɭɳɟɫɬɜɥɹɟɬɫɹ ɤɧɨɩɤɚɦɢ ɩɚɧɟɥɢ ɢɧɫɬɪɭɦɟɧɬɨɜ ɢɥɢ ɤɨɦɚɧɞɚɦɢ ɤɨɧɬɟɤɫɬɧɨɝɨ ɦɟɧɸ ɦɟɧɟɞɠɟɪɚ ɩɪɨɟɤɬɨɜ. 1. Ɂɚɤɪɨɣɬɟ ɜɫɟ ɨɬɤɪɵɬɵɟ ɮɚɣɥɵ ɜ Delphi. Ⱦɥɹ ɷɬɨɝɨ ɜɵɩɨɥɧɢɬɟ ɤɨɦɚɧɞɭ File/Close All. 2. ȼɵɡɨɜɢɬɟ ɦɟɧɟɞɠɟɪ ɩɪɨɟɤɬɚ ɤɨɦɚɧɞɨɣ Project Manager ɩɭɧɤɬɚ ɦɟɧɸ View. ɇɚ ɷɤɪɚɧɟ – ɨɤɧɨ ɦɟɧɟɞɠɟɪɚ ɩɪɨɟɤɬɚ, ɜ ɤɨɬɨɪɨɦ ɭɤɚɡɵɜɚɟɬɫɹ, ɱɬɨ ɧɟ ɫɨɡɞɚɧɨ ɧɢ ɨɞɧɨɣ ɝɪɭɩɩɵ ɩɪɨɟɤɬɨɜ. 3. Ⱦɥɹ ɬɨɝɨ ɱɬɨɛɵ ɞɨɛɚɜɢɬɶ ɩɪɨɟɤɬ, ɫɨɡɞɚɧɧɵɣ ɧɚ ɜɬɨɪɨɣ ɥɚɛɨɪɚɬɨɪɧɨɣ ɪɚɛɨɬɟ, ɧɭɠɧɨ ɜɵɛɪɚɬɶ ɩɭɧɤɬ ɝɥɚɜɧɨɝɨ ɦɟɧɸ Project | Add Existing Project, ɞɚɥɟɟ ɫɜɨɣ ɤɚɬɚɥɨɝ Lab_2 ɢ ɩɪɨɟɤɬ. Ⱥɧɚɥɨɝɢɱɧɨ ɞɨɛɚɜɶɬɟ ɤ ɩɪɨɟɤɬ ɥɚɛɨɪɚɬɨɪɧɨɣ ɪɚɛɨɬɵ ʋ 3. Ⱦɚɥɟɟ ɜɵɛɪɚɬɶ Save All ɢ ɫɨɯɪɚɧɢɬɶ ɝɪɭɩɩɭ ɩɪɨɟɤɬɨɜ ɤɚɤ PG1 ɜ ɩɚɩɤɟ Lab_4, ɜ ɷɬɨɣ ɝɪɭɩɩɟ ɛɭɞɭɬ ɧɚɯɨɞɢɬɶɫɹ ɜɵɡɜɚɧɧɵɟ ɜɚɦɢ ɩɪɨɟɤɬɵ. 4. Ⱦɨɛɚɜɶɬɟ ɤ ɩɪɨɟɤɬɭ ɧɨɜɭɸ ɮɨɪɦɭ. Ⱦɥɹ ɷɬɨɝɨ ɜɵɩɨɥɧɢɬɟ ɤɨɦɚɧɞɭ ɝɥɚɜɧɨɝɨ ɦɟɧɸ File/New ɢ ɜ ɞɢɚɥɨɝɨɜɨɦ ɨɤɧɟ New Items ɜɵɛɟɪɢɬɟ ɡɧɚɱɨɤ ɮɨɪɦɵ (Form). 5. Ⱦɨɛɚɜɶɬɟ ɤ ɩɪɨɟɤɬɭ ɲɚɛɥɨɧ ɫɬɚɧɞɚɪɬɧɨɝɨ ɞɢɚɥɨɝɚ. ɒɚɛɥɨɧɵ ɫɬɚɧɞɚɪɬɧɵɯ ɞɢɚɥɨɝɨɜ ɧɚɯɨɞɹɬɫɹ ɧɚ ɡɚɤɥɚɞɤɟ Dialogs ɩɚɧɟɥɢ New Items (File/New). 6. ɉɪɨɫɦɨɬɪɢɬɟ ɫɨɫɬɚɜ ɩɨɥɭɱɢɜɲɟɝɨ ɩɪɨɟɤɬɚ ɜ ɦɟɧɟɞɠɟɪɟ ɩɪɨɟɤɬɨɜ. 1.4. ɍɫɬɚɧɨɜɤɚ ɩɚɪɚɦɟɬɪɨɜ ɩɪɨɟɤɬɚ 1. ɉɚɪɚɦɟɬɪɵ ɩɪɨɟɤɬɚ ɞɨɫɬɭɩɧɵ, ɟɫɥɢ ɜɵɛɪɚɬɶ ɤɨɦɚɧɞɭ Options ɩɭɧɤɬɚ Project ɝɥɚɜɧɨɝɨ ɦɟɧɸ Delphi. ȼ ɷɬɨɦ ɨɤɧɟ ɦɨɠɧɨ ɧɚɫɬɪɨɢɬɶ ɤɨɦɩɢɥɹɬɨɪ ɢ ɤɨɦɩɨɧɨɜɳɢɤ, ɡɚɞɚɬɶ ɫɩɨɫɨɛ ɫɨɡɞɚɧɢɹ ɮɨɪɦ ɩɪɨɟɤɬɚ, ɩɨɞɤɥɸɱɢɬɶ ɮɚɣɥ ɩɨɦɨɳɢ ɢ ɡɧɚɱɨɤ. 2. ɉɪɢ ɡɚɩɭɫɤɟ ɩɨɞɝɨɬɨɜɥɟɧɧɨɝɨ ɩɪɨɟɤɬɚ ɧɚ ɷɤɪɚɧɟ ɩɨɹɜɢɬɫɹ ɬɚ ɮɨɪɦɚ, ɤɨɬɨɪɚɹ ɜɤɥɸɱɟɧɚ ɜ ɩɪɨɟɤɬ ɩɟɪɜɨɣ. ɗɬɚ ɮɨɪɦɚ ɚɜɬɨɦɚɬɢɱɟɫɤɢ ɧɚɡɧɚɱɟɧɚ ɝɥɚɜɧɨɣ ɮɨɪɦɨɣ ɩɪɨɟɤɬɚ. ɉɪɨɜɟɪɶɬɟ ɷɬɨ. 3. Ⱦɥɹ ɬɨɝɨ ɱɬɨɛɵ ɫɞɟɥɚɬɶ ɝɥɚɜɧɨɣ ɤɚɤɭɸ-ɥɢɛɨ ɞɪɭɝɭɸ ɮɨɪɦɭ, ɧɭɠɧɨ ɢɡɦɟɧɢɬɶ ɩɚɪɚɦɟɬɪɵ ɩɪɨɟɤɬɚ. ɇɚ ɫɬɪɚɧɢɰɟ Forms ɞɢɚɥɨɝɨɜɨɝɨ ɨɤɧɚ Project Options ɜ ɨɤɧɟ Main Form ɫɞɟɥɚɣɬɟ ɝɥɚɜɧɨɣ ɮɨɪɦɭ Form1. Ɂɚɤɪɨɣɬɟ ɨɤɧɨ ɭɫɬɚɧɨɜɤɢ ɩɚɪɚɦɟɬɪɨɜ ɩɪɨɟɤɬɚ. Ɂɚɩɭɫɬɢɬɟ ɩɪɨɝɪɚɦɦɭ ɢ ɭɛɟɞɢɬɟɫɶ, ɱɬɨ ɝɥɚɜɧɨɣ ɮɨɪɦɨɣ ɫɬɚɥɚ ɮɨɪɦɚ Form1. 4. ȼɵɡɨɜɢɬɟ ɞɢɚɥɨɝɨɜɭɸ ɩɚɧɟɥɶ Project Options ɢ ɩɪɨɫɦɨɬɪɢɬɟ ɫɨɞɟɪɠɚɧɢɟ ɜɫɟɯ ɫɬɪɚɧɢɰ. 40
5. Ɂɚɞɚɞɢɦ ɧɨɜɨɟ ɧɚɡɜɚɧɢɟ ɢ ɧɨɜɭɸ ɩɢɤɬɨɝɪɚɦɦɭ ɫɜɨɟɦɭ ɩɪɨɟɤɬɭ. ɇɚ ɫɬɪɚɧɢɰɟ Application ɜ ɨɤɧɟ Title ɜɜɟɞɢɬɟ: «ɂɡɭɱɟɧɢɟ Ɇɉ». ɇɚɠɦɢɬɟ ɤɧɨɩɤɭ ɢ ɨɬɤɪɨɣɬɟ ɧɨɜɭɸ ɤɚɪɬɢɧɤɭ ɞɥɹ ɩɢɤɬɨɝɪɚɦɦɵ (ɩɨɢɳɢɬɟ ɜ ɩɨɞɤɚɬɚɥɨɝɟ C:\Programm…\Common…\Borland…\Images\Buttons). Ɂɚɩɭɫɬɢɬɟ ɩɪɨɝɪɚɦɦɭ ɢ ɭɛɟɞɢɬɟɫɶ, ɱɬɨ ɩɢɤɬɨɝɪɚɦɦɚ ɢ ɡɚɝɨɥɨɜɨɤ ɢɡɦɟɧɢɥɢɫɶ. 6. ɉɪɢ ɞɨɛɚɜɥɟɧɢɢ ɜ ɩɪɨɟɤɬ ɧɨɜɨɣ ɮɨɪɦɵ ɟɣ ɩɪɢɫɜɚɢɜɚɟɬɫɹ ɫɬɚɬɭɫ ɫɨɡɞɚɜɚɟɦɨɣ ɩɨ ɭɦɨɥɱɚɧɢɸ. ɗɬɨ ɨɡɧɚɱɚɟɬ, ɱɬɨ ɜ ɮɚɣɥ ɩɪɨɟɤɬɚ ɞɨɛɚɜɥɹɟɬɫɹ ɤɨɧɫɬɪɭɤɬɨɪ ɞɥɹ ɷɬɨɣ ɮɨɪɦɵ, ɤɨɬɨɪɵɣ ɜɵɡɵɜɚɟɬɫɹ ɩɪɢ ɢɧɢɰɢɚɥɢɡɚɰɢɢ ɩɪɢɥɨɠɟɧɢɹ. ȿɫɥɢ ɩɪɨɟɤɬ ɫɨɞɟɪɠɢɬ ɦɧɨɝɨ ɮɨɪɦ, ɬɨ ɡɚɩɭɫɤ ɩɪɢɥɨɠɟɧɢɹ ɦɨɠɟɬ ɞɥɢɬɶɫɹ ɞɨɫɬɚɬɨɱɧɨ ɞɨɥɝɨ. ɇɟɤɨɬɨɪɵɟ ɮɨɪɦɵ ɩɪɢ ɡɚɩɭɫɤɟ ɩɪɢɥɨɠɟɧɢɹ ɦɨɠɧɨ ɧɟ ɫɨɡɞɚɜɚɬɶ. Ⱦɥɹ ɷɬɨɝɨ ɜ ɞɢɚɥɨɝɟ ɩɚɪɚɦɟɬɪɨɜ ɩɪɨɟɤɬɚ ɞɨɫɬɚɬɨɱɧɨ ɩɟɪɟɦɟɫɬɢɬɶ ɮɨɪɦɭ ɜ ɫɩɢɫɨɤ Available forms. Ɉɫɬɚɜɶɬɟ ɜ ɫɩɢɫɤɟ Auto-create forms ɬɨɥɶɤɨ ɝɥɚɜɧɭɸ ɮɨɪɦɭ. ȼɫɟ ɨɫɬɚɥɶɧɵɟ ɮɨɪɦɵ ɩɟɪɟɦɟɫɬɢɬɟ ɜ ɫɩɢɫɨɤ Available. 7. Ⱦɥɹ ɭɞɚɥɟɧɢɹ ɫɨɫɬɚɜɥɹɸɳɟɝɨ ɩɪɨɟɤɬ ɨɛɴɟɤɬɚ ɧɟɨɛɯɨɞɢɦɨ ɜɵɞɟɥɢɬɶ ɩɨɞɥɟɠɚɳɢɣ ɭɞɚɥɟɧɢɸ ɷɥɟɦɟɧɬ ɢ ɜɵɩɨɥɧɢɬɶ ɤɨɦɚɧɞɭ Remove (ɤɧɨɩɤɚ ɧɚ ɩɚɧɟɥɢ). ɍɞɚɥɢɬɟ ɜɫɟ ɦɨɞɭɥɢ ɢɡ ɩɪɨɟɤɬɚ, ɚ ɡɚɬɟɦ ɢ ɫɚɦ ɩɪɨɟɤɬ. 2. ɋɚɦɨɫɬɨɹɬɟɥɶɧɚɹ ɪɚɛɨɬɚ Ɂɚɞɚɧɢɟ. ɋɨɡɞɚɣɬɟ ɩɪɢɥɨɠɟɧɢɟ, ɫɨɫɬɨɹɳɟɟ ɢɡ ɞɜɭɯ/ɬɪɟɯ ɦɨɞɭɥɟɣ. ȼɚɪɢɚɧɬɵ
1
2
3
4
ɂɫɯɨɞɧɵɟ ɞɚɧɧɵɟ – ɦɨɞɭɥɹ ɥɚɛɨɪɚɬɨɪɧɨɣ ɪɚɛɨɬɵ ʋ 2; – ɩɭɫɬɨɣ ɫɬɚɧɞɚɪɬɧɨɣ ɮɨɪɦɵ. ɇɚ ɫɬɚɧɞɚɪɬɧɭɸ ɮɨɪɦɭ ɩɨɦɟɫɬɢɬɟ ɫɨɨɛɳɟɧɢɟ: «ɉɪɢɥɨɠɟɧɢɟ ɪɚɡɪɚɛɨɬɚɧɨ …» ɢ ɞɚɥɟɟ ɜɚɲɭ ɮɚɦɢɥɢɸ ɢ ɢɦɹ. ɋɞɟɥɚɣɬɟ ɷɬɭ ɮɨɪɦɭ ɝɥɚɜɧɨɣ. ɋɨɡɞɚɜɚɟɦɨɣ ɩɨ ɭɦɨɥɱɚɧɢɸ ɨɫɬɚɜɶɬɟ ɬɨɥɶɤɨ ɫɬɚɧɞɚɪɬɧɭɸ ɮɨɪɦɭ – ɦɨɞɭɥɹ ɥɚɛɨɪɚɬɨɪɧɨɣ ɪɚɛɨɬɵ ʋ 2; – ɮɨɪɦɵ Aboutbox. ɇɚ ɮɨɪɦɭ Aboutbox ɩɨɦɟɫɬɢɬɟ ɫɨɨɛɳɟɧɢɟ: «ɉɪɢɥɨɠɟɧɢɟ ɪɚɡɪɚɛɨɬɚɧɨ…» ɢ ɞɚɥɟɟ ɜɚɲɭ ɮɚɦɢɥɢɸ ɢ ɢɦɹ. ɋɞɟɥɚɣɬɟ ɷɬɭ ɮɨɪɦɭ ɝɥɚɜɧɨɣ. ɋɨɡɞɚɜɚɟɦɨɣ ɩɨ ɭɦɨɥɱɚɧɢɸ ɨɫɬɚɜɶɬɟ ɬɨɥɶɤɨ ɮɨɪɦɭ Aboutbox – ɦɨɞɭɥɹ ɥɚɛɨɪɚɬɨɪɧɨɣ ɪɚɛɨɬɵ ʋ 3; – ɩɭɫɬɨɣ ɫɬɚɧɞɚɪɬɧɨɣ ɮɨɪɦɵ; ɮɨɪɦɵ Password Dialog. ɋɞɟɥɚɣɬɟ ɝɥɚɜɧɨɣ ɮɨɪɦɭ Password Dialog. ɋɨɡɞɚɜɚɟɦɨɣ ɩɨ ɭɦɨɥɱɚɧɢɸ ɨɫɬɚɜɶɬɟ ɬɨɥɶɤɨ ɮɨɪɦɭ Password Dialog – ɦɨɞɭɥɹ ɥɚɛɨɪɚɬɨɪɧɨɣ ɪɚɛɨɬɵ ʋ 1; – ɦɨɞɭɥɹ ɥɚɛɨɪɚɬɨɪɧɨɣ ɪɚɛɨɬɵ ʋ 3; 41
ɮɨɪɦɵ Password Dialog. ɇɚ ɮɨɪɦɭ Password Dialog ɩɨɦɟɫɬɢɬɟ ɫɨɨɛɳɟɧɢɟ: «ɉɪɢɥɨɠɟɧɢɟ ɪɚɡɪɚɛɨɬɚɧɨ…» ɢ ɞɚɥɟɟ ɜɚɲɭ ɮɚɦɢɥɢɸ ɢ ɢɦɹ. ɋɨɡɞɚɜɚɟɦɨɣ ɩɨ ɭɦɨɥɱɚɧɢɸ ɨɫɬɚɜɶɬɟ ɬɨɥɶɤɨ ɮɨɪɦɭ Password Dialog. ɋɞɟɥɚɣɬɟ ɷɬɭ ɮɨɪɦɭ ɝɥɚɜɧɨɣ – ɦɨɞɭɥɹ ɥɚɛɨɪɚɬɨɪɧɨɣ ɪɚɛɨɬɵ ʋ 2; – ɦɨɞɭɥɹ ɥɚɛɨɪɚɬɨɪɧɨɣ ɪɚɛɨɬɵ ʋ 3; ɩɭɫɬɨɣ ɫɬɚɧɞɚɪɬɧɨɣ ɮɨɪɦɵ. 5 ɇɚ ɫɬɚɧɞɚɪɬɧɭɸ ɮɨɪɦɭ ɩɨɦɟɫɬɢɬɟ ɫɨɨɛɳɟɧɢɟ: «ɉɪɢɥɨɠɟɧɢɟ ɪɚɡɪɚɛɨɬɚɧɨ» ɢ ɞɚɥɟɟ ɜɚɲɭ ɮɚɦɢɥɢɸ ɢ ɢɦɹ. ɋɨɡɞɚɜɚɟɦɨɣ ɩɨ ɭɦɨɥɱɚɧɢɸ ɨɫɬɚɜɶɬɟ ɬɨɥɶɤɨ ɮɨɪɦɭ ɫɬɚɧɞɚɪɬɧɨɣ ɮɨɪɦɵ. ɋɞɟɥɚɣɬɟ ɷɬɭ ɮɨɪɦɭ ɝɥɚɜɧɨɣ ɉɪɨɝɪɚɦɦɭ ɡɚɩɢɲɢɬɟ ɜ ɜɚɲ ɤɚɬɚɥɨɝ Lab_4. ɑɚɫɬɶ II. Ⱥɬɪɢɛɭɬɵ ɢ ɫɬɢɥɢ ɮɨɪɦɵ. ɋɨɡɞɚɧɢɟ ɢ ɭɧɢɱɬɨɠɟɧɢɟ ɮɨɪɦɵ. ȼɢɡɭɚɥɢɡɚɰɢɹ ɮɨɪɦɵ. ɂɫɩɨɥɶɡɨɜɚɧɢɟ ɧɟɫɤɨɥɶɤɢɯ ɮɨɪɦ ɜ ɩɪɢɥɨɠɟɧɢɢ 1. Ⱥɬɪɢɛɭɬɵ ɢ ɫɬɢɥɢ ɮɨɪɦɵ. ɋɨɡɞɚɧɢɟ ɢ ɭɧɢɱɬɨɠɟɧɢɟ ɮɨɪɦɵ. ȼɢɡɭɚɥɢɡɚɰɢɹ ɮɨɪɦɵ. ɂɫɩɨɥɶɡɨɜɚɧɢɟ ɧɟɫɤɨɥɶɤɢɯ ɮɨɪɦ ɜ ɩɪɢɥɨɠɟɧɢɢ ɋɬɚɧɞɚɪɬɧɵɣ ɩɪɨɟɤɬ ɜ Delphi ɫɨɫɬɨɢɬ ɢɡ ɮɨɪɦ. Ɏɨɪɦɚ ɭɦɟɟɬ ɜɡɚɢɦɨɞɟɣɫɬɜɨɜɚɬɶ ɫ ɢɧɫɬɪɭɦɟɧɬɚɦɢ ɫɪɟɞɵ ɪɚɡɪɚɛɨɬɤɢ (ɩɚɥɢɬɪɨɣ ɤɨɦɩɨɧɟɧɬɨɜ, ɢɧɫɩɟɤɬɨɪɨɦ ɨɛɴɟɤɬɨɜ ɢ ɬ. ɞ.) ɢ ɪɚɡɦɟɳɟɧɧɵɦɢ ɧɚ ɧɟɣ ɤɨɦɩɨɧɟɧɬɚɦɢ. Ɉɧɢ ɨɛɟɫɩɟɱɢɜɚɸɬ ɫɨɡɞɚɧɢɟ ɩɨɥɶɡɨɜɚɬɟɥɶɫɤɨɝɨ ɢɧɬɟɪɮɟɣɫɚ ɢ ɯɪɚɧɟɧɢɟ ɩɪɨɝɪɚɦɦɧɨɣ ɥɨɝɢɤɢ ɩɪɢɥɨɠɟɧɢɹ. ȼ ɫɬɚɧɞɚɪɬɧɨɦ ɩɪɢɥɨɠɟɧɢɢ ɡɚɞɚɱɚ ɫɨɡɞɚɧɢɹ ɢ ɭɞɚɥɟɧɢɹ ɮɨɪɦ ɜɨɡɥɚɝɚɟɬɫɹ ɧɚ ɫɚɦɨ ɩɪɢɥɨɠɟɧɢɟ. ȿɫɥɢ ɪɚɡɪɚɛɨɬɱɢɤ ɨɫɬɚɜɢɥ ɜɫɟ ɮɨɪɦɵ ɜ ɫɩɢɫɤɟ ɫɨɡɞɚɜɚɟɦɵɯ ɚɜɬɨɦɚɬɢɱɟɫɤɢ, ɬɨ ɩɨɫɥɟ ɢɧɢɰɢɚɥɢɡɚɰɢɢ ɩɪɨɝɪɚɦɦɵ ɛɭɞɭɬ ɜɵɩɨɥɧɟɧɵ ɤɨɧɫɬɪɭɤɬɨɪɵ ɜɫɟɯ ɮɨɪɦ ɩɪɨɟɤɬɚ. ɉɪɢ ɧɟɨɛɯɨɞɢɦɨɫɬɢ ɫɨɡɞɚɬɶ ɮɨɪɦɭ ɫɚɦɨɫɬɨɹɬɟɥɶɧɨ ɪɚɡɪɚɛɨɬɱɢɤ ɦɨɠɟɬ ɢɫɩɨɥɶɡɨɜɚɬɶ ɟɟ ɤɨɧɫɬɪɭɤɬɨɪ: if Form1 = nil then Form1 := TForm1.Create(Application); ɍɞɚɥɟɧɢɟ ɫɨɡɞɚɧɧɵɯ ɬɚɤɢɦ ɨɛɪɚɡɨɦ ɮɨɪɦ ɨɫɭɳɟɫɬɜɥɹɟɬɫɹ ɚɜɬɨɦɚɬɢɱɟɫɤɢ. ɉɪɢ ɧɟɨɛɯɨɞɢɦɨɫɬɢ ɭɧɢɱɬɨɠɢɬɶ ɮɨɪɦɭ ɜ ɟɳɟ ɪɚɛɨɬɚɸɳɟɦ ɩɪɢɥɨɠɟɧɢɢ ɢɫɩɨɥɶɡɭɟɬɫɹ ɦɟɬɨɞ Release: if Form1 <> nil Then Release; Ɇɟɬɨɞ Show ɨɛɟɫɩɟɱɢɜɚɟɬ ɩɨɹɜɥɟɧɢɟ ɮɨɪɦɵ ɢ ɟɟ ɪɚɛɨɬɭ ɜ ɧɟɦɨɞɚɥɶɧɨɦ ɪɟɠɢɦɟ. Ɇɟɬɨɞ ShowModal ɨɛɟɫɩɟɱɢɜɚɟɬ ɩɨɹɜɥɟɧɢɟ ɮɨɪɦɵ ɢ ɟɟ ɪɚɛɨɬɭ ɜ ɦɨɞɚɥɶɧɨɦ ɪɟɠɢɦɟ (ɬ. ɟ. ɚɤɬɢɜɧɚ ɬɨɥɶɤɨ ɞɚɧɧɚɹ ɮɨɪɦɚ). Ⱦɥɹ ɬɨɝɨ ɱɬɨɛɵ ɨɛɪɚɬɢɬɶɫɹ ɤ ɦɟɬɨɞɭ Show, ɧɟɨɛɯɨɞɢɦɨ ɫɞɟɥɚɬɶ ɫɫɵɥɤɭ ɧɚ ɦɨɞɭɥɶ ɨɤɧɚ ɜ ɩɪɟɞɥɨɠɟɧɢɢ Uses. Delphi ɚɜɬɨɦɚɬɢɡɢɪɭɟɬ ɜɫɬɚɜɤɭ ɫɫɵɥɤɢ ɧɚ ɦɨɞɭɥɶ ɜ ɩɪɟɞɥɨɠɟɧɢɟ Uses. Ⱦɥɹ ɷɬɨɝɨ ɧɚ ɷɬɚɩɟ ɤɨɧɫɬɪɭɢɪɨɜɚɧɢɹ ɧɭɠɧɨ ɚɤɬɢɜɢɡɢɪɨɜɚɬɶ ɝɥɚɜɧɨɟ ɨɤɧɨ, ɳɟɥɤɧɭɜ ɩɨ ɧɟɦɭ ɦɵɲɶɸ, ɩɨɫɥɟ ɱɟɝɨ ɨɛɪɚɬɢɬɶɫɹ ɤ ɨɩɰɢɢ File/Uses Unit. ȼ ɩɨɹɜɢɜɲɟɦɫɹ ɞɢɚɥɨɝɨɜɨɦ ɨɤɧɟ ɧɭɠɧɨ ɜɵɛɪɚɬɶ ɦɨɞɭɥɶ ɢ ɧɚɠɚɬɶ . ȿɫɥɢ ɩɪɨɝɪɚɦɦɢɫɬ ɡɚɛɵɥ ɫɨɫɥɚɬɶɫɹ 42
ɧɚ ɦɨɞɭɥɶ, ɤɨɬɨɪɵɣ ɩɨɞɤɥɸɱɟɧ ɤ ɩɪɨɟɤɬɭ, Delphi, ɩɪɢ ɩɟɪɜɨɣ ɠɟ ɬɪɚɧɫɥɹɰɢɢ ɩɪɨɝɪɚɦɦɵ, ɫɨɨɛɳɢɬ ɨɛ ɷɬɨɦ ɢ ɩɪɟɞɥɨɠɢɬ ɜɫɬɚɜɢɬɶ ɧɟɞɨɫɬɚɸɳɭɸ ɫɫɵɥɤɭ. Ɇɟɬɨɞ Hide ɞɟɥɚɟɬ ɮɨɪɦɭ ɧɟɜɢɞɢɦɨɣ. Ɇɟɬɨɞ Close ɡɚɤɪɵɜɚɟɬ ɨɤɧɨ, ɚ ɞɥɹ ɝɥɚɜɧɨɝɨ ɨɤɧɚ ɡɚɜɟɪɲɚɟɬ ɪɚɛɨɬɭ ɩɪɨɝɪɚɦɦɵ. Ɉɛɪɚɬɢɬɟ ɜɧɢɦɚɧɢɟ, ɟɫɥɢ ɝɥɚɜɧɚɹ ɮɨɪɦɚ ɧɟɜɢɞɢɦɚ, ɢ ɜɵ ɡɚɤɪɵɜɚɟɬɟ ɜɢɞɢɦɭɸ ɮɨɪɦɭ (ɧɚɩɪɢɦɟɪ, ɫ ɩɨɦɨɳɶɸ ɫɢɫɬɟɦɧɨɣ ɤɧɨɩɤɢ), ɬɨ ɩɪɢɥɨɠɟɧɢɟ ɨɫɬɚɟɬɫɹ ɜ ɩɚɦɹɬɢ. ɗɬɨɝɨ ɜ ɩɪɢɥɨɠɟɧɢɹɯ ɞɨɩɭɫɤɚɬɶ ɧɟɥɶɡɹ, ɩɨɷɬɨɦɭ ɧɟɨɛɯɨɞɢɦɨ ɩɨɡɚɛɨɬɢɬɶɫɹ ɨ ɬɨɦ, ɱɬɨɛɵ ɜɫɟ ɮɨɪɦɵ ɛɵɥɢ ɡɚɤɪɵɬɵ ɩɨ ɨɤɨɧɱɚɧɢɢ ɪɚɛɨɬɵ ɩɪɨɝɪɚɦɦɵ. Ɇɨɠɧɨ ɜ ɫɨɛɵɬɢɟ Close ɮɨɪɦɵ ɩɨɦɟɫɬɢɬɶ ɤɨɞ: Application.Terminate. ɇɚɥɢɱɢɟ ɫɬɚɧɞɚɪɬɧɵɯ ɷɥɟɦɟɧɬɨɜ ɭɩɪɚɜɥɟɧɢɹ ɨɩɪɟɞɟɥɹɟɬɫɹ ɫɜɨɣɫɬɜɨɦ BoderIcons. Ɂɧɚɱɨɤ ɮɨɪɦɵ ɨɩɪɟɞɟɥɹɟɬɫɹ ɫɜɨɣɫɬɜɨɦ Icon. Ʉɚɠɞɚɹ ɮɨɪɦɚ ɦɨɠɟɬ ɢɦɟɬɶ ɫɨɛɫɬɜɟɧɧɨɟ ɦɟɧɸ. Ɂɚ ɟɝɨ ɢɫɩɨɥɶɡɨɜɚɧɢɟ ɨɬɜɟɱɚɟɬ ɫɜɨɣɫɬɜɨ Menu. ɋɬɢɥɶ ɮɨɪɦɵ ɨɩɪɟɞɟɥɹɟɬɫɹ ɫɜɨɣɫɬɜɨɦ BorderStyle. 1.1. Ⱥɬɪɢɛɭɬɵ ɢ ɫɬɢɥɢ ɮɨɪɦ 1. ɉɨɷɤɫɩɟɪɢɦɟɧɬɢɪɭɣɬɟ ɫɨ ɫɜɨɣɫɬɜɨɦ BorderIcons. Ɉɬɦɟɬɶɬɟ ɞɥɹ ɫɟɛɹ, ɤɚɤ ɦɟɧɹɟɬɫɹ ɧɚɛɨɪ ɫɬɚɧɞɚɪɬɧɵɯ ɷɥɟɦɟɧɬɨɜ ɭɩɪɚɜɥɟɧɢɹ ɧɚ ɮɨɪɦɟ ɜ ɡɚɜɢɫɢɦɨɫɬɢ ɨɬ ɡɧɚɱɟɧɢɹ ɫɜɨɣɫɬɜɚ. 2. ɉɨɷɤɫɩɟɪɢɦɟɧɬɢɪɭɣɬɟ ɫɨ ɫɜɨɣɫɬɜɨɦ BorderStyle. Ɉɬɦɟɬɶɬɟ ɞɥɹ ɫɟɛɹ ɫɬɢɥɢ ɮɨɪɦ ɞɥɹ ɤɚɠɞɨɝɨ ɡɧɚɱɟɧɢɹ ɷɬɨɝɨ ɫɜɨɣɫɬɜɚ. 3. ɂɫɩɨɥɶɡɭɹ ɫɜɨɣɫɬɜɨ Icon, ɨɩɪɟɞɟɥɢɬɟ ɞɥɹ ɤɚɠɞɨɣ ɮɨɪɦɵ ɢɧɞɢɜɢɞɭɚɥɶɧɭɸ ɩɢɤɬɨɝɪɚɦɦɭ. ɉɢɤɬɨɝɪɚɦɦɵ ɪɚɫɩɨɥɨɠɟɧɵ ɜ ɩɨɞɤɚɬɚɥɨɝɟ Images/Icons. 2. ɋɚɦɨɫɬɨɹɬɟɥɶɧɚɹ ɪɚɛɨɬɚ Ɂɚɞɚɧɢɟ. ɋɨɝɥɚɫɧɨ ɜɚɪɢɚɧɬɭ ɨɪɝɚɧɢɡɭɣɬɟ ɪɚɛɨɬɭ ɦɧɨɝɨɨɤɨɧɧɨɝɨ ɩɪɢɥɨɠɟɧɢɹ. ɉɪɢɦɟɱɚɧɢɟ: ɜɵ ɢɦɟɟɬɟ ɜɨɡɦɨɠɧɨɫɬɶ ɨɡɧɚɤɨɦɢɬɶɫɹ ɫ ɩɪɢɦɟɪɨɦ ɪɟɲɟɧɢɹ ɚɧɚɥɨɝɢɱɧɨɣ ɡɚɞɚɱɢ. ɉɪɨɟɤɬ Project4 ɫ ɦɨɞɭɥɹɦɢ u4 (ɨɬɧɨɫɢɬɫɹ ɤ ɝɥɚɜɧɨɣ ɮɨɪɦɟ), u2, u3 (ɨɬɧɨɫɹɬɫɹ ɤ ɮɨɪɦɚɦ ɫɨɨɬɜɟɬɫɬɜɟɧɧɨ ɥɚɛɨɪɚɬɨɪɧɨɣ ɪɚɛɨɬɵ ʋ 2 ɢ ʋ 3) ɧɚɯɨɞɢɬɫɹ ɜ ɤɚɬɚɥɨɝɟ Lab4. Ⱦɥɹ ɬɨɝɨ ɱɬɨɛɵ ɞɨɛɚɜɢɬɶ ɦɨɞɭɥɢ u2 ɢ u3 ɤ ɩɪɨɟɤɬɭ Project4 ɧɟɨɛɯɨɞɢɦɨ ɜɵɛɪɚɬɶ ɤɧɨɩɤɭ ɩɚɧɟɥɢ ɢɧɫɬɪɭɦɟɧɬɨɜ ɢ ɭɤɚɡɚɬɶ ɩɭɬɶ ɞɨɫɬɭɩɚ ɤ ɮɚɣɥɭ. ɇɚ ɪɢɫ. 3.3.1 ɩɪɟɞɫɬɚɜɥɟɧ ɜɧɟɲɧɢɣ ɜɢɞ ɝɥɚɜɧɨɣ ɮɨɪɦɵ (Form1) ɢ ɜɵɡɵɜɚɟɦɵɯ ɢɡ ɧɟɟ ɮɨɪɦ (Form2, Form3).
43
ɚ)
ɛ) ɜ) Ɋɢɫ. 3.3.1 Ɉɤɧɚ ɪɚɛɨɬɚɸɳɟɣ ɩɪɨɝɪɚɦɦɵ: ɚ – ɨɤɧɨ ɝɥɚɜɧɨɣ ɮɨɪɦɵ; ɛ – ɨɤɧɨ ɝɥɚɜɧɨɣ ɮɨɪɦɵ ɢ ɜɵɡɜɚɧɧɨɣ ɢɡ ɧɟɝɨ ɮɨɪɦɵ ɥɚɛɨɪɚɬɨɪɧɨɣ ɪɚɛɨɬɵ ʋ 2; ɜ – ɨɤɧɨ ɝɥɚɜɧɨɣ ɮɨɪɦɵ ɢ ɜɵɡɜɚɧɧɨɣ ɢɡ ɧɟɝɨ ɮɨɪɦɵ ɥɚɛɨɪɚɬɨɪɧɨɣ ɪɚɛɨɬɵ ʋ 3 Ʌɢɫɬɢɧɝ ɦɨɞɭɥɹ U4 unit U4; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, Buttons; type TForm1 = class(TForm) BitBtn1: TBitBtn; BitBtn2: TBitBtn; BitBtn3: TBitBtn; procedure BitBtn1Click(Sender: TObject); procedure BitBtn2Click(Sender: TObject); private 44
{ Private declarations } public { Public declarations } end; var Form1: TForm1; implementation uses u2, u3; {$R *.dfm} procedure TForm1.BitBtn1Click(Sender: TObject); begin if Form2 = Nil then Form2 := TForm2.Create(Application); Form2.Show; end; procedure TForm1.BitBtn2Click(Sender: TObject); begin if Form3 = Nil then Form3 := TForm3.Create(Application); Form3.Show; end; end. Ɉɛɪɚɛɨɬɱɢɤɢ ɫɨɛɵɬɢɹ Close ɞɥɹ Form2, Form3. procedure TForm2.FormClose(Sender: TObject; var Action: TCloseAction); begin if Form2 <> Nil then Release; end; procedure TForm3.FormClose(Sender: TCloseAction); begin if Form3 <> nil then Release; end;
ȼɚɪɢɚɧɬɵ
1
TObject;
var
Action:
ɂɫɯɨɞɧɵɟ ɞɚɧɧɵɟ Ƚɥɚɜɧɚɹ ɮɨɪɦɚ (ɫɬɚɧɞɚɪɬɧɚɹ ɮɨɪɦɚ) ɩɪɟɞɨɫɬɚɜɥɹɟɬ ɜɨɡɦɨɠɧɨɫɬɶ ɨɛɪɚɬɢɬɶɫɹ ɤ ɮɨɪɦɟ ɥɚɛɨɪɚɬɨɪɧɨɣ ɪɚɛɨɬɵ ʋ 2. ɂɡ ɮɨɪɦɵ ɥɚɛɨɪɚɬɨɪɧɨɣ ɪɚɛɨɬɵ ʋ 2 ɦɨɠɧɨ ɜɟɪɧɭɬɶɫɹ ɜ ɝɥɚɜɧɭɸ ɮɨɪɦɭ ɩɪɢɥɨɠɟɧɢɹ. ȼɨɡɦɨɠɧɨɫɬɶ ɡɚɤɨɧɱɢɬɶ ɪɚɛɨɬɭ ɩɪɢɥɨɠɟɧɢɹ ɞɨɥɠɧɚ ɫɭɳɟɫɬɜɨɜɚɬɶ ɬɨɥɶɤɨ ɩɪɢ ɪɚɛɨɬɟ ɫ ɝɥɚɜɧɨɣ ɮɨɪɦɨɣ 45
2
3
4
5
ɂɡ ɮɨɪɦɵ Aboutbox ɜɨɡɦɨɠɟɧ ɩɟɪɟɯɨɞ ɤ ɮɨɪɦɟ ɥɚɛɨɪɚɬɨɪɧɨɣ ɪɚɛɨɬɵ ʋ 2. ɂɡ ɮɨɪɦɵ ɥɚɛɨɪɚɬɨɪɧɨɣ ɪɚɛɨɬɵ ʋ 2 ɜɨɡɦɨɠɟɧ ɩɟɪɟɯɨɞ ɤ ɮɨɪɦɟ Aboutbox. ȼɨɡɦɨɠɧɨɫɬɶ ɩɪɟɤɪɚɬɢɬɶ ɪɚɛɨɬɭ ɩɪɢɥɨɠɟɧɢɹ ɞɨɥɠɧɚ ɫɭɳɟɫɬɜɨɜɚɬɶ ɜ ɨɛɟɢɯ ɮɨɪɦɚɯ. ɋɬɢɥɢ ɮɨɪɦ ɜɵɛɪɚɬɶ ɫɨɨɬɜɟɬɫɬɜɭɸɳɢɟ ɪɟɲɚɟɦɨɣ ɡɚɞɚɱɢ Ɋɚɛɨɬɚ ɩɪɢɥɨɠɟɧɢɹ ɞɨɥɠɧɚ ɧɚɱɢɧɚɬɶɫɹ ɫ ɜɜɨɞɚ ɩɚɪɨɥɹ. ɉɪɢ ɩɪɚɜɢɥɶɧɨɦ ɜɜɨɞɟ ɩɚɪɨɥɹ ɨɫɭɳɟɫɬɜɥɹɟɬɫɹ ɩɟɪɟɯɨɞ ɤ ɫɥɟɞɭɸɳɟɣ ɮɨɪɦɟ. ɗɬɚ ɮɨɪɦɚ ɞɨɥɠɧɚ ɩɪɟɞɨɫɬɚɜɢɬɶ ɜɵɛɨɪ: 1) ɥɚɛɨɪɚɬɨɪɧɚɹ ɪɚɛɨɬɚ; 2) ɤɨɧɟɰ ɪɚɛɨɬɵ. ȼɢɞɢɦɨɣ ɧɚ ɷɤɪɚɧɟ ɞɨɥɠɧɚ ɛɵɬɶ ɬɨɥɶɤɨ ɜɵɛɪɚɧɧɚɹ ɜ ɞɚɧɧɵɣ ɦɨɦɟɧɬ ɮɨɪɦɚ. ȼɨɡɦɨɠɧɨɫɬɶ ɩɪɟɤɪɚɬɢɬɶ ɪɚɛɨɬɭ ɢɦɟɟɬ ɬɨɥɶɤɨ ɮɨɪɦɚ ɜɵɛɨɪɚ. Ɏɨɪɦɵ ɥɚɛɨɪɚɬɨɪɧɵɯ ɪɚɛɨɬ ɞɨɥɠɧɵ ɩɪɟɞɫɬɚɜɥɹɬɶ ɫɨɛɨɣ ɩɪɹɦɨɭɝɨɥɶɧɢɤ ɛɟɡ ɪɚɦɤɢ ɢ ɡɚɝɨɥɨɜɤɚ Ɋɚɛɨɬɚ ɩɪɢɥɨɠɟɧɢɹ ɞɨɥɠɧɚ ɧɚɱɢɧɚɬɶɫɹ ɫ ɜɜɨɞɚ ɩɚɪɨɥɹ. ɉɪɢ ɪɚɛɨɬɟ ɫ ɮɨɪɦɚɦɢ ɞɨɥɠɧɚ ɫɭɳɟɫɬɜɨɜɚɬɶ ɜɨɡɦɨɠɧɨɫɬɶ ɩɟɪɟɯɨɞɚ ɨɬ ɮɨɪɦɵ ɤ ɮɨɪɦɟ. ȼ ɤɚɠɞɵɣ ɦɨɦɟɧɬ ɜɪɟɦɟɧɢ ɧɚ ɷɤɪɚɧɟ ɜɢɞɢɦɨɣ ɞɨɥɠɧɚ ɛɵɬɶ ɬɨɥɶɤɨ ɨɞɧɚ ɮɨɪɦɚ. ȼɨɡɦɨɠɧɨɫɬɶɸ ɩɪɟɤɪɚɬɢɬɶ ɪɚɛɨɬɭ ɩɪɢɥɨɠɟɧɢɹ ɞɨɥɠɧɵ ɨɛɥɚɞɚɬɶ ɮɨɪɦɵ ɥɚɛɨɪɚɬɨɪɧɵɯ ɪɚɛɨɬ Ƚɥɚɜɧɚɹ ɮɨɪɦɚ ɞɨɥɠɧɚ ɩɪɟɞɨɫɬɚɜɢɬɶ ɜɵɛɨɪ: 1) ɥɚɛɨɪɚɬɨɪɧɚɹ ɪɚɛɨɬɚ ʋ 2; 2) ɥɚɛɨɪɚɬɨɪɧɚɹ ɪɚɛɨɬɚ ʋ 4; 3) ɤɨɧɟɰ ɪɚɛɨɬɵ. ɂɡ ɤɚɠɞɨɣ ɥɚɛɨɪɚɬɨɪɧɨɣ ɪɚɛɨɬɵ ɞɨɥɠɧɚ ɫɭɳɟɫɬɜɨɜɚɬɶ ɜɨɡɦɨɠɧɨɫɬɶ ɜɟɪɧɭɬɶɫɹ ɤ ɝɥɚɜɧɨɣ ɮɨɪɦɟ. ȼɨɡɦɨɠɧɨɫɬɶ ɡɚɤɨɧɱɢɬɶ ɪɚɛɨɬɭ ɩɪɢɥɨɠɟɧɢɹ ɞɨɥɠɧɚ ɫɭɳɟɫɬɜɨɜɚɬɶ ɬɨɥɶɤɨ ɩɪɢ ɪɚɛɨɬɟ ɫ ɝɥɚɜɧɨɣ ɮɨɪɦɨɣ
ɉɪɨɝɪɚɦɦɭ ɡɚɩɢɲɢɬɟ ɜ ɜɚɲ ɤɚɬɚɥɨɝ Lab_4. 3.4. Ƚɥɚɜɧɨɟ ɦɟɧɸ ɮɨɪɦɵ. ȼɫɩɨɦɨɝɚɬɟɥɶɧɵɟ ɦɟɧɸ. ɋɬɚɧɞɚɪɬɧɵɟ ɞɢɚɥɨɝɢ. ɉɪɨɝɪɚɦɦɵ, ɭɩɪɚɜɥɹɟɦɵɟ ɫɨɛɵɬɢɹɦɢ. ɋɨɛɵɬɢɹ, ɨɛɪɚɛɚɬɵɜɚɟɦɵɟ ɮɨɪɦɨɣ. ɋɨɛɵɬɢɹ ɨɬ ɤɥɚɜɢɚɬɭɪɵ ɢ ɦɵɲɢ. ɋɨɛɵɬɢɹ ɩɪɨɬɨɤɨɥɚ Drag & Drop ɐɟɥɶ: ɢɡɭɱɢɬɶ ɧɚɛɨɪ ɨɛɪɚɛɨɬɱɢɤɨɜ ɫɨɛɵɬɢɣ, ɫɜɹɡɚɧɧɵɯ ɫ ɦɵɲɶɸ ɢ ɤɥɚɜɢɚɬɭɪɨɣ; ɨɡɧɚɤɨɦɢɬɶɫɹ ɫ ɪɟɚɥɢɡɚɰɢɟɣ ɢɧɬɟɪɮɟɣɫɚ Drag & drop. Ɋɟɡɭɥɶɬɚɬ ɨɛɭɱɟɧɢɹ: ɩɨɫɥɟ ɭɫɩɟɲɧɨɝɨ ɡɚɜɟɪɲɟɧɢɹ ɡɚɧɹɬɢɹ ɩɨɥɶɡɨɜɚɬɟɥɶ ɞɨɥɠɟɧ: – ɡɧɚɬɶ ɫɩɨɫɨɛɵ ɫɨɡɞɚɧɢɹ ɝɥɚɜɧɨɝɨ ɢ ɜɫɩɨɦɨɝɚɬɟɥɶɧɨɝɨ ɦɟɧɸ; – ɡɧɚɬɶ ɤɨɦɩɨɧɟɧɬɵ ɩɚɧɟɥɢ Dialogs; – ɭɦɟɬɶ ɢɫɩɨɥɶɡɨɜɚɬɶ ɦɟɬɨɞ Execute ɜ ɨɪɝɚɧɢɡɚɰɢɢ ɫɬɚɧɞɚɪɬɧɵɯ ɞɢɚɥɨɝɨɜ; – ɭɦɟɬɶ ɢɫɩɨɥɶɡɨɜɚɬɶ ɤɨɦɩɨɧɟɧɬ TImage ɜ ɩɪɢɥɨɠɟɧɢɹɯ;
46
– ɡɧɚɬɶ ɨɛɪɚɛɨɬɱɢɤɢ ɫɨɛɵɬɢɣ: OnMouseDown; OnMouseUp; OnMouseMove; OnClick; OnDblClick; OnKeyDown; OnKeyUp; OnKeyPress; OnDragOver; OnDragDrop. – ɢɡɭɱɢɬɶ ɫɜɨɣɫɬɜɚ DragMode ɢ DragCursor. ɂɫɩɨɥɶɡɭɟɦɚɹ ɩɚɩɤɚ: Lab5. ɉɥɚɧ ɡɚɧɹɬɢɹ ɑɚɫɬɶ I. Ƚɥɚɜɧɨɟ ɦɟɧɸ ɮɨɪɦɵ. ȼɫɩɨɦɨɝɚɬɟɥɶɧɵɟ ɦɟɧɸ. ɋɬɚɧɞɚɪɬɧɵɟ ɞɢɚɥɨɝɢ. 1. Ƚɥɚɜɧɨɟ ɦɟɧɸ ɮɨɪɦɵ. ȼɫɩɨɦɨɝɚɬɟɥɶɧɵɟ ɦɟɧɸ. ɋɬɚɧɞɚɪɬɧɵɟ ɞɢɚɥɨɝɢ: ɪɚɛɨɬɚ ɩɨɞ ɪɭɤɨɜɨɞɫɬɜɨɦ ɩɪɟɩɨɞɚɜɚɬɟɥɹ 20 ɦɢɧɭɬ. 2. ɋɚɦɨɫɬɨɹɬɟɥɶɧɚɹ ɪɚɛɨɬɚ 60 ɦɢɧɭɬ. ɑɚɫɬɶ II. ɉɪɨɝɪɚɦɦɵ, ɭɩɪɚɜɥɹɟɦɵɟ ɫɨɛɵɬɢɹɦɢ. ɋɨɛɵɬɢɹ, ɨɛɪɚɛɚɬɵɜɚɟɦɵɟ ɮɨɪɦɨɣ. ɋɨɛɵɬɢɹ ɨɬ ɤɥɚɜɢɚɬɭɪɵ ɢ ɦɵɲɢ. ɋɨɛɵɬɢɹ ɩɪɨɬɨɤɨɥɚ Drag & Drop. 1. Ʉɨɦɩɨɧɟɧɬ TStatusBar, ɫɜɹɡɚɧɧɵɟ ɫ ɤɥɚɜɢɚɬɭɪɨɣ. Ɉɛɪɚɛɨɬɱɢɤɢ ɫɨɛɵɬɢɣ, ɫɜɹɡɚɧɧɵɟ ɫ ɦɵɲɶɸ. ɂɧɬɟɪɮɟɣɫ Drag & Drop. Ɉɛɳɟɟ ɫɜɨɣɫɬɜɨ ɜɢɞɢɦɵɯ ɤɨɦɩɨɧɟɧɬɨɜ Hint: ɪɚɛɨɬɚ ɩɨɞ ɪɭɤɨɜɨɞɫɬɜɨɦ ɩɪɟɩɨɞɚɜɚɬɟɥɹ 40 ɦɢɧɭɬ 2. ɋɚɦɨɫɬɨɹɬɟɥɶɧɚɹ ɪɚɛɨɬɚ 40 ɦɢɧɭɬ. ɑɚɫɬɶ I. Ƚɥɚɜɧɨɟ ɦɟɧɸ ɮɨɪɦɵ. ȼɫɩɨɦɨɝɚɬɟɥɶɧɵɟ ɦɟɧɸ. ɋɬɚɧɞɚɪɬɧɵɟ ɞɢɚɥɨɝɢ 1. Ƚɥɚɜɧɨɟ ɦɟɧɸ ɮɨɪɦɵ. ȼɫɩɨɦɨɝɚɬɟɥɶɧɵɟ ɦɟɧɸ. ɋɬɚɧɞɚɪɬɧɵɟ ɞɢɚɥɨɝɢ Ʌɸɛɨɟ ɫɨɜɪɟɦɟɧɧɨɟ ɩɪɢɥɨɠɟɧɢɟ ɢɦɟɟɬ ɦɟɧɸ. Ɇɟɧɸ ɨɛɟɫɩɟɱɢɜɚɟɬ ɫɬɚɧɞɚɪɬɧɵɣ ɢ ɭɞɨɛɧɵɣ ɞɨɫɬɭɩ ɤ ɮɭɧɤɰɢɹɦ ɩɪɢɥɨɠɟɧɢɹ ɢ ɫɬɪɭɤɬɭɪɢɪɭɟɬ ɢɯ ɜ ɨɞɧɨɪɨɞɧɵɟ ɝɪɭɩɩɵ. Ƚɥɚɜɧɨɟ ɦɟɧɸ ɮɨɪɦɵ ɨɩɪɟɞɟɥɹɟɬ ɤɨɦɩɨɧɟɧɬ ɤɥɚɫɫɚ TɆainMenu. ɇɚ ɮɨɪɦɭ ɦɨɠɧɨ ɩɨɦɟɫɬɢɬɶ ɫɤɨɥɶɤɨ ɭɝɨɞɧɨ ɨɛɴɟɤɬɨɜ ɷɬɨɝɨ ɤɥɚɫɫɚ, ɧɨ ɨɬɨɛɪɚɠɚɬɶɫɹ ɜ ɩɨɥɨɫɟ ɦɟɧɸ ɜ ɜɟɪɯɧɟɣ ɱɚɫɬɢ ɮɨɪɦɵ ɛɭɞɟɬ ɬɨɥɶɤɨ ɬɨɬ ɢɡ ɧɢɯ, ɤɨɬɨɪɵɣ ɭɤɚɡɚɧ ɜ ɫɜɨɣɫɬɜɟ Menu ɮɨɪɦɵ. Ⱦɥɹ ɤɨɦɩɨɧɟɧɬɚ TɆainMenu ɜɵɡɵɜɚɟɬɫɹ Menu Designer, ɳɟɥɱɤɨɦ ɩɨ ɤɧɨɩɤɟ ɜ ɩɪɚɜɨɣ ɩɨɥɨɜɢɧɟ ɫɬɪɨɤɢ Items ɂɧɫɩɟɤɬɨɪɚ ɨɛɴɟɤɬɨɜ. Ɍɟɤɫɬ ɨɩɰɢɢ ɜɜɨɞɢɬɫɹ ɜ ɫɬɪɨɤɟ Caption ɨɤɧɚ ɂɧɫɩɟɤɬɨɪɚ ɨɛɴɟɤɬɨɜ. Ɉɩɰɢɢ ɦɟɧɸ ɦɨɠɧɨ ɪɚɡɞɟɥɢɬɶ ɱɟɪɬɨɣ, ɟɫɥɢ ɨɱɟɪɟɞɧɨɣ ɷɥɟɦɟɧɬ ɦɟɧɸ ɧɚɡɜɚɬɶ ɢɦɟɧɟɦ «–». ȼɫɩɨɦɨɝɚɬɟɥɶɧɨɟ ɦɟɧɸ ɫɨɡɞɚɟɬɫɹ ɫ ɩɨɦɨɳɶɸ ɤɨɦɩɨɧɟɧɬɚ TPopupMenu. ɇɚɡɜɚɧɢɹ ɨɩɰɢɣ ɜɫɩɨɦɨɝɚɬɟɥɶɧɨɝɨ ɦɟɧɸ ɨɩɪɟɞɟɥɹɸɬɫɹ ɫ ɩɨɦɨɳɶɸ Menu Designer, ɤɨɬɨɪɵɣ ɜɵɡɵɜɚɟɬɫɹ ɞɜɨɣɧɵɦ ɳɟɥɱɤɨɦ ɦɵɲɢ ɩɨ ɤɨɦɩɨɧɟɧɬɭ TPopupMenu, ɭɫɬɚɧɨɜɥɟɧɧɨɦɭ ɧɚ ɮɨɪɦɟ. ɑɬɨɛɵ ɫɜɹɡɚɬɶ ɳɟɥɱɨɤ ɩɪɚɜɨɣ ɤɧɨɩɤɨɣ ɦɵɲɢ ɧɚ ɤɚɤɨɦ-ɥɢɛɨ ɤɨɦɩɨɧɟɧɬɟ ɫ ɪɚɫɤɪɵɬɢɟɦ ɜɫɩɨɦɨɝɚɬɟɥɶɧɨɝɨ ɦɟɧɸ, ɜ ɫɜɨɣɫɬɜɨ PopupMenu ɤɨɦɩɨɧɟɧɬɚ ɧɟɨɛɯɨɞɢɦɨ ɩɨɦɟɫɬɢɬɶ ɢɦɹ ɤɨɦɩɨɧɟɧɬɚ-ɦɟɧɸ. Ɇɨɠɧɨ ɜɵɛɪɚɬɶ ɢɦɹ ɜɫɩɨɦɨɝɚɬɟɥɶɧɨɝɨ ɦɟɧɸ ɢɡ ɫɩɢɫɤɚ ɫɜɨɣɫɬɜɚ PopupMenu. ȼɵɩɨɥɧɟɧɢɟ ɰɟɥɨɣ ɝɪɭɩɩɵ ɨɩɟɪɚɰɢɣ, ɧɚɢɛɨɥɟɟ ɱɚɫɬɨ ɢɫɩɨɥɶɡɭɟɦɵɯ ɩɪɢɥɨɠɟɧɢɹɦɢ, ɨɛɟɫɩɟɱɢɜɚɟɬɫɹ ɫɬɚɧɞɚɪɬɧɵɦɢ ɞɢɚɥɨɝɚɦɢ. Ʉ ɧɢɦ ɨɬɧɨɫɹɬɫɹ ɞɢɚɥɨɝɢ ɨɬɤɪɵɬɢɹ ɢ ɫɨɯɪɚɧɟɧɢɹ ɮɚɣɥɨɜ, ɩɟɱɚɬɢ ɞɨɤɭɦɟɧɬɨɜ, ɭɫɬɚɧɨɜɤɢ ɩɚ47
ɪɚɦɟɬɪɨɜ ɲɪɢɮɬɚ ɢ ɬ. ɞ. ȼ ɫɨɫɬɚɜɟ Delphi ɢɦɟɟɬɫɹ ɧɚɛɨɪ ɤɨɦɩɨɧɟɧɬɨɜ, ɢɧɤɚɩɫɭɥɢɪɭɸɳɢɯ ɫɬɚɧɞɚɪɬɧɵɟ ɫɢɫɬɟɦɧɵɟ ɞɢɚɥɨɝɢ. Ɉɧɢ ɪɚɡɦɟɳɟɧɵ ɧɚ ɫɬɪɚɧɢɰɟ Dialogs ɩɚɥɢɬɪɵ ɤɨɦɩɨɧɟɧɬɨɜ. ɋɚɦɢ ɤɨɦɩɨɧɟɧɬɵ ɹɜɥɹɸɬɫɹ ɧɟɜɢɡɭɚɥɶɧɵɦɢ, ɧɨ ɨɛɟɫɩɟɱɢɜɚɸɬ ɩɨɹɜɥɟɧɢɟ ɫɨɨɬɜɟɬɫɬɜɭɸɳɢɯ ɞɢɚɥɨɝɨɜ ɩɪɢ ɜɵɡɨɜɟ ɢɡ ɦɟɧɸ ɢɥɢ ɩɚɧɟɥɢ ɢɧɫɬɪɭɦɟɧɬɨɜ ɩɪɢɥɨɠɟɧɢɹ. ȼɵɡɨɜ ɞɢɚɥɨɝɨɜɨɣ ɮɨɪɦɵ ɜɨ ɜɪɟɦɹ ɪɚɛɨɬɵ ɩɪɢɥɨɠɟɧɢɹ ɨɫɭɳɟɫɬɜɥɹɟɬɫɹ ɦɟɬɨɞɨɦ Execute, ɜɨɡɜɪɚɳɚɸɳɢɦ ɪɟɡɭɥɶɬɚɬ ɥɨɝɢɱɟɫɤɨɝɨ ɬɢɩɚ. ȿɫɥɢ ɩɨɥɶɡɨɜɚɬɟɥɶ, ɧɚɩɪɢɦɟɪ, ɜɵɛɪɚɥ ɮɚɣɥ ɢ ɧɚɠɚɥ ɤɧɨɩɤɭ , ɬɨ ɮɭɧɤɰɢɹ ɜɨɡɜɪɚɳɚɟɬ True. Ʉɨɦɩɨɧɟɧɬ Image ɫɥɭɠɢɬ ɞɥɹ ɪɚɡɦɟɳɟɧɢɹ ɧɚ ɮɨɪɦɟ ɨɞɧɨɝɨ ɢɡ ɬɪɟɯ ɩɨɞɞɟɪɠɢɜɚɟɦɵɯ Delphi ɬɢɩɨɜ ɢɡɨɛɪɚɠɟɧɢɣ: ɪɚɫɬɪɨɜɨɣ ɤɚɪɬɢɧɤɢ, ɩɢɤɬɨɝɪɚɦɦɵ ɢɥɢ ɦɟɬɚɮɚɣɥɚ. ɋɜɨɣɫɬɜɨ Picture ɫɥɭɠɢɬ ɤɨɧɬɟɣɧɟɪɨɦ ɢɡɨɛɪɚɠɟɧɢɹ. ȼ ɢɧɫɩɟɤɬɨɪɟ ɨɛɴɟɤɬɨɜ ɜ ɩɪɚɜɨɣ ɱɚɫɬɢ ɫɬɪɨɤɢ ɷɬɨɝɨ ɫɜɨɣɫɬɜɚ ɜɵɡɵɜɚɟɬɫɹ ɞɢɚɥɨɝɨɜɚɹ ɩɚɧɟɥɶ ɡɚɝɪɭɡɤɢ ɝɪɚɮɢɱɟɫɤɨɝɨ ɮɚɣɥɚ. ɋɜɨɣɫɬɜɨ Stretch ɪɚɡɪɟɲɚɟɬ/ɡɚɩɪɟɳɚɟɬ ɢɡɦɟɧɹɬɶ ɪɚɡɦɟɪ ɢɡɨɛɪɚɠɟɧɢɹ ɬɚɤ, ɱɬɨɛɵ ɨɧɨ ɰɟɥɢɤɨɦ ɡɚɩɨɥɧɢɥɨ ɤɥɢɟɧɬɫɤɭɸ ɨɛɥɚɫɬɶ ɤɨɦɩɨɧɟɧɬɚ. ɉɨɡɧɚɤɨɦɢɬɶɫɹ ɫ ɩɪɢɦɟɧɟɧɢɟɦ ɢɡɭɱɚɟɦɵɯ ɤɨɦɩɨɧɟɧɬɨɜ ɦɨɠɧɨ, ɜɵɡɜɚɜ ɩɪɨɟɤɬ Project5, ɪɚɫɩɨɥɨɠɟɧɧɵɣ ɜ ɩɚɩɤɟ Lab5. ɉɪɨɝɪɚɦɦɚ ɩɨɡɜɨɥɹɟɬ ɜɵɡɵɜɚɬɶ ɮɨɪɦɭ ɥɚɛɨɪɚɬɨɪɧɨɣ ɪɚɛɨɬɵ ʋ 2, ɡɚɩɢɫɵɜɚɬɶ ɜ ɮɚɣɥ ɢ ɨɬɤɪɵɜɚɬɶ ɢɡ ɮɚɣɥɚ ɞɚɧɧɵɟ ɷɤɡɚɦɟɧɚɰɢɨɧɧɨɣ ɜɟɞɨɦɨɫɬɢ. Ɏɨɪɦɵ ɩɪɨɝɪɚɦɦɵ ɧɚ ɷɬɚɩɟ ɤɨɧɫɬɪɭɢɪɨɜɚɧɢɹ ɩɪɟɞɫɬɚɜɥɟɧɵ ɧɚ ɪɢɫ. 3.4.1, ɨɤɧɚ ɪɚɛɨɬɚɸɳɟɣ ɩɪɨɝɪɚɦɦɵ ɧɚ ɪɢɫ 3.4.2.
ɚ)
ɛ)
ɜ) Ɋɢɫ. 3.4.1. Ɏɨɪɦɵ ɩɪɨɝɪɚɦɦɵ ɧɚ ɷɬɚɩɟ ɤɨɧɫɬɪɭɢɪɨɜɚɧɢɹ 48
ɚ)
ɛ)
ɜ)
ɝ)
ɞ)
ɟ)
49
ɠ) ɡ) Ɋɢɫ. 3.4.2. Ɉɤɧɚ ɪɚɛɨɬɚɸɳɟɣ ɩɪɨɝɪɚɦɦɵ Ʌɢɫɬɢɧɝ ɩɪɨɝɪɚɦɦɧɵɯ ɦɨɞɭɥɟɣ: unit U5; { } Interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, Menus, jpeg, ExtCtrls, StdCtrls; type TForm1 = class(TForm) Image1: TImage; MainMenu1: TMainMenu; Memo1: TMemo; N21: TMenuItem; PopupMenu1: TPopupMenu; N1: TMenuItem; Label1: TLabel; FontDialog1: TFontDialog; N2: TMenuItem; N3: TMenuItem; procedure N21Click(Sender: TObject); procedure FormActivate(Sender: TObject); procedure N1Click(Sender: TObject); private { Private declarations } public { Public declarations } end; 50
var Form1: TForm1; implementation uses u51; {$R *.dfm} procedure TForm1.N21Click(Sender: TObject); begin form2.Show; end; procedure TForm1.FormActivate(Sender: TObject); begin Memo1.Lines.Add('Ʌɚɛɨɪɚɬɨɪɧɚɹ ɪɚɛɨɬɚ ʋ5'); end; procedure TForm1.N1Click(Sender: TObject); begin if FontDialog1.Execute then Memo1.Font:=FontDialog1.Font end; end. { U5} unit U51; { } interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, Grids, Menus, StdCtrls, Buttons; type TForm2 = class(TForm) MainMenu1: TMainMenu; N1: TMenuItem; N2: TMenuItem; N3: TMenuItem; N4: TMenuItem; StringGrid1: TStringGrid; SaveDialog1: TSaveDialog; OpenDialog1: TOpenDialog; N5: TMenuItem; BitBtn1: TBitBtn; procedure FormActivate(Sender: TObject); procedure StringGrid1SetEditText(Sender: TObject; ACol, ARow: Integer;const Value: String); 51
procedure N3Click(Sender: TObject); procedure N5Click(Sender: TObject); procedure BitBtn1Click(Sender: TObject); procedure N4Click(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form2: TForm2; implementation {$R *.dfm} const nn = 5; //Ɇɚɤɫɢɦɚɥɶɧɨɟ ɤɨɥɢɱɟɫɬɜɨ ɭɱɟɧɢɤɨɜ = 5 mm = 5; //Ɇɚɤɫɢɦɚɥɶɧɨɟ ɤɨɥɢɱɟɫɬɜɨ ɷɤɡɚɦɟɧɨɜ = 5 type T_a = array [1..nn, 1..mm] of real; T_sr=array [1..nn] of real; Tf_type = record make : T_a; sr : T_sr; end; var a : T_a; //a - ɦɚɫɫɢɜ ɨɰɟɧɨɤ ss : T_sr;//ss - ɦɚɫɫɢɜ ɞɥɹ ɫɪɟɞɧɟɝɨ ɛɚɥɥɚ ɭɱɟɧɢɤɨɜ f_p : Tf_type; {ɗɤɡɟɦɩɥɹɪ ɡɚɩɢɫɢ} f : file of Tf_type; {Ɏɚɣɥ} procedure TForm2.FormActivate(Sender: TObject); var i :integer; begin stringGrid1.Cells[0,0]:='ɇɨɦɟɪ ɫɬɭɞɟɧɬɚ'; for i:=1 to nn do stringGrid1.Cells[0,i]:='ʋ '+IntToStr(i); for i:=1 to mm do stringGrid1.Cells[i,0]:='Ɉɰɟɧɤɚ ʋ'+IntToStr(i); stringGrid1.Cells[mm+1,0]:='ɋɪɟɞɧɹɹ ɨɰɟɧɤɚ' end; { TForm2.FormActivate } procedure TForm2.StringGrid1SetEditText(Sender: TObject; ACol, ARow: Integer; const Value: String); 52
var b, k : integer; // b -ɰɟɥɨɟ ɡɧɚɱɟɧɢɟ ɫɬɪɨɤɢ ɪɟɞɚɤɬɢɪɨɜɚɧɢɹ j : byte; //j - ɩɚɪɚɦɟɬɪ ɰɢɤɥɚ ɞɥɹ ɬɟɤɭɳɟɝɨ ɧɨɦɟɪɚ ɫɬɨɥɛɰɚ ɦɚɬɪɢɰɵ begin with StringGrid1 do begin if Value = '' then Exit; //ȿɫɥɢ ɧɢɱɟɝɨ ɧɟ ɜɜɟɞɟɧɨ, ɬɨ ɜɵɣɬɢ ɢɡ ɩɪɨɰɟɞɭɪɵ //ɇɚɱɚɥɨ ɡɚɳɢɳɟɧɧɨɝɨ ɛɥɨɤɚ try b := StrToInt(Value) except ShowMessage('ɇɟ ɜɟɪɧɵɣ ɫɢɦɜɨɥ!'); b:=0 end; //Ʉɨɧɟɰ ɡɚɳɢɳɟɧɧɨɝɨ ɛɥɨɤɚ. //ɂɝɧɨɪɢɪɨɜɚɬɶ ɧɟɜɟɪɧɨ ɜɜɟɞɟɧɧɭɸ ɨɰɟɧɤɭ if (b<1) or (b>5) then begin Cells[Acol,Arow]:=''; Exit; end; Cells[Acol,Arow]:=Value; //Ɉɬɪɚɡɢɬɶ ɨɰɟɧɤɭ ɜ ɬɚɛɥɢɰɟ A[arow,Acol]:=b; //Ɂɚɩɢɫɚɬɶ ɨɰɟɧɤɭ ɜ ɦɚɫɫɢɜ //Ⱦɚɥɟɟ ɩɨɞɫɱɟɬ ɫɪɟɞɧɟɝɨ ɛɚɥɥɚ. SS[Arow]:=0; k:=0; //ɋɱɟɬɱɢɤ ɱɢɫɥɚ ɜɜɟɞɟɧɧɵɯ ɨɰɟɧɨɤ for j:=1 to 4 do begin SS[Arow]:=SS[Arow]+a[Arow,j]; if StringGrid1.Cells[j,Arow]<>'' then k:=k+1; end; if k<>0 then SS[Arow]:= SS[Arow]/k else SS[Arow]:=0; //Ɉɬɨɛɪɚɡɢɬɶ ɫɪɟɞɧɢɣ ɛɚɥɥ ɜ 5-ɨɦ ɫɬɨɥɛɰɟ ɬɚɛɥɢɰɵ. Cells[mm+1, Arow] := FormatFloat('##.##', SS[Arow]) end; end; { TForm2.StringGrid1SetEditText } procedure TForm2.N3Click(Sender: TObject); var i: integer; {ɋɱɟɬɱɢɤ} 53
begin if SaveDialog1.Execute then {ɟɫɥɢ ɞɢɚɥɨɝ ɡɚɤɪɵɬ ɤɧɨɩɤɨɣ "ɋɨɯɪɚɧɢɬɶ"} begin AssignFile(F,SaveDialog1.FileName); Rewrite(F); {ɨɬɤɪɵɬɶ ɮɚɣɥ ɧɚ ɡɚɩɢɫɶ} f_p.make:=a; f_p.sr:=ss; write(F,f_p); {ɞɨɛɚɜɢɬɶ ɡɚɩɢɫɶ ɜ ɮɚɣɥ} CloseFile(F); {Ɂɚɤɪɵɬɶ ɮɚɣɥ} end; end; {TForm2.N3Click} procedure TForm2.N5Click(Sender: TObject); var i,j: integer; {ɋɱɟɬɱɢɤ} begin if OpenDialog1.Execute then {ɟɫɥɢ ɞɢɚɥɨɝ ɡɚɤɪɵɬ ɤɧɨɩɤɨɣ "Ɉɬɤɪɵɬɶ"} begin AssignFile(F,OpenDialog1.FileName); Reset(F); {ɨɬɤɪɵɬɶ ɮɚɣɥ ɧɚ ɱɬɟɧɢɟ} read(F,f_p); {ɱɢɬɚɟɦ ɡɚɩɢɫɶ ɢɡ ɮɚɣɥɚ} for i:=1 to nn do for j:=1 to mm do begin StringGrid1.Cells[j,i]:=FloatToStr(f_p.make[i,j]); StringGrid1.Cells[mm+1,i]:=FloatToStr(f_p.sr[i]); end; CloseFile(F); {Ɂɚɤɪɵɬɶ ɮɚɣɥ} end; end; { TForm2.N5Click } procedure TForm2.BitBtn1Click(Sender: TObject); var i,j: integer; begin for i:=1 to nn do for j:=1 to mm+1 do StringGrid1.Cells[j,i]:=''; end; { TForm2.BitBtn1Click } procedure TForm2.N4Click(Sender: TObject); 54
begin close; end; { TForm2.N4Click } end. { unit U51 } 2. ɋɚɦɨɫɬɨɹɬɟɥɶɧɚɹ ɪɚɛɨɬɚ Ɂɚɞɚɧɢɟ. Ɉɫɬɚɜɢɬɶ ɩɪɨɝɪɚɦɦɭ, ɫɨɨɬɜɟɬɫɬɜɟɧɧɨ ɩɪɟɞɥɚɝɚɟɦɨɦɭ ɜɚɪɢɚɧɬɭ. ȼɚɪɢɚɧɬɵ
1
2
3
4
ɂɫɯɨɞɧɵɟ ɞɚɧɧɵɟ 1. ɇɚ ɝɥɚɜɧɭɸ ɮɨɪɦɭ ɩɪɢɥɨɠɟɧɢɹ ɩɨɦɟɫɬɢɬɟ ɤɨɦɩɨɧɟɧɬ TImage. ȼɵɛɟɪɢɬɟ ɩɨɧɪɚɜɢɜɲɭɸɫɹ ɜɚɦ ɤɚɪɬɢɧɤɭ ɢɡ ɩɨɞɤɚɬɚɥɨɝɚ Images\Splash. 2. ɋ ɩɨɦɨɳɶɸ ɫɬɚɧɞɚɪɬɧɨɝɨ ɞɢɚɥɨɝɚ ɌFontDialog ɨɫɭɳɟɫɬɜɢɬɟ ɜɨɡɦɨɠɧɨɫɬɶ ɢɡɦɟɧɟɧɢɹ ɲɪɢɮɬɚ ɜ ɤɨɦɩɨɧɟɧɬɟ Memo1 ɥɚɛɨɪɚɬɨɪɧɨɣ ɪɚɛɨɬɵ ʋ 2. 3. Ɉɫɭɳɟɫɬɜɢɬɟ ɡɚɩɢɫɶ ɪɟɡɭɥɶɬɚɬɨɜ ɪɚɫɱɟɬɨɜ ɜ ɥɚɛɨɪɚɬɨɪɧɨɣ ɪɚɛɨɬɟ ʋ 2. ɂɫɩɨɥɶɡɭɣɬɟ TSaveDialog. ɗɬɢ ɮɭɧɤɰɢɢ ɩɪɢɥɨɠɟɧɢɹ ɞɨɥɠɧɵ ɜɵɩɨɥɧɹɬɶɫɹ ɫ ɩɨɦɨɳɶɸ ɝɥɚɜɧɨɝɨ ɢ ɜɫɩɨɦɨɝɚɬɟɥɶɧɨɝɨ ɦɟɧɸ 1. ɇɚ ɝɥɚɜɧɭɸ ɮɨɪɦɭ ɩɪɢɥɨɠɟɧɢɹ ɩɨɦɟɫɬɢɬɟ ɤɨɦɩɨɧɟɧɬ TImage. ȼɵɛɟɪɢɬɟ ɩɨɧɪɚɜɢɜɲɭɸɫɹ ȼɚɦ ɤɚɪɬɢɧɤɭ ɢɡ ɩɨɞɤɚɬɚɥɨɝɚ Images\Splash. 2. ɋ ɩɨɦɨɳɶɸ ɜɫɩɨɦɨɝɚɬɟɥɶɧɨɝɨ ɦɟɧɸ ɢ ɤɨɦɩɨɧɟɧɬɚ ɌOpenPictureDialog ɨɫɭɳɟɫɬɜɢɬɟ ɜɨɡɦɨɠɧɨɫɬɶ ɢɡɦɟɧɟɧɢɹ ɝɪɚɮɢɱɟɫɤɨɝɨ ɮɚɣɥɚ. 3. ɋɨɡɞɚɣɬɟ ɝɥɚɜɧɨɟ ɦɟɧɸ ɮɨɪɦɵ ɥɚɛɨɪɚɬɨɪɧɨɣ ɪɚɛɨɬɵ ʋ 2: «Ɋɟɠɢɦ ɪɚɛɨɬɵ»; «ɇɚɫɬɪɨɣɤɚ». ȼ ɩɭɧɤɬɟ ɦɟɧɸ «Ɋɟɠɢɦ ɪɚɛɨɬɵ» ɞɨɥɠɧɵ ɫɭɳɟɫɬɜɨɜɚɬɶ ɩɨɞɨɩɰɢɢ: «Ɋɚɫɱɟɬ ɟɞɢɧɢɱɧɵɣ»; «Ɋɚɫɱɟɬ ɢɧɬɟɪɜɚɥɶɧɵɣ», «Ɂɚɩɢɫɶ ɪɟɡɭɥɶɬɚɬɨɜ ɪɚɫɱɟɬɚ ɜ ɮɚɣɥ» 1. ɇɚ ɝɥɚɜɧɭɸ ɮɨɪɦɭ ɩɪɢɥɨɠɟɧɢɹ ɩɨɦɟɫɬɢɬɟ ɤɨɦɩɨɧɟɧɬ TImage. ȼɵɛɟɪɢɬɟ ɩɨɧɪɚɜɢɜɲɭɸɫɹ ɜɚɦ ɤɚɪɬɢɧɤɭ ɢɡ ɩɨɞɤɚɬɚɥɨɝɚ Images\Splash. 2. ɋ ɩɨɦɨɳɶɸ ɤɨɦɩɨɧɟɧɬɚ TColorDialog ɨɫɭɳɟɫɬɜɢɬɟ ɜɨɡɦɨɠɧɨɫɬɶ ɢɡɦɟɧɟɧɢɹ ɰɜɟɬɚ ɬɚɛɥɢɰɵ TStringGrid. 3. Ɉɫɭɳɟɫɬɜɢɬɟ ɡɚɩɢɫɶ ɪɟɡɭɥɶɬɚɬɨɜ ɪɚɫɱɟɬɚ ɜ ɥɚɛɨɪɚɬɨɪɧɨɣ ɪɚɛɨɬɟ ʋ 3. ɗɬɢ ɮɭɧɤɰɢɢ ɞɨɥɠɧɵ ɜɵɩɨɥɧɹɬɶɫɹ ɫ ɩɨɦɨɳɶɸ ɝɥɚɜɧɨɝɨ ɢ ɜɫɩɨɦɨɝɚɬɟɥɶɧɨɝɨ ɦɟɧɸ 1. ȼɨɡɦɨɠɧɨɫɬɶ ɩɟɪɟɯɨɞɚ ɨɬ ɮɨɪɦɵ ɤ ɮɨɪɦɟ ɨɫɭɳɟɫɬɜɢɬɶ ɫ ɩɨɦɨɳɶɸ ɝɥɚɜɧɨɝɨ ɦɟɧɸ ɮɨɪɦɵ. 2. ɂɡɦɟɧɟɧɢɟ ɰɜɟɬɚ ɢ ɲɪɢɮɬɚ ɤɨɦɩɨɧɟɧɬɚ ɨɫɭɳɟɫɬɜɢɬɶ ɫ ɩɨɦɨɳɶɸ ɜɫɩɨɦɨɝɚɬɟɥɶɧɨɝɨ ɦɟɧɸ. Ʉɨɦɩɨɧɟɧɬɵ ɜɵɛɪɚɬɶ ɩɨ ɫɜɨ55
5
ɟɦɭ ɭɫɦɨɬɪɟɧɢɸ. 3. ɇɚ ɮɨɪɦɭ ɥɚɛɨɪɚɬɨɪɧɨɣ ɪɚɛɨɬɵ ʋ 4 ɩɨɦɟɫɬɢɬɟ ɤɨɦɩɨɧɟɧɬ TImage. ȼɵɛɟɪɢɬɟ ɩɨɧɪɚɜɢɜɲɭɸɫɹ ȼɚɦ ɤɚɪɬɢɧɤɭ ɢɡ ɩɨɞɤɚɬɚɥɨɝɚ Images\Splash 1. ɇɚ ɝɥɚɜɧɭɸ ɮɨɪɦɭ ɩɪɢɥɨɠɟɧɢɹ ɩɨɦɟɫɬɢɬɟ ɤɨɦɩɨɧɟɧɬ TImage. ȼɵɛɟɪɢɬɟ ɩɨɧɪɚɜɢɜɲɭɸɫɹ ɜɚɦ ɤɚɪɬɢɧɤɭ ɢɡ ɩɨɞɤɚɬɚɥɨɝɚ Images\Splash. 2. ɇɚ ɝɥɚɜɧɨɣ ɮɨɪɦɟ ɫɨɡɞɚɬɶ ɝɥɚɜɧɨɟ ɦɟɧɸ. 3. ɋ ɩɨɦɨɳɶɸ ɜɫɩɨɦɨɝɚɬɟɥɶɧɨɝɨ ɦɟɧɸ ɨɫɭɳɟɫɬɜɢɬɶ ɜɨɡɦɨɠɧɨɫɬɶ ɢɡɦɟɧɟɧɢɹ ɰɜɟɬɚ ɢ ɲɪɢɮɬɚ ɫɨɨɛɳɟɧɢɹ «ɉɪɢɥɨɠɟɧɢɟ ɪɚɡɪɚɛɨɬɚɧɨ…». 4. Ɉɫɭɳɟɫɬɜɢɬɟ ɡɚɩɢɫɶ ɪɟɡɭɥɶɬɚɬɨɜ ɪɚɫɱɟɬɚ ɜ ɥɚɛɨɪɚɬɨɪɧɨɣ ɪɚɛɨɬɟ ʋ 3
ɉɪɨɝɪɚɦɦɭ ɡɚɩɢɲɢɬɟ ɜ ɜɚɲ ɤɚɬɚɥɨɝ Lab_5. ɑɚɫɬɶ II. ɉɪɨɝɪɚɦɦɵ, ɭɩɪɚɜɥɹɟɦɵɟ ɫɨɛɵɬɢɹɦɢ. ɋɨɛɵɬɢɹ, ɨɛɪɚɛɚɬɵɜɚɟɦɵɟ ɮɨɪɦɨɣ. ɋɨɛɵɬɢɹ ɨɬ ɤɥɚɜɢɚɬɭɪɵ ɢ ɦɵɲɢ. ɋɨɛɵɬɢɹ ɩɪɨɬɨɤɨɥɚ Drag & Drop 1. Ʉɨɦɩɨɧɟɧɬ TStatusBar. Ɉɛɪɚɛɨɬɱɢɤɢ ɫɨɛɵɬɢɣ, ɫɜɹɡɚɧɧɵɟ ɫ ɤɥɚɜɢɚɬɭɪɨɣ. Ɉɛɪɚɛɨɬɱɢɤɢ ɫɨɛɵɬɢɣ, ɫɜɹɡɚɧɧɵɟ ɫ ɦɵɲɶɸ. ɂɧɬɟɪɮɟɣɫ Drag & Drop. Ɉɛɳɟɟ ɫɜɨɣɫɬɜɨ ɜɢɞɢɦɵɯ ɤɨɦɩɨɧɟɧɬɨɜ Hint Ⱦɥɹ ɛɨɥɶɲɢɧɫɬɜɚ ɜɢɞɢɦɵɯ ɷɥɟɦɟɧɬɨɜ ɨɩɪɟɞɟɥɟɧ ɧɚɛɨɪ ɨɛɪɚɛɨɬɱɢɤɨɜ ɫɨɛɵɬɢɣ, ɫɜɹɡɚɧɧɵɯ ɫ ɦɵɲɶɸ: – OnMouseDown: TMouseEvent ɢ OnMouseUp: TMouseEvent ɨɩɪɟɞɟɥɹɸɬ ɪɟɚɤɰɢɸ ɩɪɨɝɪɚɦɦɵ ɧɚ ɫɨɨɬɜɟɬɫɬɜɟɧɧɨ ɧɚɠɚɬɢɟ ɢ ɨɬɩɭɫɤɚɧɢɟ ɤɧɨɩɤɢ ɦɵɲɢ; – OnMouseMove: TMouseMoveEvent – ɧɚ ɩɟɪɟɦɟɳɟɧɢɟ ɭɤɚɡɚɬɟɥɹ ɦɵɲɢ ɧɚɞ ɤɨɦɩɨɧɟɧɬɨɦ; – OnClick: TNotifyEvent ɢ OnDblClick:TNotifyEvent – ɫɨɨɬɜɟɬɫɬɜɟɧɧɨ ɧɚ ɳɟɥɱɨɤ ɢ ɞɜɨɣɧɨɣ ɳɟɥɱɨɤ ɥɟɜɨɣ ɤɧɨɩɤɢ. ȼɨ ɜɫɟɯ ɨɛɪɚɛɨɬɱɢɤɚɯ ɩɚɪɚɦɟɬɪ Sender ɫɨɞɟɪɠɢɬ ɫɫɵɥɤɭ ɧɚ ɤɨɦɩɨɧɟɧɬ, ɧɚɞ ɤɨɬɨɪɵɦ ɩɪɨɢɡɨɲɥɨ ɫɨɛɵɬɢɟ, ɚ X ɢ Y ɨɩɪɟɞɟɥɹɸɬ ɤɨɨɪɞɢɧɚɬɵ ɬɨɱɤɢ ɱɭɜɫɬɜɢɬɟɥɶɧɨɫɬɢ ɭɤɚɡɚɬɟɥɹ ɦɵɲɢ ɜ ɦɨɦɟɧɬ ɜɨɡɧɢɤɧɨɜɟɧɢɹ ɫɨɛɵɬɢɹ. ɉɚɪɚɦɟɬɪ Button ɨɩɪɟɞɟɥɹɟɬ ɨɞɧɭ ɢɡ ɬɪɟɯ ɤɧɨɩɨɤ ɦɵɲɢ: ɥɟɜɭɸ (mbLeft), ɩɪɚɜɭɸ (mbRight) ɢ ɫɪɟɞɧɸɸ (mbMiddle). ɉɚɪɚɦɟɬɪ Shift ɫɨɞɟɪɠɢɬ ɩɪɢɡɧɚɤɢ, ɭɬɨɱɧɹɸɳɢɟ ɨɛɫɬɨɹɬɟɥɶɫɬɜɚ ɜɨɡɧɢɤɧɨɜɟɧɢɹ ɫɨɛɵɬɢɹ: ssShift – ɧɚɠɚɬɚ ɤɥɚɜɢɲɚ <Shift>; ssAlt – ɧɚɠɚɬɚ ɤɥɚɜɢɲɚ ; ssCtrl – ; ssLeft – ɧɚɠɚɬɚ ɥɟɜɚɹ ɤɧɨɩɤɚ ɦɵɲɢ; ssRight – ɩɪɚɜɚɹ ɤɧɨɩɤɚ ɦɵɲɢ; ssMiddle – ɫɪɟɞɧɹɹ; ssDouble – ɨɞɧɨɜɪɟɦɟɧɧɨ ɥɟɜɚɹ ɢ ɩɪɚɜɚɹ ɤɧɨɩɤɢ. ɉɨɫɥɟɞɨɜɚɬɟɥɶɧɨɫɬɶ ɜɨɡɧɢɤɧɨɜɟɧɢɹ ɫɨɛɵɬɢɣ: OnMouseDown, OnClick, OnMouseUp, OnDblClick. ɋɨɛɵɬɢɹ ɨɬ ɦɵɲɢ ɩɨɥɭɱɚɸɬ ɥɸɛɵɟ ɩɨɬɨɦɤɢ Tɋontrol. ɋɨɛɵɬɢɹ ɨɬ ɤɥɚɜɢɚɬɭɪɵ ɩɨɥɭɱɚɸɬ ɬɨɥɶɤɨ ɧɟɤɨɬɨɪɵɟ ɨɤɨɧɧɵɟ ɤɨɦɩɨɧɟɧɬɵ: 56
– OnKeyDown ɢ OnKeyUp ɜɨɡɧɢɤɚɸɬ ɩɪɢ ɧɚɠɚɬɢɢ ɢ ɨɬɩɭɫɤɚɧɢɢ ɥɸɛɨɣ ɤɥɚɜɢɲɢ ɤɥɚɜɢɚɬɭɪɵ; – OnKeyPress – ɬɨɥɶɤɨ ɩɪɢ ɧɚɠɚɬɢɢ ɚɥɮɚɜɢɬɧɨ-ɰɢɮɪɨɜɵɯ ɤɥɚɜɢɲ. ɉɚɪɚɦɟɬɪ Shift, ɤɚɤ ɢ ɜ ɨɛɪɚɛɨɬɱɢɤɚɯ ɫɨɛɵɬɢɣ ɨɬ ɦɵɲɢ, ɫɨɞɟɪɠɢɬ ɭɬɨɱɧɹɸɳɢɟ ɩɪɢɡɧɚɤɢ. ɉɚɪɚɦɟɬɪ Key ɫɨɞɟɪɠɢɬ ɤɨɞ ɤɥɚɜɢɲɢ. ɂɧɬɟɪɮɟɣɫ Drag & Drop ɨɩɪɟɞɟɥɹɟɬɫɹ ɞɜɭɦɹ ɫɜɨɣɫɬɜɚɦɢ ɢ ɬɪɟɦɹ ɫɨɛɵɬɢɹɦɢ, ɞɨɫɬɭɩɧɵɦɢ ɤɚɠɞɨɦɭ ɜɢɞɢɦɨɦɭ ɤɨɦɩɨɧɟɧɬɭ: – DragMode ɨɩɪɟɞɟɥɹɟɬ, ɤɚɤ ɛɭɞɟɬ ɜɵɩɨɥɧɹɬɶɫɹ ɜɟɫɶ ɤɨɦɩɥɟɤɫ ɞɟɣɫɬɜɢɣ, ɫɜɹɡɚɧɧɵɯ ɫ Drag & Drop (dmManual, dmAutomatic); – DragCursor ɨɩɪɟɞɟɥɹɟɬ ɜɢɞ ɭɤɚɡɚɬɟɥɹ ɦɵɲɢ; – OnDragOver ɜɨɡɧɢɤɚɟɬ ɜ ɦɨɦɟɧɬ ɩɟɪɟɦɟɳɟɧɢɹ ɭɤɚɡɚɬɟɥɹ ɦɵɲɢ «ɫ ɝɪɭɡɨɦ» ɧɚɞ ɤɨɦɩɨɧɟɧɬɨɦ (ɩɚɪɚɦɟɬɪ Sender – ɤɨɦɩɨɧɟɧɬ, ɤɨɬɨɪɵɣ ɜɨɡɛɭɞɢɥ ɫɨɛɵɬɢɟ; Source – ɤɨɦɩɨɧɟɧɬ-ɨɬɩɪɚɜɢɬɟɥɶ «ɝɪɭɡɚ»; X, Y – ɬɟɤɭɳɢɟ ɤɨɨɪɞɢɧɚɬɵ ɭɤɚɡɚɬɟɥɹ ɦɵɲɢ; State ɫɨɫɬɨɹɧɢɟ ɭɤɚɡɚɬɟɥɹ; Accept – ɝɨɬɨɜɧɨɫɬɶ ɤɨɦɩɨɧɟɧɬɚ ɩɪɢɧɹɬɶ ɞɚɧɧɵɟ); – OnDragDrop ɨɡɧɚɱɚɟɬ, ɱɬɨ ɩɨɥɶɡɨɜɚɬɟɥɶ «ɛɪɨɫɢɥ» ɞɚɧɧɵɟ ɧɚ ɤɨɦɩɨɧɟɧɬ; – OnEndDrag ɜɨɡɧɢɤɚɟɬ ɩɪɢ ɡɚɜɟɪɲɟɧɢɢ ɩɟɪɟɬɚɫɤɢɜɚɧɢɹ (Sender – ɨɬɩɪɚɜɢɬɟɥɶ ɞɚɧɧɵɯ; Targer – ɩɨɥɭɱɚɬɟɥɶ ɞɚɧɧɵɯ ɢɥɢ Nil). 1.1. ɉɨɞɝɨɬɨɜɢɬɟɥɶɧɵɟ ɞɟɣɫɬɜɢɹ 1. ɋɨɡɞɚɣɬɟ ɩɨɞɤɚɬɚɥɨɝ Lab6 ɜ ɫɜɨɟɦ ɤɚɬɚɥɨɝɟ. 2. ɇɚɱɧɢɬɟ ɪɚɡɪɚɛɨɬɤɭ ɧɨɜɨɝɨ ɩɪɨɟɤɬɚ. Ɋɚɡɪɚɛɨɬɚɣɬɟ ɮɨɪɦɭ, ɢɦɟɸɳɭɸ ɬɚɤɭɸ ɠɟ ɤɨɧɫɬɪɭɤɰɢɸ, ɤɚɤ ɧɚ ɪɢɫ. 3.4.3. 3. ɇɚ ɮɨɪɦɟ ɪɚɫɩɨɥɨɠɟɧɵ: ɞɜɟ ɦɟɬɤɢ Label1 ɢ Label2, ɞɜɚ ɨɞɧɨɫɬɪɨɱɧɵɯ ɪɟɞɚɤɬɨɪɚ Edit1 ɢ Edit2, ɞɜɟ ɩɚɧɟɥɢ Panel1 ɢ Panel2; ɨɞɢɧ ɤɨɦɩɨɧɟɧɬ TStatusBar ɫ ɢɦɟɧɟɦ StatusBar1. 1.2. Ʉɨɦɩɨɧɟɧɬ TStatusBar 1. Ʉɨɦɩɨɧɟɧɬ TStatusBar (ɜɤɥɚɞɤɚ Win32) ɩɪɟɞɧɚɡɧɚɱɟɧ ɞɥɹ ɫɨɡɞɚɧɢɹ ɩɚɧɟɥɟɣ ɫɨɫɬɨɹɧɢɹ, ɤɨɬɨɪɵɟ ɨɛɵɱɧɨ ɪɚɫɩɨɥɚɝɚɸɬɫɹ ɜ ɧɢɠɧɟɣ ɱɚɫɬɢ ɨɫɧɨɜɧɨɣ ɮɨɪɦɵ. Ʉɨɦɩɨɧɟɧɬ ɦɨɠɟɬ ɢɦɟɬɶ ɧɟɫɤɨɥɶɤɨ ɫɟɤɰɢɣ. Ʉɨɥɢɱɟɫɬɜɨ ɫɟɤɰɢɣ, ɚ ɬɚɤ ɠɟ ɫɬɢɥɶ ɤɚɠɞɨɣ ɩɚɧɟɥɢ ɡɚɞɚɸɬɫɹ ɫ ɩɨɦɨɳɶɸ ɫɩɟɰɢɚɥɶɧɨɝɨ ɪɟɞɚɤɬɨɪɚ, ɤɨɬɨɪɵɣ ɜɵɡɵɜɚɟɬɫɹ ɫɜɨɣɫɬɜɨɦ Panels. ɗɬɨ ɫɜɨɣɫɬɜɨ ɫɨɞɟɪɠɢɬ ɨɛɴɟɤɬɵ-ɩɚɧɟɥɢ. ɋɜɨɣɫɬɜɨ TStatusPanels.Items[Index: Integer] ɨɬɤɪɵɜɚɟɬ ɞɨɫɬɭɩ ɤ ɩɚɧɟɥɢ ɩɨ ɟɟ ɢɧɞɟɤɫɭ. ɋ ɩɨɦɨɳɶɸ ɫɜɨɣɫɬɜ Width ɢ Height ɢɡɦɟɧɢɬɟ ɞɥɢɧɭ ɢ ɜɵɫɨɬɭ ɤɚɠɞɨɣ ɫɟɤɰɢɢ.
57
Ɋɢɫ. 3.4.3. Windows-ɨɤɧɨ ɨɛɳɟɝɨ ɩɪɢɦɟɪɚ 1.3. ɂɧɬɟɪɮɟɣɫ Drag & Drop ȼ ɩɪɢɥɨɠɟɧɢɢ ɨɫɭɳɟɫɬɜɢɦ ɜɨɡɦɨɠɧɨɫɬɶ ɩɟɪɟɧɨɫɚ ɫɨɞɟɪɠɢɦɨɝɨ ɪɟɞɚɤɬɨɪɚ Edit1 ɜ ɪɟɞɚɤɬɨɪ Edit2. ɋɞɟɥɚɟɦ ɬɚɤ, ɱɬɨɛɵ ɩɚɧɟɥɶ Panel1 ɦɨɠɧɨ ɛɵɥɨ ɩɟɪɟɦɟɳɚɬɶ ɩɨ ɮɨɪɦɟ. 1. ɂɫɬɨɱɧɢɤɚɦɢ ɜ ɦɟɯɚɧɢɡɦɟ Drag & Drop ɛɭɞɭɬ ɤɨɦɩɨɧɟɧɬɵ Panel1 ɢ Edit1. ɍɫɬɚɧɨɜɢɬɟ ɞɥɹ ɤɨɦɩɨɧɟɧɬɨɜ Panel1 ɢ Edit1 ɫɜɨɣɫɬɜɨ DragMode ɪɚɜɧɵɦ dmAutomatic. Ɂɧɚɱɟɧɢɟ dmAutomatic ɨɛɟɫɩɟɱɢɜɚɟɬ ɚɜɬɨɦɚɬɢɱɟɫɤɭɸ ɪɟɚɤɰɢɸ ɤɨɦɩɨɧɟɧɬɚ ɧɚ ɧɚɠɚɬɢɟ ɥɟɜɨɣ ɤɥɚɜɢɲɢ ɦɵɲɢ ɢ ɧɚɱɚɥɨ ɩɟɪɟɬɚɫɤɢɜɚɧɢɹ. Ɉ ɜɤɥɸɱɟɧɢɢ ɦɟɯɚɧɢɡɦɚ ɫɢɝɧɚɥɢɡɢɪɭɟɬ ɭɤɚɡɚɬɟɥɶ ɦɵɲɢ, – ɨɧ ɢɡɦɟɧɹɟɬɫɹ ɧɚ ɤɭɪɫɨɪ, ɨɩɪɟɞɟɥɟɧɧɵɣ ɜ ɫɜɨɣɫɬɜɟ DragCursor. 2. ɉɪɢɟɦɧɢɤɨɦ ɦɨɠɟɬ ɫɬɚɬɶ ɥɸɛɨɣ ɤɨɦɩɨɧɟɧɬ, ɜ ɤɨɬɨɪɨɦ ɫɨɡɞɚɧ ɦɟɬɨɞ–ɨɛɪɚɛɨɬɱɢɤ DragOver. ɋɨɡɞɚɣɬɟ ɨɛɪɚɛɨɬɱɢɤɢ ɫɨɛɵɬɢɣ: – Ⱦɥɹ Edit2: procedure TForm1.Edit2DragOver(Sender, Source: TObject; X, Y: Integer; State: TDragState; var Accept: Boolean); Begin //ȿɫɥɢ ɢɫɬɨɱɧɢɤ ɩɟɪɟɧɨɫɚ ɨɞɧɨɫɬɪɨɱɧɵɣ ɪɟɞɚɤɬɨɪ, ɬɨ Edit2 //ɫɬɚɧɨɜɢɬɫɹ ɩɪɢɟɦɧɢɤɨɦ. If Source.ClassName = 'TEdit' Then Accept := True Else Accept := False; end; – Ⱦɥɹ ɮɨɪɦɵ: procedure TForm1.FormDragOver(Sender, Source: TObject; X, Y: Integer; State: TDragState; var Accept: Boolean); begin //ȿɫɥɢ ɢɫɬɨɱɧɢɤ ɩɟɪɟɧɨɫɚ ɩɚɧɟɥɶ, ɬɨ ɮɨɪɦɚ ɫɬɚɧɨɜɢɬɫɹ ɩɪɢɟɦɧɢɤɨɦ. if Source.ClassName ='TPanel' then Accept := True else 58
Accept := False; end; 3. ɉɪɢɟɦɧɢɤ ɞɨɥɠɟɧ ɩɪɟɞɭɫɦɚɬɪɢɜɚɬɶ ɜɵɩɨɥɧɟɧɢɟ ɧɟɤɨɬɨɪɵɯ ɞɟɣɫɬɜɢɣ, ɜ ɫɥɭɱɚɟ ɟɫɥɢ ɢɫɬɨɱɧɢɤ ɡɚɜɟɪɲɢɬ ɩɟɪɟɬɚɫɤɢɜɚɧɢɟ ɢɦɟɧɧɨ ɧɚ ɧɟɦ. Ⱦɥɹ ɷɬɨɝɨ ɢɫɩɨɥɶɡɭɟɬɫɹ ɦɟɬɨɞ-ɨɛɪɚɛɨɬɱɢɤ OnDragDrop, ɤɨɬɨɪɵɣ ɜɵɡɵɜɚɟɬɫɹ ɩɪɢ ɨɬɩɭɫɤɚɧɢɢ ɥɟɜɨɣ ɤɧɨɩɤɢ ɦɵɲɢ ɧɚ ɤɨɦɩɨɧɟɧɬɟ–ɩɪɢɟɦɧɢɤɟ. – Ⱦɥɹ Ʉɨɦɩɨɧɟɧɬɚ Edit2: procedure TForm1.Edit2DragDrop(Sender, Source: TObject; X, Y: Integer); begin //ɉɟɪɟɞɚɟɦ ɫɨɞɟɪɠɢɦɨɟ ɢɫɬɨɱɧɢɤɚ ɜ ɩɪɢɟɦɧɢɤ. Edit2.text := (Source As TEdit).Text; end; – Ⱦɥɹ ɮɨɪɦɵ: procedure TForm1.FormDragDrop(Sender, Source: TObject; X, Y: Integer); begin //ɍɫɬɚɧɚɜɥɢɜɚɟɦ ɢɫɬɨɱɧɢɤɭ ɤɨɨɪɞɢɧɚɬɵ ɦɵɲɢ, //ɤɨɬɨɪɵɟ ɨɧɚ ɢɦɟɟɬ ɜ ɦɨɦɟɧɬ ɨɩɭɫɤɚɧɢɹ ɤɧɨɩɤɢ (Source As TPanel).Left := x; (Source As TPanel).Top := y; end; 4. ɉɪɨɜɟɪɶɬɟ ɩɪɚɜɢɥɶɧɨɫɬɶ ɜɚɲɢɯ ɞɟɣɫɬɜɢɣ, ɨɫɭɳɟɫɬɜɢɜ ɩɪɨɝɨɧ ɩɪɨɝɪɚɦɦɵ. 1.4. ɋɨɛɵɬɢɹ, ɫɜɹɡɚɧɧɵɟ ɫ ɤɥɚɜɢɚɬɭɪɨɣ ȼ ɪɹɞɟ ɫɥɭɱɚɟɜ ɛɵɜɚɟɬ ɭɞɨɛɧɨ ɡɚɞɚɬɶ ɬɢɩ ɫɢɦɜɨɥɨɜ, ɤɨɬɨɪɵɟ ɦɨɝɭɬ ɛɵɬɶ ɜɜɟɞɟɧɵ ɜ ɫɬɪɨɤɟ ɪɟɞɚɤɬɢɪɨɜɚɧɢɹ. ɉɪɨɳɟ ɜɫɟɝɨ ɷɬɨɝɨ ɞɨɫɬɢɱɶ ɜ ɨɛɪɚɛɨɬɱɢɤɟ ɫɨɛɵɬɢɹ OnKeyPress, ɤɨɬɨɪɨɟ ɩɪɨɢɫɯɨɞɢɬ ɩɪɢ ɤɚɠɞɨɦ ɧɚɠɚɬɢɢ ɤɥɚɜɢɲɢ. 1. Ⱦɥɹ ɤɨɦɩɨɧɟɧɬɚ Edit1 ɪɟɚɥɢɡɭɟɦ ɩɪɟɨɛɪɚɡɨɜɚɧɢɟ ɜɜɨɞɢɦɨɣ ɢɧɮɨɪɦɚɰɢɢ ɜ ɫɢɦɜɨɥɵ ɜɟɪɯɧɟɝɨ ɪɟɝɢɫɬɪɚ (ɞɥɹ ɥɚɬɢɧɫɤɢɯ ɫɢɦɜɨɥɨɜ). ɋɨɡɞɚɞɢɦ ɫɥɟɞɭɸɳɢɣ ɨɛɪɚɛɨɬɱɢɤ: procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char); begin If Key in ['a'..'z'] Then Begin Key := Chr(Ord(Key)-32); End; end; 2. ɉɪɨɜɟɪɶɬɟ ɩɪɚɜɢɥɶɧɨɫɬɶ ȼɚɲɢɯ ɞɟɣɫɬɜɢɣ, ɨɫɭɳɟɫɬɜɢɜ ɩɪɨɝɨɧ ɩɪɨɝɪɚɦɦɵ. 1.5. ɋɨɛɵɬɢɹ, ɫɜɹɡɚɧɧɵɟ ɫ ɦɵɲɶɸ 59
Ⱦɥɹ ɮɨɪɦɵ ɫɨɡɞɚɞɢɦ ɨɛɪɚɛɨɬɱɢɤɢ ɫɨɛɵɬɢɣ, ɤɨɬɨɪɵɟ ɛɭɞɭɬ ɮɢɤɫɢɪɨɜɚɬɶ ɧɚɠɚɬɢɟ ɤɥɚɜɢɲɢ ɦɵɲɢ ɜ ɩɟɪɜɨɣ ɫɟɤɰɢɢ ɤɨɦɩɨɧɟɧɬɚ StatusBar1, ɨɬɩɭɫɤɚɧɢɟ ɤɧɨɩɤɢ ɦɵɲɢ ɜɨ ɜɬɨɪɨɣ ɫɟɤɰɢɢ ɢ ɬɟɤɭɳɟɟ ɩɨɥɨɠɟɧɢɟ ɤɭɪɫɨɪɚ ɦɵɲɢ ɜ ɬɪɟɬɶɟɣ ɫɟɤɰɢɢ. 1. ɋɨɡɞɚɣɬɟ ɨɛɪɚɛɨɬɱɢɤɢ ɞɥɹ ɮɨɪɦɵ: – ɇɚɠɚɬɢɟ ɧɚ ɤɧɨɩɤɭ ɦɵɲɢ: procedure
TForm1.FormMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin //ȼ ɩɟɪɜɭɸ ɫɟɤɰɢɸ ɩɚɧɟɥɢ ɫɬɚɬɭɫɚ ɡɚɩɢɫɵɜɚɟɦ ɤɨɨɪɞɢɧɚɬɵ ɦɵɲɢ ɩɪɢ // ɧɚɠɚɬɢɢ ɤɧɨɩɤɢ ɦɵɲɢ StatusBar1.Panels[0].Text := 'ɇɚɱɚɥɨ: ' + 'X:'+IntToStr(x)+'; Y:'+IntToStr(y); end; – Ɉɬɩɭɫɤɚɧɢɟ ɤɧɨɩɤɢ ɦɵɲɢ: procedure TForm1.FormMouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin //ȼɨ ɜɬɨɪɭɸ ɫɟɤɰɢɸ ɩɚɧɟɥɢ ɫɬɚɬɭɫɚ ɡɚɩɢɫɵɜɚɟɦ ɤɨɨɪɞɢɧɚɬɵ ɦɵɲɢ // ɩɪɢ ɨɬɩɭɫɤɚɧɢɢ ɦɵɲɢ StatusBar1.Panels[1].Text := 'Ʉɨɧɟɰ: ' + 'X:'+IntToStr(x)+'; Y:'+IntToStr(y); end; – ɉɟɪɟɦɟɳɟɧɢɟ ɦɵɲɢ: procedure TForm1.FormMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer); begin //ȼ ɬɪɟɬɶɸ ɫɟɤɰɢɸ ɩɚɧɟɥɢ ɫɬɚɬɭɫɚ ɡɚɩɢɫɵɜɚɟɦ ɤɨɨɪɞɢɧɚɬɵ ɦɵɲɢ // ɩɪɢ ɩɟɪɟɦɟɳɟɧɢɢ ɦɵɲɢ StatusBar1.Panels[2].Text := 'X:'+IntToStr(x)+'; Y:'+IntToStr(y); end; 2. ɉɪɨɜɟɪɶɬɟ ɩɪɚɜɢɥɶɧɨɫɬɶ ɜɚɲɢɯ ɞɟɣɫɬɜɢɣ, ɨɫɭɳɟɫɬɜɢɜ ɩɪɨɝɨɧ ɩɪɨɝɪɚɦɦɵ ɪɢɫ. 3.4.4.
60
Ɋɢɫ. 3.4.4. Ɉɤɧɨ ɪɚɛɨɬɚɸɳɟɣ ɩɪɨɝɪɚɦɦɵ 1.6. Ɉɛɳɟɟ ɫɜɨɣɫɬɜɨ ɤɨɦɩɨɧɟɧɬɨɜ Hint ȼɫɟ ɜɢɞɢɦɵɟ ɷɥɟɦɟɧɬɵ ɢɦɟɸɬ ɫɜɨɣɫɬɜɚ Hint: String ɢ ShowHint: Boolean, ɪɟɝɭɥɢɪɭɸɳɢɟ ɩɨɹɜɥɟɧɢɟ ɢ ɫɨɞɟɪɠɚɧɢɟ ɹɪɥɵɱɤɚ – ɧɟɛɨɥɶɲɨɝɨ ɫɩɪɚɜɨɱɧɨɝɨ ɨɤɧɚ ɜɨɡɥɟ ɷɥɟɦɟɧɬɚ, ɧɚ ɤɨɬɨɪɨɦ ɨɫɬɚɧɨɜɢɥɫɹ ɤɭɪɫɨɪ. 1. ȼ ɫɜɨɣɫɬɜɨ Hint ɞɥɹ ɩɚɧɟɥɢ Panel1 ɜɜɟɞɢɬɟ ɬɟɤɫɬ: «ɗɬɭ ɩɚɧɟɥɶ ɦɨɠɧɨ ɩɟɪɟɦɟɳɚɬɶ». 2. ɋɜɨɣɫɬɜɭ ShowHint ɡɚɞɚɣɬɟ ɡɧɚɱɟɧɢɟ True. 3. Ɉɫɭɳɟɫɬɜɢɬɟ ɩɪɨɝɨɧ ɩɪɨɝɪɚɦɦɵ ɢ ɭɛɟɞɢɬɟɫɶ ɜ ɬɨɦ, ɱɬɨ ɩɪɢ ɨɫɬɚɧɨɜɤɟ ɤɭɪɫɨɪɚ ɧɚɞ ɤɨɦɩɨɧɟɧɬɨɦ Panel1 «ɜɫɩɥɵɜɚɟɬ» Hint. 2. ɋɚɦɨɫɬɨɹɬɟɥɶɧɚɹ ɪɚɛɨɬɚ Ɂɚɞɚɧɢɟ. ɋɧɚɛɞɢɬɟ ɫɩɪɚɜɨɱɧɨɣ ɢɧɮɨɪɦɚɰɢɟɣ ɤɨɦɩɨɧɟɧɬɵ ɜɚɲɟɝɨ ɩɪɢɥɨɠɟɧɢɹ, ɢɫɩɨɥɶɡɭɹ ɫɜɨɣɫɬɜɚ Hint ɢ ShowHint. ɇɚ ɝɥɚɜɧɨɣ ɮɨɪɦɟ ɩɪɢɥɨɠɟɧɢɹ ɭɫɬɚɧɨɜɢɬɟ ɤɨɦɩɨɧɟɧɬ TStatusBar, ɜ ɤɨɬɨɪɨɦ ɨɬɪɚɡɢɬɟ ɬɟɤɭɳɭɸ ɞɚɬɭ ɢ ɬɟɤɭɳɢɟ ɤɨɨɪɞɢɧɚɬɵ ɦɵɲɢ. ȼɚɪɢɚɧɬɵ 1
2
3
ɂɫɯɨɞɧɵɟ ɞɚɧɧɵɟ 1. Ɉɪɝɚɧɢɡɭɣɬɟ ɢɧɬɟɪɮɟɣɫ Drag & Drop ɞɥɹ ɩɟɪɟɦɟɳɟɧɢɹ ɤɧɨɩɨɤ ɩɨ ɮɨɪɦɟ ɜ ɝɥɚɜɧɨɣ ɮɨɪɦɟ ɩɪɢɥɨɠɟɧɢɹ. 2. ɍɫɬɚɧɨɜɢɬɟ ɡɚɳɢɬɭ ɢɧɮɨɪɦɚɰɢɢ ɞɥɹ ɜɜɨɞɚ ɜ ɥɚɛɨɪɚɬɨɪɧɨɣ ɪɚɛɨɬɟ ʋ 1 1. ȼ ɥɚɛɨɪɚɬɨɪɧɨɣ ɪɚɛɨɬɟ ʋ 1 ɨɪɝɚɧɢɡɭɣɬɟ ɢɧɬɟɪɮɟɣɫ Drag & Drop ɞɥɹ ɩɟɪɟɧɨɫɚ ɟɞɢɧɢɰ ɢɡɦɟɪɟɧɢɹ ɜ ɦɟɬɤɭ. Ⱦɥɹ ɷɬɨɣ ɰɟɥɢ ɞɨɩɨɥɧɢɬɟ ɩɪɢɥɨɠɟɧɢɟ ɟɳɟ ɨɞɧɢɦ ɤɨɦɩɨɧɟɧɬɨɦ TLabel. 2. ɍɫɬɚɧɨɜɢɬɟ ɡɚɳɢɬɭ ɢɧɮɨɪɦɚɰɢɢ ɞɥɹ ɜɜɨɞɚ ɜ ɥɚɛɨɪɚɬɨɪɧɨɣ ɪɚɛɨɬɟ ʋ 1 1. ȼ ɥɚɛɨɪɚɬɨɪɧɨɣ ɪɚɛɨɬɟ ʋ 2 ɨɪɝɚɧɢɡɭɣɬɟ ɢɧɬɟɪɮɟɣɫ Drag & Drop ɞɥɹ ɩɟɪɟɧɨɫɚ ɡɧɚɱɟɧɢɹ ɫɪɟɞɧɟɝɨ ɛɚɥɥɚ ɢɡ ɪɟɞɚɤɬɨɪɚ ɜ ɦɟɬɤɭ. Ⱦɥɹ ɷɬɨɣ ɰɟɥɢ ɞɨɩɨɥɧɢɬɟ ɩɪɢɥɨɠɟɧɢɟ ɟɳɟ ɨɞɧɢɦ ɤɨɦɩɨɧɟɧɬɨɦ TLabel. 2. Ɉɫɭɳɟɫɬɜɢɬɟ ɡɚɳɢɬɭ ɜɜɨɞɚ ɢɧɮɨɪɦɚɰɢɢ ɜ ɥɚɛɨɪɚɬɨɪɧɨɣ ɪɚɛɨɬɟ ʋ 2 61
4
5
1. Ɉɪɝɚɧɢɡɭɣɬɟ ɢɧɬɟɪɮɟɣɫ Drag & Drop ɞɥɹ ɩɟɪɟɦɟɳɟɧɢɹ ɤɧɨɩɤɢ ɩɨ ɮɨɪɦɟ ɜ ɥɚɛɨɪɚɬɨɪɧɨɣ ɪɚɛɨɬɟ ʋ 3. 2. Ɉɫɭɳɟɫɬɜɢɬɟ ɡɚɳɢɬɭ ɜɜɨɞɚ ɢɧɮɨɪɦɚɰɢɢ ɜ ɥɚɛɨɪɚɬɨɪɧɨɣ ɪɚɛɨɬɟ ʋ 3 1. Ɉɪɝɚɧɢɡɭɣɬɟ ɢɧɬɟɪɮɟɣɫ Drag & Drop ɞɥɹ ɩɟɪɟɦɟɳɟɧɢɹ ɤɚɪɬɢɧɤɢ ɩɨ ɮɨɪɦɟ ɜ ɥɚɛɨɪɚɬɨɪɧɨɣ ɪɚɛɨɬɟ ʋ 5. 2. Ɉɫɭɳɟɫɬɜɢɬɟ ɜɨɡɦɨɠɧɨɫɬɢ ɩɟɪɟɬɚɫɤɢɜɚɧɢɹ ɫɨɞɟɪɠɢɦɨɝɨ ɤɨɦɩɨɧɟɧɬɚ Memo1 ɜ Memo2 ɥɚɛɨɪɚɬɨɪɧɨɣ ɪɚɛɨɬɵ ʋ 5 (ɞɨɛɚɜɶɬɟ Memo2 ɧɚ ɝɥɚɜɧɭɸ ɮɨɪɦɭ) ɉɪɨɝɪɚɦɦɭ ɡɚɩɢɲɢɬɟ ɜ ɜɚɲ ɤɚɬɚɥɨɝ Lab_6.
3.5. ɉɪɢɦɟɬɵ ɜɢɡɭɚɥɶɧɵɯ ɤɨɦɩɨɧɟɧɬɨɜ Windows-ɢɧɬɟɪɮɟɣɫɚ. Ɂɚɱɟɬɧɨɟ ɡɚɧɹɬɢɟ. Ɋɚɡɪɚɛɨɬɤɚ ɩɪɨɫɬɨɝɨ ɩɪɢɥɨɠɟɧɢɹ ɞɥɹ Windows ɜ ɫɪɟɞɟ Delphi 7 ɐɟɥɶ: ɨɡɧɚɤɨɦɢɬɶɫɹ ɫ ɤɨɦɩɨɧɟɧɬɚɦɢ Windows-ɢɧɬɟɪɮɟɣɫɚ. ɉɪɨɞɟɦɨɧɫɬɪɢɪɨɜɚɬɶ ɩɪɢɨɛɪɟɬɟɧɧɵɟ ɩɪɚɤɬɢɱɟɫɤɢɟ ɧɚɜɵɤɢ ɪɚɡɪɚɛɨɬɤɢ ɩɪɢɥɨɠɟɧɢɣ ɞɥɹ Windows ɜ ɫɪɟɞɟ Delphi. Ɋɟɡɭɥɶɬɚɬ ɨɛɭɱɟɧɢɹ: ɩɨɫɥɟ ɭɫɩɟɲɧɨɝɨ ɡɚɜɟɪɲɟɧɢɹ ɡɚɧɹɬɢɹ ɩɨɥɶɡɨɜɚɬɟɥɶ ɞɨɥɠɟɧ: – ɭɦɟɬɶ ɢɫɩɨɥɶɡɨɜɚɬɶ ɜ ɩɪɢɥɨɠɟɧɢɹɯ ɤɨɦɩɨɧɟɧɬɵ, ɪɚɫɩɨɥɨɠɟɧɧɵɟ ɧɚ ɫɬɪɚɧɢɰɚɯ Win32, System, Samples ɩɚɥɢɬɪɵ ɤɨɦɩɨɧɟɧɬɨɜ; – ɪɚɡɪɚɛɚɬɵɜɚɬɶ ɩɪɢɥɨɠɟɧɢɹ ɞɥɹ Windows ɫ ɢɫɩɨɥɶɡɨɜɚɧɢɟɦ ɫɬɚɧɞɚɪɬɧɵɯ ɢɧɬɟɪɮɟɣɫɧɵɯ ɷɥɟɦɟɧɬɨɜ ɭɩɪɚɜɥɟɧɢɹ: ɩɨɹɫɧɹɸɳɢɯ ɬɟɤɫɬɨɜ, ɪɟɞɚɤɬɨɪɨɜ, ɬɚɛɥɢɰ, ɫɩɢɫɤɨɜ ɜɵɛɨɪɚ, ɤɧɨɩɨɤ, ɦɧɨɝɨɫɬɪɚɧɢɱɧɵɯ ɛɥɨɤɧɨɬɨɜ, ɝɥɚɜɧɨɝɨ ɢ ɜɫɩɥɵɜɚɸɳɟɝɨ ɦɟɧɸ, ɝɪɚɮɢɱɟɫɤɢɯ ɢ ɚɧɢɦɚɰɢɨɧɧɵɯ ɷɮɮɟɤɬɨɜ. ɉɥɚɧ ɡɚɧɹɬɢɹ ɑɚɫɬɶ I. ɉɪɢɦɟɪɵ ɜɢɡɭɚɥɶɧɵɯ ɤɨɦɩɨɧɟɧɬɨɜ Windows-ɢɧɬɟɪɮɟɣɫɚ. 1. ɉɪɢɦɟɪɵ ɜɢɡɭɚɥɶɧɵɯ ɤɨɦɩɨɧɟɧɬɨɜ Windows–ɢɧɬɟɪɮɟɣɫɚ. Ɋɚɛɨɬɚ ɩɨɞ ɪɭɤɨɜɨɞɫɬɜɨɦ ɩɪɟɩɨɞɚɜɚɬɟɥɹ 40 ɦɢɧɭɬ. 2. ɋɚɦɨɫɬɨɹɬɟɥɶɧɚɹ ɪɚɛɨɬɚ 40 ɦɢɧɭɬ. ɑɚɫɬɶ II. Ɂɚɱɟɬɧɨɟ ɡɚɧɹɬɢɟ. Ɋɚɡɪɚɛɨɬɤɚ ɩɪɨɫɬɨɝɨ ɩɪɢɥɨɠɟɧɢɹ ɞɥɹ Windows ɜ ɫɪɟɞɟ DELPHI 7.0. 1. Ɉɛɳɢɟ ɪɟɤɨɦɟɧɞɚɰɢɢ ɩɨ ɜɵɩɨɥɧɟɧɢɸ ɡɚɱɟɬɧɨɝɨ ɡɚɞɚɧɢɹ. Ɋɚɛɨɬɚ ɩɨɞ ɪɭɤɨɜɨɞɫɬɜɨɦ ɩɪɟɩɨɞɚɜɚɬɟɥɹ 20 ɦɢɧɭɬ. 2. ɋɚɦɨɫɬɨɹɬɟɥɶɧɚɹ ɪɚɛɨɬɚ 60 ɦɢɧɭɬ. ɑɚɫɬɶ I. ɉɪɢɦɟɪɵ ɜɢɡɭɚɥɶɧɵɯ ɤɨɦɩɨɧɟɧɬɨɜ Windows-ɢɧɬɟɪɮɟɣɫɚ. 1. ɉɪɢɦɟɪɵ ɜɢɡɭɚɥɶɧɵɯ ɤɨɦɩɨɧɟɧɬɨɜ Windows-ɢɧɬɟɪɮɟɣɫɚ 62
ɇɨɜɵɟ ɷɥɟɦɟɧɬɵ ɭɩɪɚɜɥɟɧɢɹ ɜ ɫɬɢɥɟ Windows 2000/ɏɊ ɪɚɫɩɨɥɨɠɟɧɵ ɧɚ ɫɬɪɚɧɢɰɟ Win32. ɗɬɨ ɦɧɨɝɨɫɬɪɚɧɢɱɧɵɟ ɛɥɨɤɧɨɬɵ, ɤɨɧɬɟɣɧɟɪɵ ɞɥɹ ɩɚɧɟɥɟɣ ɢɧɫɬɪɭɦɟɧɬɨɜ ɫ ɜɨɡɦɨɠɧɨɫɬɶɸ ɩɟɪɟɧɨɫɚ ɷɥɟɦɟɧɬɨɜ ɭɩɪɚɜɥɟɧɢɹ (Docking), ɞɪɟɜɨɜɢɞɧɵɟ ɫɩɢɫɤɢ, ɤɚɥɟɧɞɚɪɢ, ɤɨɦɩɨɧɟɧɬɵ ɞɥɹ ɢɡɦɟɧɟɧɢɹ ɡɧɚɱɟɧɢɣ (ɩɥɚɜɧɨɝɨ – TɌrackBar ɢ ɫɤɚɱɤɨɨɛɪɚɡɧɨɝɨ – TUpDate), ɤɨɦɩɨɧɟɧɬ ɞɥɹ ɨɬɨɛɪɚɠɟɧɢɹ ɩɪɨɰɟɫɫɚ ɜɵɩɨɥɧɟɧɢɹ ɨɩɟɪɚɰɢɢ ɢ ɞɪɭɝɢɟ. 1.1. ɉɨɞɝɨɬɨɜɢɬɟɥɶɧɵɟ ɞɟɣɫɬɜɢɹ 1. ɋɨɡɞɚɣɬɟ ɜ ɫɜɨɟɦ ɤɚɬɚɥɨɝɟ ɩɨɞɤɚɬɚɥɨɝ Lab7. 2. ɋɨɡɞɚɣɬɟ ɧɨɜɨɟ ɩɪɢɥɨɠɟɧɢɟ. 1.2. ɉɚɧɟɥɢ ɢɧɫɬɪɭɦɟɧɬɨɜ 1. ɉɨɦɟɫɬɢɬɟ ɧɚ ɮɨɪɦɭ ɤɨɧɬɟɣɧɟɪ ɞɥɹ ɩɚɧɟɥɟɣ ɢɧɫɬɪɭɦɟɧɬɨɜ (ɫɬɪɚɧɢɰɚ Additional). Ɉɧ ɚɤɬɢɜɧɨ ɢɫɩɨɥɶɡɭɟɬ ɬɟɯɧɨɥɨTControlBar ɝɢɸ Drag & Drop ɞɥɹ ɭɩɪɚɜɥɟɧɢɹ ɩɨɥɨɠɟɧɢɟɦ ɩɚɧɟɥɟɣ. ɍɫɬɚɧɨɜɢɬɟ ɜ ɟɝɨ ɫɜɨɣɫɬɜɨ Align ɡɧɚɱɟɧɢɟ alTop, ɜ AutoSize – True, ɜ DragKind – dkDock. Ɉɫɬɚɜɶɬɟ ɜ ɫɜɨɣɫɬɜɟ DragMode ɡɧɚɱɟɧɢɟ dmManual. Ʉɨɦɩɨɧɟɧɬ TControlBar ɫɥɭɠɢɬ ɭɞɨɛɧɵɦ ɤɨɧɬɟɣɧɟɪɨɦ ɞɥɹ ɪɚɡɦɟɳɟɧɢɹ ɢɧɫɬɪɭɦɟɧ(ɫɬɪɚɧɢɰɚ Win32). ɬɚɥɶɧɵɯ ɩɚɧɟɥɟɣ TɌoolBar 2. ɉɨɥɨɠɢɬɟ ɧɚ ɫɜɨɛɨɞɧɨɟ ɦɟɫɬɨ ɮɨɪɦɵ ɞɜɚ ɤɨɦɩɨɧɟɧɬɚ ImageList (ɫɬɪɚɧɢɰɚ Win32) ɢ ɧɚɩɨɥɧɢɬɟ ɤɚɠɞɵɣ ɢɡ ɧɢɯ ɱɟɬɵɪɶɦɹ ɢɡɨɛɪɚɠɟɧɢɹɦɢ. ɑɬɨɛɵ ɧɚɩɨɥɧɢɬɶ ɤɨɦɩɨɧɟɧɬ ImageList ɢɡɨɛɪɚɠɟɧɢɹɦɢ, ɞɜɚɠɞɵ ɳɟɥɤɧɢɬɟ ɩɨ ɧɟɦɭ ɦɵɲɶɸ ɢɥɢ ɜɵɛɟɪɢɬɟ ɜ ɟɝɨ ɜɫɩɨɦɨɝɚɬɟɥɶɧɨɦ ɦɟɧɸ (ɳɟɥɱɨɤ ɩɪɚɜɨɣ ɤɥɚɜɢɲɟɣ ɦɵɲɢ) ɨɩɰɢɸ ImageList Editor. 3. ȼ ɩɨɹɜɢɜɲɟɦɫɹ ɨɤɧɟ ɪɟɞɚɤɬɨɪɚ ɧɚɠɦɢɬɟ ɤɧɨɩɤɭ ɢ ɜɵɛɟɪɢɬɟ BMP-ɮɚɣɥɵ ɢɡ ɤɚɬɚɥɨɝɚ Images\Buttons. Ɏɚɣɥɵ ɜ ɷɬɨɦ ɤɚɬɚɥɨɝɟ ɢɦɟɸɬ ɩɨ ɞɜɚ ɢɡɨɛɪɚɠɟɧɢɹ, ɜ ɬɨ ɜɪɟɦɹ ɤɚɤ ɤɨɦɩɨɧɟɧɬ ImageList ɫɩɨɫɨɛɟɧ ɯɪɚɧɢɬɶ ɬɨɥɶɤɨ ɨɞɢɧɨɱɧɵɟ ɢɡɨɛɪɚɠɟɧɢɹ ɨɞɢɧɚɤɨɜɨɝɨ ɪɚɡɦɟɪɚ. ɉɨɷɬɨɦɭ ɪɟɞɚɤɬɨɪ ɩɪɟɞɥɨɠɢɬ ɜɚɦ ɪɚɡɞɟɥɢɬɶ ɞɜɚ ɢɡɨɛɪɚɠɟɧɢɹ. ɋɨɝɥɚɫɢɬɟɫɶ ɫ ɧɢɦ. ɓɟɥɤɧɢɬɟ ɩɨ ɩɪɚɜɨɦɭ ɢɡɨɛɪɚɠɟɧɢɸ ɜ ɨɤɧɟ ɪɟɞɚɤɬɨɪɚ ɢ ɧɚɠɦɢɬɟ ɤɧɨɩɤɭ , ɱɬɨɛɵ ɭɧɢɱɬɨɠɢɬɶ ɟɝɨ. 4. ɉɨɜɬɨɪɢɬɟ ɩ. 3 ɞɥɹ ɡɚɝɪɭɡɤɢ ɧɟɫɤɨɥɶɤɢɯ ɢɡɨɛɪɚɠɟɧɢɣ ɢ ɡɚɬɟɦ ɡɚɤɪɨɣɬɟ ɪɟɞɚɤɬɨɪ. 5. ɉɨɦɟɫɬɢɬɟ ɧɚ ɤɨɦɩɨɧɟɧɬ ControlBar1 ɤɨɦɩɨɧɟɧɬ TToolBar (ɫɬɪɚɧɢɰɚ Win32). ɍɫɬɚɧɨɜɢɬɟ ɜ ɫɜɨɣɫɬɜɨ Images ɤɨɦɩɨɧɟɧɬɚ ToolBar1 ɡɧɚɱɟɧɢɟ ImageList1 ɢ ɩɨɦɟɫɬɢɬɟ ɜ ɧɟɝɨ ɱɟɬɵɪɟ ɤɧɨɩɤɢ. Ⱦɥɹ ɜɫɬɚɜɤɢ ɤɧɨɩɤɢ ɳɟɥɤɧɢɬɟ ɩɨ ToolBar1 ɩɪɚɜɨɣ ɤɧɨɩɤɨɣ ɢ ɜɵɛɟɪɢɬɟ ɨɩɰɢɸ NewButton. 6. ɉɨɦɟɫɬɢɬɟ ɧɚ ControlBar1 ɟɳɟ ɨɞɢɧ ɤɨɦɩɨɧɟɧɬ TToolBar. ɂɡɦɟɧɢɬɟ ɜ ɟɝɨ ɫɜɨɣɫɬɜɟ Align ɡɧɚɱɟɧɢɟ alTop ɧɚ alNone. ɋɜɹɠɢɬɟ ɤɨɦɩɨɧɟɧɬ ɫ ImageList2 (ɫɜɨɣɫɬɜɨ Images) ɢ ɫɨɡɞɚɣɬɟ ɜ ɧɟɦ ɤɧɨɩɤɢ (ɫɦ. ɩ. 5). 7. Ⱦɥɹ ɨɛɨɢɯ ɤɨɦɩɨɧɟɧɬɨɜ TToolBar ɩɨɦɟɫɬɢɬɟ ɜ ɫɜɨɣɫɬɜɚ DragKind ɡɧɚɱɟɧɢɹ dkDock, ɜ DragMode – dmAutomatic ɢ ɜ AutoSize – True. 8. Ɂɚɩɭɫɬɢɬɟ ɩɪɨɝɪɚɦɦɭ ɢ ɩɨɩɪɨɛɭɣɬɟ ɩɟɪɟɦɟɫɬɢɬɶ ɩɚɧɟɥɢ. 1.3. Ɇɧɨɝɨɫɬɪɚɧɢɱɧɵɣ ɛɥɨɤɧɨɬ 63
ȼ ɩɚɥɢɬɪɟ ɤɨɦɩɨɧɟɧɬɨɜ ɢɦɟɸɬɫɹ ɞɜɚ ɷɥɟɦɟɧɬɚ ɭɩɪɚɜɥɟɧɢɹ, ɨɛɟɫɩɟɱɢɜɚɸɳɢɯ ɫɨɡɞɚɧɢɟ ɦɧɨɝɨɫɬɪɚɧɢɱɧɵɯ ɛɥɨɤɧɨɬɨɜ. ɗɬɨ ɤɨɦɩɨɧɟɧɬɵ TTabControl ɢ TPageControl. ɉɟɪɟɤɥɸɱɟɧɢɟ ɦɟɠɞɭ ɫɬɪɚɧɢɰɚɦɢ ɨɫɭɳɟɫɬɜɥɹɟɬɫɹ ɩɪɢ ɩɨɦɨɳɢ ɡɚɤɥɚɞɨɤ. Ʉɨɦɩɨɧɟɧɬ TɊageControl ɦɨɠɟɬ ɫɨɞɟɪɠɚɬɶ ɧɟɫɤɨɥɶɤɨ ɩɟɪɟɤɪɵɜɚɸɳɢɯ ɞɪɭɝ ɞɪɭɝɚ ɩɚɧɟɥɟɣ ɤɥɚɫɫɚ TɌabSheet. Ʉɚɠɞɚɹ ɩɚɧɟɥɶ ɜɵɛɢɪɚɟɬɫɹ ɫɜɹɡɚɧɧɨɣ ɫ ɧɟɣ ɡɚɤɥɚɞɤɨɣ ɢ ɦɨɠɟɬ ɫɨɞɟɪɠɚɬɶ ɫɜɨɣ ɧɚɛɨɪ ɩɨɦɟɳɟɧɧɵɯ ɧɚ ɧɟɟ ɤɨɦɩɨɧɟɧɬɨɜ. 1. ɉɨɦɟɫɬɢɬɟ ɧɚ ɮɨɪɦɭ ɤɨɦɩɨɧɟɧɬ TPageControl, ɡɚɞɚɣɬɟ ɫɜɨɣɫɬɜɭ Align ɡɧɚɱɟɧɢɟ alClient. 2. ɑɬɨɛɵ ɧɚ ɷɬɚɩɟ ɤɨɧɫɬɪɭɢɪɨɜɚɧɢɹ ɞɨɛɚɜɢɬɶ ɧɨɜɭɸ ɩɚɧɟɥɶ ɳɟɥɤɧɢɬɟ ɩɨ ɤɨɦɩɨɧɟɧɬɭ ɩɪɚɜɨɣ ɤɧɨɩɤɨɣ ɦɵɲɢ ɢ ɜɵɛɟɪɢɬɟ New Page. Ⱦɥɹ ɧɨɜɨɣ ɫɬɪɚɧɢɰɵ ɦɨɠɧɨ ɭɫɬɚɧɨɜɢɬɶ ɡɚɝɨɥɨɜɨɤ ɜ ɫɜɨɣɫɬɜɟ Caption ɪɢɫ. 3.5.1. 1.4. Ʉɨɦɩɨɧɟɧɬ TɊaintBox Ʉɨɦɩɨɧɟɧɬ TPaintBox ɪɚɫɩɨɥɨɠɟɧ ɧɚ ɩɚɧɟɥɢ System. ɗɬɨ ɩɪɨɫɬɨɟ ɨɤɧɨ ɞɥɹ ɪɢɫɨɜɚɧɢɹ ɩɪɨɢɡɜɨɥɶɧɵɯ ɢɡɨɛɪɚɠɟɧɢɣ. Ʉɚɧɜɚ ɫɨɞɟɪɠɢɬɫɹ ɜ ɫɜɨɣɫɬɜɟ Canvas ɤɨɦɩɨɧɟɧɬɚ, ɝɪɚɮɢɱɟɫɤɢɟ ɢɧɫɬɪɭɦɟɧɬɵ – ɜ ɫɜɨɣɫɬɜɚɯ Font, Pen ɢ Brush. 1. ɉɨɦɟɫɬɢɬɟ ɧɚ ɩɟɪɜɭɸ ɫɬɪɚɧɢɰɭ PageControl ɤɨɦɩɨɧɟɧɬ TPanel ɢ ɡɚɞɚɣɬɟ ɟɝɨ ɫɜɨɣɫɬɜɭ Align ɡɧɚɱɟɧɢɟ alRight. 2. ɇɚ ɩɚɧɟɥɶ ɩɨɦɟɫɬɢɬɟ ɞɜɟ ɤɧɨɩɤɢ TBitBtn. Ɂɚɞɚɣɬɟ ɤɧɨɩɤɚɦ ɡɚɝɨɥɨɜɤɢ ɢ ɩɢɤɬɨɝɪɚɦɦɵ (ɫɜɨɣɫɬɜɚ Caption ɢ Glyph).
Ɋɢɫ. 3.5.1. ɉɟɪɜɚɹ ɫɬɪɚɧɢɰɚ ɛɥɨɤɧɨɬɚ PageControl1 3. ɇɚ ɫɜɨɛɨɞɧɨɟ ɦɟɫɬɨ ɫɬɪɚɧɢɰɵ ɩɨɦɟɫɬɢɬɟ ɤɨɦɩɨɧɟɧɬ TPaintBox (Align = alClient). 4. ɋɨɡɞɚɣɬɟ ɨɛɪɚɛɨɬɱɢɤ ɫɨɛɵɬɢɹ OnClick ɞɥɹ BitBtn1. procedure TForm1.BitBtn1Click(Sender: TObject); Var x, y, w, h : Integer; begin With PaintBox1.Canvas Do begin 64
Brush.Color := clGreen; W:=Width div 2; h:=Height div 2; Ellipse(0,0,W,H); Font.Size := Height div 8; Font.Color := clWhite; x :=(Width - TextWidth('Delphi')) div 6; y := (Height - TextHeight('D')) div 6; TextOut(x, y, 'Delphi'); end; end; ȼ ɨɛɪɚɛɨɬɱɢɤɟ ɫ ɩɨɦɨɳɶɸ ɦɟɬɨɞɨɜ ɤɥɚɫɫɚ Canvas ɪɢɫɭɟɬɫɹ ɷɥɥɢɩɫ ɡɟɥɟɧɨɝɨ ɰɜɟɬɚ. 5. ɗɬɨɬ ɠɟ ɨɛɪɚɛɨɬɱɢɤ ɧɚɡɧɚɱɶɬɟ ɥɸɛɨɣ ɤɧɨɩɤɟ ɫɨɡɞɚɧɧɨɣ ɜɚɦɢ ɩɚɧɟɥɢ ɢɧɫɬɪɭɦɟɧɬɨɜ. 6. Ⱦɥɹ ɤɧɨɩɤɢ BitBtn2 ɫɨɡɞɚɣɬɟ ɨɛɪɚɛɨɬɱɢɤ: procedure TForm1.BitBtn2Click(Sender: TObject); begin PaintBox1.Refresh; end; ɇɚɠɚɬɢɟ ɧɚ ɤɧɨɩɤɭ BitBtn2 ɩɪɢɜɟɞɟɬ ɤ ɨɱɢɫɬɤɟ ɤɨɦɩɨɧɟɧɬɚ PaintBox1. 7. ɉɪɨɜɟɪɶɬɟ ɩɪɚɜɢɥɶɧɨɫɬɶ ɜɚɲɢɯ ɞɟɣɫɬɜɢɣ, ɨɫɭɳɟɫɬɜɢɜ ɩɪɨɝɨɧ ɩɪɨɝɪɚɦɦɵ. 1.5. Ʉɨɦɩɨɧɟɧɬɵ TAnimate, TProgressBar, TUpDown, TShape, TTimer Ʉɨɦɩɨɧɟɧɬ TProgressBar ɩɪɟɞɧɚɡɧɚɱɟɧ ɞɥɹ ɨɬɨɛɪɚɠɟɧɢɹ ɯɨɞɚ ɜɵɩɨɥɧɟɧɢɹ ɞɥɢɬɟɥɶɧɨɝɨ ɩɨ ɜɪɟɦɟɧɢ ɩɪɨɰɟɫɫɚ. ɋɜɨɣɫɬɜɚ max ɢ min ɨɩɪɟɞɟɥɹɸɬ ɦɚɤɫɢɦɚɥɶɧɨɟ ɢ ɦɢɧɢɦɚɥɶɧɨɟ ɡɧɚɱɟɧɢɟ ɞɢɚɩɚɡɨɧɚ ɢɡɦɟɧɟɧɢɹ ɫɜɨɣɫɬɜɚ Position. Position ɫɨɞɟɪɠɢɬ ɬɟɤɭɳɟɟ ɡɧɚɱɟɧɢɟ ɨɬɨɛɪɚɠɚɟɦɨɣ ɜɟɥɢɱɢɧɵ. Ʉɨɦɩɨɧɟɧɬ TUpDown ɩɪɟɞɧɚɡɧɚɱɟɧ ɞɥɹ ɪɟɝɭɥɢɪɨɜɚɧɢɹ ɱɢɫɥɨɜɨɣ ɜɟɥɢɱɢɧɵ. Ɉɛɵɱɧɨ ɤɨɦɩɨɧɟɧɬ TUpDown ɫɜɹɡɚɧ ɫ ɞɪɭɝɢɦ ɤɨɦɩɨɧɟɧɬɨɦ ɤɥɚɫɫɚ TEdit, ɤɨɬɨɪɵɣ ɨɬɨɛɪɚɠɚɟɬ ɪɟɝɭɥɢɪɭɟɦɭɸ ɜɟɥɢɱɢɧɭ ɢ ɩɪɢ ɧɟɨɛɯɨɞɢɦɨɫɬɢ, ɦɨɠɟɬ ɪɟɞɚɤɬɢɪɨɜɚɬɶ ɟɟ. ɋɜɨɣɫɬɜɨ Associate ɨɩɪɟɞɟɥɹɟɬ ɫɜɹɡɚɧɧɵɣ ɤɨɦɩɨɧɟɧɬ. Ʉɨɦɩɨɧɟɧɬ TAnimate ɩɪɟɞɫɬɚɜɥɹɟɬ ɫɨɛɨɣ ɩɪɨɢɝɪɵɜɚɬɟɥɶ ɜɢɞɟɨɤɥɢɩɨɜ ɮɨɪɦɚɬɚ AVI. ɋɜɨɣɫɬɜɨ FileName ɫɜɹɡɵɜɚɟɬ ɤɨɦɩɨɧɟɧɬ ɫ AVI-ɮɚɣɥɨɦ. ɋɜɨɣɫɬɜɨ Active ɪɚɡɪɟɲɚɟɬ/ɡɚɩɪɟɳɚɟɬ ɞɟɦɨɧɫɬɪɚɰɢɸ ɤɥɢɩɚ. Ʉɨɦɩɨɧɟɧɬ TShape ɪɢɫɭɟɬ ɨɞɧɭ ɢɡ ɩɪɨɫɬɟɣɲɢɯ ɝɟɨɦɟɬɪɢɱɟɫɤɢɯ ɮɢɝɭɪ. ɋɜɨɣɫɬɜɨ Shape ɨɩɪɟɞɟɥɹɟɬ ɜɢɞ ɝɟɨɦɟɬɪɢɱɟɫɤɨɣ ɮɢɝɭɪɵ. Ʉɨɦɩɨɧɟɧɬ TɌimer ɫɥɭɠɢɬ ɞɥɹ ɨɬɫɱɟɬɚ ɢɧɬɟɪɜɚɥɨɜ ɪɟɚɥɶɧɨɝɨ ɜɪɟɦɟɧɢ. ȿɝɨ ɫɜɨɣɫɬɜɨ Interval ɨɩɪɟɞɟɥɹɟɬ ɢɧɬɟɪɜɚɥ ɜɪɟɦɟɧɢ ɜ ɦɢɥɥɢɫɟɤɭɧɞɚɯ, 65
ɤɨɬɨɪɵɣ ɞɨɥɠɟɧ ɩɪɨɣɬɢ ɨɬ ɜɤɥɸɱɟɧɢɹ ɬɚɣɦɟɪɚ ɞɨ ɧɚɫɬɭɩɥɟɧɢɹ ɫɨɛɵɬɢɹ OnTimer. Ɍɚɣɦɟɪ ɜɤɥɸɱɚɟɬɫɹ ɩɪɢ ɭɫɬɚɧɨɜɤɟ ɡɧɚɱɟɧɢɹ True ɜ ɟɝɨ ɫɜɨɣɫɬɜɨ Enabled. Ɋɚɡ ɜɤɥɸɱɟɧɧɵɣ ɬɚɣɦɟɪ ɜɫɟ ɜɪɟɦɹ ɛɭɞɟɬ ɜɨɡɛɭɠɞɚɬɶ ɫɨɛɵɬɢɹ OnTimer, ɩɨɤɚ ɟɝɨ ɫɜɨɣɫɬɜɨ Enabled ɧɟ ɩɪɢɦɟɬ ɡɧɚɱɟɧɢɹ False. 1. ɉɨɦɟɫɬɢɬɟ ɧɚ ɜɬɨɪɭɸ ɫɬɪɚɧɢɰɭ ɛɥɨɤɧɨɬɚ ɤɨɦɩɨɧɟɧɬɵ TAnimate, TShape, TProgressBar, TTimer, TUpDown, TEdit. 2. ɇɚɣɞɢɬɟ ɜ ɤɚɬɚɥɨɝɟ Delphi7 ɥɸɛɨɣ ɮɚɣɥ ɫ ɪɚɫɲɢɪɟɧɢɟɦ AVI ɢ ɫɤɨɩɢɪɭɣɬɟ ɟɝɨ ɜ ɫɜɨɣ ɤɚɬɚɥɨɝ Lab_7. ɍɫɬɚɧɨɜɢɬɟ ɢɦɹ ɷɬɨɝɨ ɮɚɣɥɚ ɜ ɫɜɨɣɫɬɜɨ FileName ɤɨɦɩɨɧɟɧɬɚ Animate1. Ɇɨɠɧɨ ɬɚɤɠɟ ɜɵɛɪɚɬɶ ɫɬɚɧɞɚɪɬɧɵɣ ɮɚɣɥ ɚɧɢɦɚɰɢɢ ɜ ɫɜɨɣɫɬɜɟ CommonAVI. 3. ɍɫɬɚɧɨɜɢɬɟ ɜ ɫɜɨɣɫɬɜɨ Enabled ɤɨɦɩɨɧɟɧɬɚ Timer1 ɡɧɚɱɟɧɢɟ False. 4. ɉɨɦɟɫɬɢɬɟ ɜ ɫɜɨɣɫɬɜɨ Visible ɤɨɦɩɨɧɟɧɬɚ ProgressBar1 ɡɧɚɱɟɧɢɟ False. 5. ɋɨɡɞɚɣɬɟ ɨɛɪɚɛɨɬɱɢɤ ɫɨɛɵɬɢɹ OnTimer ɤɨɦɩɨɧɟɧɬɚ Timer1: procedure TForm1.Timer1Timer(Sender: TObject); begin ProgressBar1.Position := ProgressBar1.Position +1; If ProgressBar1.Position>=ProgressBar1.Max Then Begin Timer1.Enabled := False; ProgressBar1.Hide; Animate1.Stop; end; end; 6. ɉɪɢ ɳɟɥɱɤɟ ɩɨ ɤɧɨɩɤɚɦ ɤɨɦɩɨɧɟɧɬɚ TUpDown ɜɨɡɧɢɤɚɟɬ ɫɨɛɵɬɢɟ OnClick. ɋɨɡɞɚɞɢɦ ɫɨɨɬɜɟɬɫɬɜɭɸɳɢɣ ɨɛɪɚɛɨɬɱɢɤ: procedure TForm1.UpDown1Click(Sender: TObject; Button: TUDBtnType); begin //Ɂɧɚɱɟɧɢɟ ɫɜɨɣɫɬɜɚ Position ɤɨɦɩɨɧɟɧɬɚ UpDate1 ɨɬɪɚɠɚɟɬɫɹ ɜ Memo1. Edit1.Text := IntToStr(UpDown1.Position); Case UpDown1.Position mod 5 Of //ȼ ɡɚɜɢɫɢɦɨɫɬɢ ɨɬ ɡɧɚɱɟɧɢɹ ɫɜɨɣɫɬɜɚ Position ɤɨɦɩɨɧɟɧɬɚ UpDate1 //ɢɡɦɟɧɹɟɬɫɹ ɜɢɞ ɮɢɝɭɪɵ ɜ ɤɨɦɩɨɧɟɧɬɟ Shape1. 0: Shape1.Shape := stRectangle; 1: Shape1.Shape := stSquare; 2: Shape1.Shape := stRoundRect; 3: Shape1.Shape := stRoundSquare; 66
4: Shape1.Shape := stEllipse; 5: Shape1.Shape := stCircle; end; end; 7. Ɍɚɣɦɟɪ ɜɤɥɸɱɚɟɬɫɹ ɩɪɢ ɧɚɠɚɬɢɢ ɧɚ ɤɧɨɩɤɭ ʋ 3 ɩɚɧɟɥɢ ɢɧɫɬɪɭɦɟɧɬɨɜ: procedure TForm1.ToolButton3Click(Sender: TObject); begin ProgressBar1.Position := 0; Animate1.Active := True; ProgressBar1.Show; Timer1.Enabled := True; end; 8. Ɂɚɩɭɫɬɢɬɟ ɩɪɨɝɪɚɦɦɭ ɢ ɩɪɨɜɟɪɶɬɟ ɩɪɚɜɢɥɶɧɨɫɬɶ ɜɚɲɢɯ ɞɟɣɫɬɜɢɣ (ɫɦ. ɪɢɫ. 3.5.2).
Ɋɢɫ. 3.5.2. ȼɬɨɪɚɹ ɫɬɪɚɧɢɰɚ ɛɥɨɤɧɨɬɚ PageControl1 Ʉɚɥɟɧɞɚɪɢ ȼɵɛɨɪ ɞɚɬɵ – ɨɞɧɚ ɢɡ ɱɚɫɬɨ ɢɫɩɨɥɶɡɭɟɦɵɯ ɨɩɟɪɚɰɢɣ ɩɪɢ ɜɜɨɞɟ ɞɚɧɧɵɯ. Ʉɨɦɩɨɧɟɧɬ TMonthCalendar ɢɧɤɚɩɫɭɥɢɪɭɟɬ ɤɚɥɟɧɞɚɪɶ, ɩɚɧɟɥɶ ɤɨɬɨɪɨɝɨ ɫɨɞɟɪɠɢɬ ɬɢɩɨɜɭɸ ɬɚɛɥɢɰɭ ɧɚ ɨɞɢɧ ɦɟɫɹɰ. ɉɪɢ ɭɜɟɥɢɱɟɧɢɢ ɪɚɡɦɟɪɨɜ ɜ ɷɥɟɦɟɧɬɟ ɭɩɪɚɜɥɟɧɢɹ ɨɬɨɛɪɚɠɚɟɬɫɹ ɰɟɥɨɟ ɱɢɫɥɨ ɤɚɥɟɧɞɚɪɟɣ ɞɥɹ ɦɟɫɹɰɟɜ, ɛɥɢɠɚɣɲɢɯ ɤ ɬɟɤɭɳɟɦɭ. Ɋɟɡɭɥɶɬɚɬ ɜɵɛɨɪɚ ɞɚɬɵ ɜ ɤɚɥɟɧɞɚɪɟ ɫɨɯɪɚɧɹɟɬɫɹ ɜ ɫɜɨɣɫɬɜɟ Date. Ʉɨɦɩɨɧɟɧɬ NDateTimePicker ɫɨɜɦɟɳɚɟɬ ɤɚɥɟɧɞɚɪɶ ɫ ɨɞɧɨɫɬɪɨɱɧɵɦ ɬɟɤɫɬɨɜɵɦ ɪɟɞɚɤɬɨɪɨɦ. ɇɚ ɫɬɪɚɧɢɰɟ Samples ɪɚɫɩɨɥɨɠɟɧ ɟɳɟ ɨɞɢɧ ɤɚɥɟɧɞɚɪɶ TCalendar. 1.6.
1. ɇɚ ɬɪɟɬɶɸ ɩɚɧɟɥɶ ɛɥɨɤɧɨɬɚ ɩɨɦɟɫɬɢɬɟ ɤɨɦɩɨɧɟɧɬɵ: TPanel (Align = alRight); TEdit (ɧɚ ɩɚɧɟɥɶ); TɆonthCalendar(Align = alClient) (ɪɢɫ. 3.5.3). 67
2. ɋɨɡɞɚɣɬɟ ɆonthCalendar1.
ɨɛɪɚɛɨɬɱɢɤ
ɫɨɛɵɬɢɹ
OnClick
ɞɥɹ
ɤɨɦɩɨɧɟɧɬɚ
procedure TForm1.MonthCalendar1Click(Sender: TObject); begin Edit2.Text := DateToStr(MonthCalendar1.Date); end;
Ɋɢɫ. 3.5.3. Ɍɪɟɬɶɹ ɫɬɪɚɧɢɰɚ PageControl1 2. ɋɚɦɨɫɬɨɹɬɟɥɶɧɚɹ ɪɚɛɨɬɚ Ɂɚɞɚɧɢɟ. ɋɨɡɞɚɬɶ ɩɪɨɝɪɚɦɦɭ ɫ ɮɭɧɤɰɢɨɧɚɥɶɧɵɦɢ ɜɨɡɦɨɠɧɨɫɬɹɦɢ ɫɨɝɥɚɫɧɨ ɩɨɥɭɱɟɧɧɨɦɭ ɜɚɪɢɚɧɬɭ. ȼɚɪɢɚɧɬɵ ɂɫɯɨɞɧɵɟ ɞɚɧɧɵɟ 1. ɇɚ ɝɥɚɜɧɭɸ ɮɨɪɦɭ ɩɨɦɟɫɬɢɬɟ ɫɜɨɣ ɪɢɫɭɧɨɤ, ɫɞɟɥɚɧɧɵɣ ɫ ɩɨɦɨɳɶɸ ɤɨɦɩɨɧɟɧɬɚ TɊaintBox. 1 2. ɇɚ ɫɬɚɧɞɚɪɬɧɨɣ ɮɨɪɦɟ ɭɫɬɚɧɨɜɢɬɟ ɤɚɥɟɧɞɚɪɶ. ȼɵɛɪɚɧɧɚɹ ɜ ɤɚɥɟɧɞɚɪɟ ɞɚɬɚ ɞɨɥɠɧɚ ɨɬɨɛɪɚɠɚɬɶɫɹ ɜ ɨɞɧɨɫɬɪɨɱɧɨɦ ɪɟɞɚɤɬɨɪɟ 1. ɋɧɚɛɞɢɬɟ ɝɥɚɜɧɭɸ ɮɨɪɦɭ ɜɢɞɟɨɤɥɢɩɨɦ. 2 2. ȼ ɥɚɛɨɪɚɬɨɪɧɨɣ ɪɚɛɨɬɟ ʋ 1 ɨɫɭɳɟɫɬɜɢɬɟ ɜɨɡɦɨɠɧɨɫɬɶ ɜɜɨɞɚ ɫ ɩɨɦɨɳɶɸ ɤɨɦɩɨɧɟɧɬɚ TUpDown 1. ɋɧɚɛɞɢɬɟ ɮɨɪɦɭ Password ɜɢɞɟɨɤɥɢɩɨɦ. 2. ɇɚ ɫɬɚɧɞɚɪɬɧɨɣ ɮɨɪɦɟ ɭɫɬɚɧɨɜɢɬɟ ɤɚɥɟɧɞɚɪɶ. ȼɵɛɪɚɧ3 ɧɚɹ ɜ ɤɚɥɟɧɞɚɪɟ ɞɚɬɚ ɞɨɥɠɧɚ ɨɬɨɛɪɚɠɚɬɶɫɹ ɧɚ ɩɚɧɟɥɢ ɫɬɚɬɭɫɚ 1. ɇɚ ɩɚɧɟɥɢ Password ɩɨɦɟɫɬɢɬɟ ɤɨɦɩɨɧɟɧɬ TShape. ȼɢɞ ɝɟɨɦɟɬɪɢɱɟɫɤɨɣ ɮɢɝɭɪɵ ɞɨɥɠɟɧ ɢɡɦɟɧɹɬɶɫɹ ɜɨ ɜɪɟɦɟɧɢ. 4 2. ȼ ɥɚɛɨɪɚɬɨɪɧɨɣ ɪɚɛɨɬɟ ʋ 1 ɨɫɭɳɟɫɬɜɢɬɟ ɜɨɡɦɨɠɧɨɫɬɶ ɜɜɨɞɚ ɫ ɩɨɦɨɳɶɸ ɤɨɦɩɨɧɟɧɬɚ TUpDate 1. ɋɧɚɛɞɢɬɟ ɥɚɛɨɪɚɬɨɪɧɭɸ ɪɚɛɨɬɭ ʋ 1 ɜɢɞɟɨɤɥɢɩɨɦ. 5 2. ȼ ɥɚɛɨɪɚɬɨɪɧɨɣ ɪɚɛɨɬɟ ʋ 1 ɨɫɭɳɟɫɬɜɢɬɟ ɜɨɡɦɨɠɧɨɫɬɶ ɜɜɨɞɚ ɫ ɩɨɦɨɳɶɸ ɤɨɦɩɨɧɟɧɬɚ TUpDate 68
ɉɪɨɝɪɚɦɦɭ ɡɚɩɢɲɢɬɟ ɜ ɜɚɲ ɢɧɞɢɜɢɞɭɚɥɶɧɵɣ ɤɚɬɚɥɨɝ Lab_7. ɑɚɫɬɶ II. Ɂɚɱɟɬɧɨɟ ɡɚɧɹɬɢɟ. Ɋɚɡɪɚɛɨɬɤɚ ɩɪɨɫɬɨɝɨ ɩɪɢɥɨɠɟɧɢɹ ɞɥɹ Windows ɜ ɂɋɊ – DELPHI 7 1. Ɉɛɳɢɟ ɪɟɤɨɦɟɧɞɚɰɢɢ ɩɨ ɜɵɩɨɥɧɟɧɢɸ ɡɚɱɟɬɧɨɝɨ ɡɚɞɚɧɢɹ ɉɪɢ ɜɵɩɨɥɧɟɧɢɢ ɥɚɛɨɪɚɬɨɪɧɨɣ ɪɚɛɨɬɵ ɫɬɭɞɟɧɬɵ ɞɨɥɠɧɵ ɩɪɨɞɟɦɨɧɫɬɪɢɪɨɜɚɬɶ ɡɧɚɧɢɹ ɧɚɢɛɨɥɟɟ ɱɚɫɬɨ ɢɫɩɨɥɶɡɭɟɦɵɯ ɤɨɦɩɨɧɟɧɬɨɜ ɩɚɥɢɬɪɵ Delphi ɢ ɪɚɡɪɚɛɨɬɚɬɶ ɬɚɤɨɟ ɩɪɢɥɨɠɟɧɢɟ, ɜ ɤɨɬɨɪɨɦ ɪɚɰɢɨɧɚɥɶɧɨ ɫɨɱɟɬɚɸɬɫɹ ɛɚɡɨɜɵɟ ɷɥɟɦɟɧɬɵ ɭɩɪɚɜɥɟɧɢɹ, ɦɟɧɸ (ɝɥɚɜɧɨɟ ɢ ɜɫɩɥɵɜɚɸɳɟɟ), ɤɚɤ ɷɥɟɦɟɧɬ ɩɪɨɝɪɚɦɦɧɨɝɨ ɢɧɬɟɪɮɟɣɫɚ, ɫɬɚɧɞɚɪɬɧɵɟ ɞɢɚɥɨɝɢ. ȼ ɩɪɢɥɨɠɟɧɢɢ ɧɟɨɛɯɨɞɢɦɨ ɢɫɩɨɥɶɡɨɜɚɬɶ ɝɪɚɮɢɱɟɫɤɢɟ ɢɥɢ ɚɧɢɦɚɰɢɨɧɧɵɟ ɷɮɮɟɤɬɵ. ɉɪɢ ɧɟɨɛɯɨɞɢɦɨɫɬɢ ɩɪɢɥɨɠɟɧɢɟ ɦɨɠɟɬ ɫɨɞɟɪɠɚɬɶ ɧɟɫɤɨɥɶɤɨ ɮɨɪɦ. ȼ ɷɬɨɦ ɫɥɭɱɚɟ ɫɥɟɞɭɟɬ ɩɪɚɜɢɥɶɧɨ ɢɫɩɨɥɶɡɨɜɚɬɶ ɫɜɨɣɫɬɜɚ BorderIcons ɢ BorderStyle ɮɨɪɦɵ. ɉɪɢ ɪɚɫɩɨɥɨɠɟɧɢɢ ɤɨɦɩɨɧɟɧɬɨɜ ɧɟ ɡɚɛɵɜɚɣɬɟ ɢɫɩɨɥɶɡɨɜɚɬɶ ɫɜɨɣɫɬɜɨ Anchors, ɨɩɪɟɞɟɥɹɸɳɟɟ ɫɩɨɫɨɛ ɮɢɤɫɢɪɨɜɚɧɢɹ ɞɨɱɟɪɧɟɝɨ ɤɨɦɩɨɧɟɧɬɚ ɨɬɧɨɫɢɬɟɥɶɧɨ ɝɪɚɧɢɰ ɫɜɨɟɝɨ ɪɨɞɢɬɟɥɶɫɤɨɝɨ ɤɨɦɩɨɧɟɧɬɚ. Ɉɪɝɚɧɢɡɭɣɬɟ ɫɩɪɚɜɨɱɧɭɸ ɫɥɭɠɛɭ ɩɪɢɥɨɠɟɧɢɹ, ɢɫɩɨɥɶɡɭɹ ɫɜɨɣɫɬɜɨ Hint ɢ ShowHint. ɉɪɨɹɜɢɬɟ ɧɚɜɵɤɢ ɨɪɝɚɧɢɡɚɰɢɢ ɢɧɬɟɪɮɟɣɫɚ Drag & Drop. ȼɵɩɨɥɧɟɧɢɟ ɡɚɱɟɬɧɨɝɨ ɡɚɞɚɧɢɹ ɞɨɥɠɧɨ ɩɪɨɯɨɞɢɬ ɜ ɞɜɚ ɷɬɚɩɚ (ɩɨɞɝɨɬɨɜɢɬɟɥɶɧɵɣ ɷɬɚɩ ɢ ɫɚɦɨɫɬɨɹɬɟɥɶɧɚɹ ɪɚɛɨɬɚ). ɉɨɞɝɨɬɨɜɢɬɟɥɶɧɵɣ ɷɬɚɩ 1. ɉɪɨɞɭɦɚɣɬɟ ɤɨɧɫɬɪɭɤɰɢɸ ɮɨɪɦ ɩɪɢɥɨɠɟɧɢɹ ɢ ɨɪɝɚɧɢɡɚɰɢɸ ɜɡɚɢɦɨɞɟɣɫɬɜɢɹ ɮɨɪɦ. 2. ɉɪɢɦɢɬɟ ɪɟɲɟɧɢɟ ɨɛ ɢɫɩɨɥɶɡɨɜɚɧɢɢ ɲɚɛɥɨɧɨɜ ɮɨɪɦ. 3. Ɉɩɪɟɞɟɥɢɬɟ ɫɨɞɟɪɠɚɧɢɟ ɝɥɚɜɧɨɝɨ ɦɟɧɸ ɩɪɢɥɨɠɟɧɢɹ. 4. ɋɨɫɬɚɜɶɬɟ ɩɟɪɟɱɟɧɶ ɫɨɛɵɬɢɣ, ɧɚ ɤɨɬɨɪɵɟ ɞɨɥɠɧɨ ɨɬɤɥɢɤɚɬɶɫɹ ɜɚɲɟ ɩɪɢɥɨɠɟɧɢɟ. ɇɟ ɩɟɪɟɝɪɭɠɚɣɬɟ ɩɪɢɥɨɠɟɧɢɟ ɨɛɪɚɛɨɬɱɢɤɚɦɢ. ɉɨ ɜɨɡɦɨɠɧɨɫɬɢ ɨɛɴɟɞɢɧɹɣɬɟ ɨɛɪɚɛɨɬɱɢɤɢ ɫɨɛɵɬɢɣ, ɢɞɟɧɬɢɮɢɰɢɪɭɹ ɢɫɬɨɱɧɢɤ ɫɨɛɵɬɢɹ ɩɨ ɩɚɪɚɦɟɬɪɭ Sender. 5. Ɋɚɡɪɚɛɨɬɚɣɬɟ ɚɥɝɨɪɢɬɦ ɪɟɲɟɧɢɹ ɡɚɞɚɱɢ ɜ ɤɚɠɞɨɦ ɨɛɪɚɛɨɬɱɢɤɟ ɫɨɛɵɬɢɹ ɢ ɫɨɫɬɚɜɶɬɟ ɩɪɨɝɪɚɦɦɭ. 2. ɋɚɦɨɫɬɨɹɬɟɥɶɧɚɹ ɪɚɛɨɬɚ Ɂɚɞɚɧɢɟ. Ɋɚɡɪɚɛɨɬɚɬɶ ɩɪɨɝɪɚɦɦɭ, ɨɛɥɚɞɚɸɳɭɸ ɮɭɧɤɰɢɨɧɚɥɶɧɵɦɢ ɜɨɡɦɨɠɧɨɫɬɹɦɢ ɫɨɝɥɚɫɧɨ ɢɧɞɢɜɢɞɭɚɥɶɧɨɦɭ ɜɚɪɢɚɧɬɭ. ɉɪɨɝɪɚɦɦɭ ɫɥɟɞɭɟɬ ɫɨɯɪɚɧɢɬɶ ɜ ɩɚɩɤɟ ɫ ɢɦɟɧɟɦ «Ɂɚɱɟɬ». ȼɚɪɢɚɧɬɵ
ɂɫɯɨɞɧɵɟ ɞɚɧɧɵɟ
1
Ɋɚɡɪɚɛɨɬɚɬɶ ɩɪɢɥɨɠɟɧɢɟ, ɩɪɟɞɫɬɚɜɥɹɸɳɟɟ ɫɨɛɨɣ ɡɚɩɢɫɧɭɸ ɤɧɢɠɤɭ ɫ ɞɚɧɧɵɦɢ ɨ ɜɚɲɢɯ ɫɨɤɭɪɫɧɢɤɚɯ. ȼ ɡɚɩɢɫɧɨɣ ɤɧɢɠɤɟ ɞɨɥɠɧɚ ɯɪɚɧɢɬɶɫɹ ɫɥɟɞɭɸɳɚɹ ɢɧɮɨɪɦɚɰɢɹ: ɎɂɈ; ɚɞɪɟɫ ɢ ɬɟ69
2
3
4
5
ɥɟɮɨɧ; ɞɟɧɶ ɪɨɠɞɟɧɢɹ. ȼ ɩɪɢɥɨɠɟɧɢɢ ɩɪɟɞɭɫɦɨɬɪɢɬɟ ɜɵɜɨɞ ɫɨɨɛɳɟɧɢɹ ɨ ɛɥɢɠɚɣɲɟɦ ɞɧɟ ɪɨɠɞɟɧɢɹ Ɋɚɡɪɚɛɨɬɚɬɶ ɩɪɢɥɨɠɟɧɢɟ, ɩɨɡɜɨɥɹɸɳɟɟ ɮɨɪɦɢɪɨɜɚɬɶ ɢ ɩɪɨɫɦɚɬɪɢɜɚɬɶ ɞɚɧɧɵɟ ɨ ɤɧɢɝɚɯ ɩɨ ɩɪɨɝɪɚɦɦɢɪɨɜɚɧɢɸ ɜɚɲɟɣ ɥɢɱɧɨɣ ɛɢɛɥɢɨɬɟɤɢ. Ȼɚɡɚ ɞɚɧɧɵɯ ɜɤɥɸɱɚɟɬ ɫɥɟɞɭɸɳɭɸ ɢɧɮɨɪɦɚɰɢɸ: ɮɚɦɢɥɢɹ ɚɜɬɨɪɚ, ɧɚɡɜɚɧɢɟ ɤɧɢɝɢ, ɧɚɡɜɚɧɢɟ ɢɡɞɚɬɟɥɶɫɬɜɚ, ɝɨɞ ɢɡɞɚɧɢɹ. ɉɪɟɞɭɫɦɨɬɪɟɬɶ ɜɨɡɦɨɠɧɨɫɬɶ ɜɵɜɨɞɚ ɫɩɢɫɤɚ ɤɧɢɝ, ɜɵɩɭɳɟɧɧɵɯ ɡɚɞɚɧɧɵɦ ɢɡɞɚɬɟɥɶɫɬɜɨɦ ɉɨɫɬɪɨɢɬɶ ɬɚɛɥɢɰɭ ɱɟɦɩɢɨɧɚɬɚ ɩɨ ɮɭɬɛɨɥɭ, ɢɫɩɨɥɶɡɭɹ ɤɨɦɩɨɧɟɧɬ TSringGrid. Ɉɪɝɚɧɢɡɨɜɚɬɶ ɩɨɞɫɱɟɬ ɪɟɡɭɥɶɬɚɬɨɜ ɩɪɢ ɤɚɠɞɨɦ ɜɜɨɞɟ ɢɧɮɨɪɦɚɰɢɢ ɜ ɬɚɛɥɢɰɭ. ɇɚɡɜɚɧɢɟ ɥɭɱɲɟɣ ɤɨɦɚɧɞɵ ɜɵɜɟɫɬɢ ɜ ɨɬɞɟɥɶɧɨɦ ɨɤɧɟ Ɋɚɡɪɚɛɨɬɚɬɶ ɩɪɢɥɨɠɟɧɢɟ ɞɥɹ ɜɜɨɞɚ ɢ ɜɵɜɨɞɚ ɪɟɡɭɥɶɬɚɬɨɜ ɫɟɫɫɢɢ ɭɱɟɛɧɨɣ ɝɪɭɩɩɵ. ɉɪɟɞɭɫɦɨɬɪɟɬɶ ɜɨɡɦɨɠɧɨɫɬɶ ɜɵɜɨɞɚ ɫɩɢɫɤɚ ɞɜɨɟɱɧɢɤɨɜ; ɫɩɢɫɤɚ ɫɬɭɞɟɧɬɨɜ, ɫɞɚɜɲɢɯ ɫɟɫɫɢɸ ɛɟɡ ɬɪɨɟɤ; ɫɩɢɫɨɤ ɫɬɭɞɟɧɬɨɜ, ɫɞɚɜɲɢɯ ɫɟɫɫɢɸ ɧɚ ɨɞɧɢ ɩɹɬɟɪɤɢ. ȼɜɨɞ ɢɫɯɨɞɧɨɣ ɢɧɮɨɪɦɚɰɢɢ ɩɪɟɞɫɬɚɜɢɬɶ ɜ ɬɚɛɥɢɱɧɨɣ ɮɨɪɦɟ Ɋɚɡɪɚɛɨɬɚɬɶ ɩɪɢɥɨɠɟɧɢɟ ɞɥɹ ɭɱɟɬɚ ɩɪɨɞɚɧɧɵɯ ɬɨɜɚɪɨɜ. ɉɨ ɤɚɠɞɨɦɭ ɜɢɞɭ ɬɨɜɚɪɚ ɜɜɨɞɢɬɫɹ ɢɧɮɨɪɦɚɰɢɹ: ɧɚɢɦɟɧɨɜɚɧɢɟ, ɚɪɬɢɤɭɥ, ɤɨɥɢɱɟɫɬɜɨ, ɰɟɧɚ ɡɚ ɟɞɢɧɢɰɭ. Ɋɚɫɫɱɢɬɚɬɶ ɫɭɦɦɭ ɜɵɪɭɱɤɢ ɡɚɞɚɧɧɨɦɭ ɜɢɞɭ ɬɨɜɚɪɚ. ȼɵɞɚɬɶ ɨɛɳɭɸ ɫɭɦɦɭ ɪɟɚɥɢɡɚɰɢɢ ɬɨɜɚɪɨɜ
4. ɊȿɄɈɆȿɇȾȺɐɂɂ ɉɈ ɉɈȾȽɈɌɈȼɄȿ ɂ ɈɎɈɊɆɅȿɇɂɘ ɂɇȾɂȼɂȾɍȺɅɖɇɕɏ ɁȺȾȺɇɂɃ – Ʉɭɪɫɨɜɚɹ ɪɚɛɨɬɚ ɞɨɥɠɧɚ ɢɦɟɬɶ ɬɢɬɭɥɶɧɵɣ ɥɢɫɬ (ɩɟɪɜɵɣ ɥɢɫɬ-ɨɛɥɨɠɤɭ) ɫɬɚɧɞɚɪɬɧɨɝɨ ɜɢɞɚ, ɧɚ ɤɨɬɨɪɨɦ ɧɟɨɛɯɨɞɢɦɨ ɭɤɚɡɚɬɶ ɜɫɟ ɫɨɨɬɜɟɬɫɬɜɭɸɳɢɟ ɫɜɟɞɟɧɢɹ ɨɛ ɚɜɬɨɪɟ ɢ ɪɭɤɨɜɨɞɢɬɟɥɟ ɪɚɛɨɬɵ. – Ʉɭɪɫɨɜɚɹ ɪɚɛɨɬɚ ɞɨɥɠɧɚ ɫɨɞɟɪɠɚɬɶ ɩɨɥɧɨɟ ɭɫɥɨɜɢɟ ɤɚɠɞɨɝɨ ɡɚɞɚɧɢɹ ɫ ɩɨɹɫɧɟɧɢɹɦɢ, ɩɪɟɞɜɚɪɢɬɟɥɶɧɵɣ ɚɧɚɥɢɡ ɡɚɞɚɱɢ, ɩɨɫɬɚɧɨɜɤɭ ɡɚɞɚɱɢ ɚɥɝɨɪɢɬɦɢɡɚɰɢɢ, ɛɥɨɤ-ɫɯɟɦɭ ɢɥɢ ɬɟɤɫɬ ɚɥɝɨɪɢɬɦɚ, ɡɚɩɢɫɚɧɧɨɝɨ ɧɚ ɚɥɝɨɪɢɬɦɢɱɟɫɤɨɦ ɹɡɵɤɟ, ɬɟɤɫɬ (ɥɢɫɬɢɧɝ ɢɥɢ ɪɚɫɩɟɱɚɬɤɭ) ɩɪɨɝɪɚɦɦɵ, ɩɨɥɭɱɟɧɧɵɟ ɪɟɡɭɥɶɬɚɬɵ ɢ ɢɯ ɚɧɚɥɢɡ. – ȼ ɩɨɫɥɟɞɧɟɦ ɩɭɧɤɬɟ ɧɟɨɛɯɨɞɢɦɨ ɩɪɟɞɫɬɚɜɢɬɶ ɪɟɡɭɥɶɬɚɬɵ ɞɨɤɚɡɚɬɟɥɶɫɬɜɚ ɩɪɚɜɢɥɶɧɨɫɬɢ ɪɚɛɨɬɵ ɩɪɨɝɪɚɦɦɵ (ɫɜɟɞɟɧɢɹ ɨ ɬɟɫɬɢɪɨɜɚɧɢɢ, ɜɟɪɢɮɢɤɚɰɢɢ, ɤɨɧɬɪɨɥɶɧɵɟ ɪɚɫɱɟɬɵ). – ȼ ɬɟɤɫɬɟ ɩɪɨɝɪɚɦɦ ɞɨɥɠɧɵ ɛɵɬɶ ɜɫɟ ɧɟɨɛɯɨɞɢɦɵɟ ɪɚɡɞɟɥɵ: ɡɚɝɨɥɨɜɨɤ, ɜɜɨɞɧɵɣ ɤɨɦɦɟɧɬɚɪɢɣ, ɨɩɢɫɚɧɢɟ ɢ ɨɛɴɹɜɥɟɧɢɟ ɞɚɧɧɵɯ, ɢɞɟɧɬɢɮɢɤɚɰɢɹ ɩɪɨɝɪɚɦɦɵ, ɜɜɨɞ ɢ ɤɨɧɬɪɨɥɶ ɢɫɯɨɞɧɵɯ ɞɚɧɧɵɯ, ɨɫɧɨɜɧɚɹ ɱɚɫɬɶ ɢ ɜɵɜɨɞ ɪɟɡɭɥɶɬɚɬɨɜ. – ȼɫɟ ɨɫɧɨɜɧɵɟ ɩɪɟɞɩɢɫɚɧɢɹ ɪɟɚɥɢɡɭɸɬɫɹ ɫ ɩɨɦɨɳɶɸ ɩɨɞɩɪɨɝɪɚɦɦ ɩɪɨɰɟɞɭɪ ɢ ɮɭɧɤɰɢɣ: ɜɜɨɞ ɢɫɯɨɞɧɵɯ ɞɚɧɧɵɯ, ɢɞɟɧɬɢɮɢɤɚɰɢɹ ɪɚɫɱɟɬɨɜ (ɢɥɢ ɩɪɨ70
ɝɪɚɦɦɵ), ɨɫɧɨɜɧɵɟ ɞɟɣɫɬɜɢɹ ɩɨ ɩɪɟɨɛɪɚɡɨɜɚɧɢɸ ɢɧɮɨɪɦɚɰɢɢ ɢ ɜɵɜɨɞ ɪɟɡɭɥɶɬɚɬɨɜ ɪɚɛɨɬɵ ɩɪɨɝɪɚɦɦɵ. – ȼɵɛɨɪ ɢɦɟɧ ɞɚɧɧɵɯ ɢ ɩɪɨɝɪɚɦɦɧɵɯ ɟɞɢɧɢɰ ɞɨɥɠɟɧ ɢɦɟɬɶ ɫɨɞɟɪɠɚɬɟɥɶɧɵɣ ɫɦɵɫɥ ɢ ɜ ɨɛɴɹɜɥɟɧɢɢ ɨɧɢ ɨɛɹɡɚɧɵ ɛɵɬɶ ɩɪɨɤɨɦɦɟɧɬɢɪɨɜɚɧɵ. – ɉɪɢ ɪɚɡɪɚɛɨɬɤɟ ɩɪɨɝɪɚɦɦ ɩɪɟɞɭɫɦɚɬɪɢɜɚɟɬɫɹ ɜɨɡɦɨɠɧɨɫɬɶ ɪɚɛɨɬɵ ɫ ɧɢɦɢ ɧɟ ɩɪɨɮɟɫɫɢɨɧɚɥɶɧɵɯ ɩɨɥɶɡɨɜɚɬɟɥɟɣ. – ɉɪɨɝɪɚɦɦɵ ɞɨɥɠɧɵ ɛɵɬɶ ɨɩɬɢɦɢɡɢɪɨɜɚɧɵ: ɜ ɧɢɯ ɧɟ ɞɨɥɠɧɵ ɫɨɞɟɪɠɚɬɶɫɹ ɩɨɜɬɨɪɹɸɳɢɟɫɹ ɞɟɣɫɬɜɢɹ ɩɨ ɩɪɟɨɛɪɚɡɨɜɚɧɢɸ ɢɧɮɨɪɦɚɰɢɢ, ɨɩɟɪɚɬɢɜɧɚɹ ɩɚɦɹɬɶ ɞɨɥɠɧɚ ɢɫɩɨɥɶɡɨɜɚɬɶɫɹ ɪɚɰɢɨɧɚɥɶɧɨ, ɩɪɢ ɨɬɫɭɬɫɬɜɢɢ ɫɩɟɰɢɚɥɶɧɵɯ ɭɤɚɡɚɧɢɣ ɜɪɟɦɹ ɜɵɩɨɥɧɟɧɢɹ ɞɨɥɠɧɨ ɛɵɬɶ ɦɢɧɢɦɚɥɶɧɵɦ. – ɉɨɫɥɟ ɡɚɩɢɫɢ ɬɟɤɫɬɚ ɚɥɝɨɪɢɬɦɚ ɜ ɤɭɪɫɨɜɨɣ ɪɚɛɨɬɟ ɞɨɥɠɟɧ ɛɵɬɶ ɩɨɞɩɭɧɤɬ, ɜ ɤɨɬɨɪɨɦ ɤɪɚɬɤɨ ɨɩɢɫɚɧɵ ɞɟɣɫɬɜɢɹ ɫɬɭɞɟɧɬɚ ɩɨ ɨɩɬɢɦɢɡɚɰɢɢ ɩɪɨɝɪɚɦɦɵ: ɜɵɛɨɪ ɢ ɨɛɨɫɧɨɜɚɧɢɟ ɧɚɢɥɭɱɲɟɝɨ ɫɨɨɬɧɨɲɟɧɢɹ ɦɟɠɞɭ ɨɫɧɨɜɧɵɦɢ ɩɨɤɚɡɚɬɟɥɹɦɢ ɤɚɱɟɫɬɜɚ ɩɪɨɝɪɚɦɦɵ – ɩɚɦɹɬɶ – ɜɪɟɦɹ ɜɵɩɨɥɧɟɧɢɹ – ɹɫɧɨɫɬɶ ɬɟɤɫɬɚ. – ȼɚɠɧɟɣɲɢɦ ɤɚɱɟɫɬɜɨɦ ɩɪɨɝɪɚɦɦ ɹɜɥɹɟɬɫɹ ɢɯ «ɱɢɬɚɛɟɥɶɧɨɫɬɶ», ɬɨ ɟɫɬɶ ɹɫɧɨɫɬɶ ɢ ɩɨɧɹɬɧɨɫɬɶ ɫɬɪɭɤɬɭɪɵ, ɩɪɨɫɬɨɬɚ ɥɨɝɢɤɢ ɚɥɝɨɪɢɬɦɚ ɢ ɬ. ɩ. Ⱦɥɹ ɷɬɨɝɨ ɬɟɤɫɬɵ ɚɥɝɨɪɢɬɦɨɜ ɢ ɩɪɨɝɪɚɦɦ ɩɢɲɭɬɫɹ ɩɨ ɭɪɨɜɧɹɦ. – ɇɚɥɢɱɢɟ ɜ ɬɟɤɫɬɟ ɧɟɨɛɯɨɞɢɦɵɯ ɤɨɦɦɟɧɬɚɪɢɟɜ (ɥɢɲɧɢɯ ɧɟ ɞɨɥɠɧɨ ɛɵɬɶ). – Ɉɮɨɪɦɥɟɧɢɟ ɤɭɪɫɨɜɨɣ ɪɚɛɨɬɵ ɜɵɩɨɥɧɹɟɬɫɹ ɜ ɬɟɤɫɬɨɜɨɦ ɪɟɞɚɤɬɨɪɟ Microsoft Word. Ɋɚɡɦɟɪ ɛɭɦɚɝɢ – ɮɨɪɦɚɬ Ⱥ4; ɲɪɢɮɬ: Times New Roman – 12 ɢɥɢ 14; ɩɨɥɹ – 2,5 × 2,0 × 3,0 × 1,5. – Ɏɨɪɦɚɬɢɪɨɜɚɧɢɟ ɜɵɩɨɥɧɹɟɬɫɹ ɜ ɫɨɨɬɜɟɬɫɬɜɢɢ ɫ ɨɛɳɢɦɢ ɬɪɟɛɨɜɚɧɢɹɦɢ ȽɈɋɌɚ ɤ ɞɨɤɭɦɟɧɬɚɦ ɬɚɤɨɝɨ ɬɢɩɚ. Ɇɟɠɫɬɪɨɱɧɵɣ ɢɧɬɟɪɜɚɥ – ɨɞɢɧɚɪɧɵɣ; ɚɛɡɚɰɧɵɣ ɨɬɫɬɭɩ 1,0; ɜɵɪɚɜɧɢɜɚɧɢɟ ɩɨ ɲɢɪɢɧɟ ɫɬɪɨɤɢ. – ɉɪɢ ɡɚɩɢɫɢ ɦɚɬɟɦɚɬɢɱɟɫɤɢɯ ɜɵɪɚɠɟɧɢɣ ɭɫɬɚɧɚɜɥɢɜɚɸɬɫɹ ɫɥɟɞɭɸɳɢɟ ɩɚɪɚɦɟɬɪɵ ɪɟɞɚɤɬɨɪɚ ɮɨɪɦɭɥ: 14–8–6–16–10. – Ʉɭɪɫɨɜɚɹ ɪɚɛɨɬɚ ɞɨɥɠɧɚ ɛɵɬɶ ɚɤɤɭɪɚɬɧɨ ɨɮɨɪɦɥɟɧɚ ɜ ɬɟɬɪɚɞɢ ɢɥɢ ɧɚ ɨɬɞɟɥɶɧɵɯ ɥɢɫɬɚɯ. ȼ ɩɨɫɥɟɞɧɟɦ ɫɥɭɱɚɟ ɥɢɫɬɵ ɞɨɥɠɧɵ ɛɵɬɶ ɩɪɨɧɭɦɟɪɨɜɚɧɵ, ɩɥɨɬɧɨ ɫɤɪɟɩɥɟɧɵ ɦɟɠɞɭ ɫɨɛɨɣ ɢɥɢ ɡɚɤɪɟɩɥɟɧɵ ɜ ɨɬɞɟɥɶɧɨɣ ɩɚɩɤɟ.
71
ɉɪɢɥɨɠɟɧɢɟ 1. Ƚɥɚɜɧɨɟ ɢɥɢ ɨɫɧɨɜɧɨɟ ɦɟɧɸ ɫɪɟɞɵ Delphi Ɍɚɛɥɢɰɚ 1.1 Ɉɩɰɢɹ File ɇɚɡɜɚɧɢɟ Ɏɭɧɤɰɢɹ New Ɉɩɰɢɹ-ɡɚɝɨɥɨɜɨɤ. ɉɪɢ ɟɟ ɜɵɛɨɪɟ ɪɚɫɤɪɵɜɚɟɬɫɹ ɩɨɞɦɟɧɸ ɫɨ ɫɥɟɞɭɸɳɢɦɢ ɨɩɰɢɹɦɢ: Application ɫɨɡɞɚɟɬ ɧɨɜɭɸ ɩɪɨɝɪɚɦɦɭ ɞɥɹ Windows CLX ɫɨɡɞɚɟɬ ɧɨɜɭɸ ɩɪɨɝɪɚɦɦɭ ɞɥɹ Windows ɢ Linux Application Data Module ɫɨɡɞɚɟɬ ɧɨɜɵɣ ɦɨɞɭɥɶ ɞɚɧɧɵɯ Form ɫɨɡɞɚɟɬ ɧɨɜɭɸ ɮɨɪɦɭ ɢ ɩɨɞɤɥɸɱɚɟɬ ɟɟ ɤ ɩɪɨɟɤɬɭ Frame ɫɨɡɞɚɟɬ ɧɨɜɭɸ ɪɚɦɭ Other ɨɬɤɪɵɜɚɟɬ ɨɤɧɨ ɪɟɩɨɡɢɬɨɪɢɹ Exit ɜɫɬɚɜɥɹɟɬ ɜ ɬɟɤɭɳɭɸ ɮɨɪɦɭ ɫɫɵɥɤɭ ɧɚ ɞɪɭɝɨɣ ɦɨɞɭɥɶ, ɩɟɱɚɬɚɟɬ ɚɤɬɢɜɧɭɸ ɮɨɪɦɭ ɢɥɢ ɦɨɞɭɥɶ, ɩɪɟɤɪɚɳɚɟɬ ɪɚɛɨɬɭ Delphi Print ɡɚɤɪɵɜɚɟɬ ɜɫɟ ɨɬɤɪɵɬɵɟ ɮɚɣɥɵ Unit ɡɚɤɪɵɜɚɟɬ ɬɟɤɭɳɭɸ ɮɨɪɦɭ Open ɨɬɤɪɵɜɚɟɬ ɪɚɧɟɟ ɫɨɡɞɚɧɧɭɸ ɮɨɪɦɭ Open Project ɨɬɤɪɵɜɚɟɬ ɪɚɧɟɟ ɫɨɡɞɚɧɧɵɣ ɩɪɨɟɤɬ Reopen ɜɵɡɵɜɚɟɬ ɫɩɢɫɨɤ ɪɚɧɟɟ ɡɚɝɪɭɠɚɜɲɢɯɫɹ ɩɪɨɟɤɬɨɜ ɢ ɮɨɪɦ ɞɥɹ ɜɵɛɨɪɚ ɢ ɩɨɜɬɨɪɧɨɣ ɡɚɝɪɭɡɤɢ Save Save As ɫɨɯɪɚɧɹɟɬ ɚɤɬɢɜɧɭɸ ɮɨɪɦɭ Save Project As ɫɨɯɪɚɧɹɟɬ ɚɤɬɢɜɧɭɸ ɮɨɪɦɭ ɩɨɞ ɞɪɭɝɢɦ ɢɦɟɧɟɦ Save All Close ɫɨɯɪɚɧɹɟɬ ɮɚɣɥ ɩɪɨɟɤɬɚ ɩɨɞ ɞɪɭɝɢɦ ɢɦɟɧɟɦ Close All Use ɫɨɯɪɚɧɹɟɬ ɮɚɣɥ ɩɪɨɟɤɬɚ ɢ ɜɫɟ ɨɬɤɪɵɬɵɟ ɦɨɞɭɥɢ
ɇɚɡɜɚɧɢɟ Undo Redo Cut Copy
Paste
Ɍɚɛɥɢɰɚ 1.2 Ɉɩɰɢɹ Edit Ɏɭɧɤɰɢɹ Ɉɬɦɟɧɹɟɬ ɩɨɫɥɟɞɧɟɟ ɢɡɦɟɧɟɧɢɟ ɩɪɨɟɤɬɚ ȼɨɫɫɬɚɧɚɜɥɢɜɚɟɬ ɩɨɫɥɟɞɧɟɟ ɢɡɦɟɧɟɧɢɟ ɩɪɨɟɤɬɚ ȼɵɪɟɡɚɟɬ ɜɵɛɪɚɧɧɵɣ ɤɨɦɩɨɧɟɧɬ ɮɨɪɦɵ ɢɥɢ ɮɪɚɝɦɟɧɬ ɬɟɤɫɬɚ ɢ ɩɨɦɟɳɚɟɬ ɟɝɨ ɜ ɛɭɮɟɪ Clipboard Ʉɨɩɢɪɭɟɬ ɜ Clipboard ɜɵɞɟɥɟɧɧɵɟ ɤɨɦɩɨɧɟɧɬɵ ɮɨɪɦɵ ɢɥɢ ɮɪɚɝɦɟɧɬ ɬɟɤɫɬɚ ɦɨɞɭɥɹ ɂɡɜɥɟɤɚɟɬ ɢɡ ɛɭɮɟɪɚ ɢ ɩɟɪɟɧɨɫɢɬ ɤɨɦɩɨɧɟɧɬɵ ɧɚ ɮɨɪɦɭ ɢɥɢ ɤɨɩɢɪɭɟɬ ɬɟɤɫɬ ɜ ɦɨɞɭɥɶ (ɜ ɩɨɡɢɰɢɸ, ɭɤɚɡɵɜɚɟɦɭɸ ɬɟɤɭɳɢɦ ɩɨɥɨɠɟɧɢɟɦ ɬɟɤɫɬɨɜɨɝɨ ɤɭɪɫɨɪɚ) 72
ɍɞɚɥɹɟɬ ɜɵɞɟɥɟɧɧɵɟ ɤɨɦɩɨɧɟɧɬɵ ɢɥɢ ɮɪɚɝɦɟɧɬ ɬɟɤɫɬɚ ȼɵɞɟɥɹɟɬ ɜɫɟ ɤɨɦɩɨɧɟɧɬɵ ɮɨɪɦɵ ɢɥɢ ɜɟɫɶ ɬɟɤɫɬ ɦɨɞɭɥɹ Align To Grid ɉɪɢɜɹɡɵɜɚɟɬ ɜɵɞɟɥɟɧɧɵɟ ɤɨɦɩɨɧɟɧɬɵ ɤ ɦɚɫɲɬɚɛɧɨɣ ɫɟɬɤɟ ɬɚɤ, ɱɬɨɛɵ ɢɯ ɥɟɜɵɟ ɜɟɪɯɧɢɟ ɭɝɥɵ ɪɚɫɩɨɥɚɝɚɥɢɫɶ ɜ ɛɥɢɠɚɣɲɢɯ ɬɨɱɤɚɯ ɫɟɬɤɢ Bring To Front ɉɟɪɟɦɟɳɚɟɬ ɜɵɞɟɥɟɧɧɵɟ ɤɨɦɩɨɧɟɧɬɵ ɧɚ ɩɟɪɟɞɧɢɣ ɩɥɚɧ Send To Back ɉɟɪɟɦɟɳɚɟɬ ɜɵɞɟɥɟɧɧɵɟ ɤɨɦɩɨɧɟɧɬɵ ɧɚ ɡɚɞɧɢɣ ɩɥɚɧ Align ȼɵɡɵɜɚɟɬ ɨɤɧɨ ɜɵɪɚɜɧɢɜɚɧɢɹ ɜɵɞɟɥɟɧɧɵɯ ɤɨɦɩɨɧɟɧɬɨɜ Size ȼɵɡɵɜɚɟɬ ɨɤɧɨ ɢɡɦɟɧɟɧɢɹ ɪɚɡɦɟɪɨɜ ɜɵɞɟɥɟɧɧɵɯ ɤɨɦɩɨɧɟɧɬɨɜ Scale Ɇɚɫɲɬɚɛɢɪɭɟɬ ɜɵɞɟɥɟɧɧɵɟ ɤɨɦɩɨɧɟɧɬɵ Tab Order ɂɡɦɟɧɹɟɬ ɩɨɪɹɞɨɤ ɨɛɯɨɞɚ ɤɨɦɩɨɧɟɧɬɨɜ ɤɥɚɜɢɲɟɣ Tab Creation Order ɂɡɦɟɧɹɟɬ ɩɨɪɹɞɨɤ ɫɨɡɞɚɧɢɹ ɧɟɜɢɡɭɚɥɶɧɵɯ ɤɨɦɩɨɧɟɧɬɨɜ Flip Children ɂɡɦɟɧɹɟɬ ɫɜɨɣɫɬɜɨ BiDiMode ɞɥɹ ɜɫɟɯ ɢɥɢ ɬɨɥɶɤɨ ɞɥɹ ɜɵɞɟɥɟɧɧɵɯ ɤɨɦɩɨɧɟɧɬɨɜ. Ȼɥɨɤɢɪɭɟɬ ɜɨɡɦɨɠɧɨɫɬɶ ɩɟLock Controls Add to interface ɪɟɦɟɳɟɧɢɹ ɤɨɦɩɨɧɟɧɬɨɜ ɧɚ ɮɨɪɦɟ. Ɉɩɪɟɞɟɥɹɟɬ ɧɨɜɵɟ ɫɜɨɣɫɬɜɚ, ɦɟɬɨɞɵ ɢ ɫɨɛɵɬɢɹ ɞɥɹ ɤɨɦɩɨɧɟɧɬɨɜ ActiveX Delete Select All
Ɍɚɛɥɢɰɚ 1.3 Ɉɩɰɢɹ Run ɇɚɡɜɚɧɢɟ Ɏɭɧɤɰɢɹ Run Ʉɨɦɩɢɥɢɪɭɟɬ ɩɪɨɝɪɚɦɦɭ ɢ ɞɟɥɚɟɬ ɟɟ ɩɪɨɝɨɧ Attach to ɉɨɡɜɨɥɹɟɬ ɩɪɢɫɨɟɞɢɧɢɬɶɫɹ ɜ ɪɟɠɢɦɟ ɨɬɥɚɞɤɢ ɤ ɨɞɧɨɦɭ Process ɢɡ ɭɠɟ ɡɚɩɭɳɟɧɧɵɯ ɩɪɨɰɟɫɫɨɜ ɧɚ ɞɪɭɝɨɣ ɫɟɬɟɜɨɣ ɦɚɲɢɧɟ Parameters ɍɤɚɡɵɜɚɟɬ ɤɨɦɚɧɞɧɭɸ ɫɬɪɨɤɭ ɡɚɩɭɫɤɚ ɜɚɲɟɣ ɩɪɨɝɪɚɦɦɵ Register Ɋɟɝɢɫɬɪɢɪɭɟɬ ɜɚɲ ɩɪɨɟɤɬ ɜ ɪɟɟɫɬɪɟ Windows. Ɉɩɰɢɹ ActiveX Servers ɞɨɫɬɭɩɧɚ ɞɥɹ ActiveX-ɩɪɨɟɤɬɨɜ Unregister ɍɞɚɥɹɟɬ ɜɚɲ ɩɪɨɟɤɬ ɢɡ ɪɟɟɫɬɪɚ Windows. Ɉɩɰɢɹ ɞɨɫActiveX Servers ɬɭɩɧɚ ɞɥɹ ActiveX-ɩɪɨɟɤɬɨɜ Install MTS Ɋɟɝɢɫɬɪɢɪɭɟɬ ɜ ɜɚɲɟɦ ɩɪɨɟɤɬɟ ɨɛɴɟɤɬ MTS Objects Step Over ȼ ɨɬɥɚɞɨɱɧɨɦ ɪɟɠɢɦɟ ɜɵɩɨɥɧɹɟɬ ɬɟɤɭɳɭɸ ɫɬɪɨɤɭ ɤɨɞɚ ɢ ɧɟ ɩɪɨɫɥɟɠɢɜɚɟɬ ɪɚɛɨɬɭ ɜɵɡɵɜɚɟɦɵɯ ɩɨɞɩɪɨɝɪɚɦɦ Trace Into ȼ ɨɬɥɚɞɨɱɧɨɦ ɪɟɠɢɦɟ ɜɵɩɨɥɧɹɟɬ ɬɟɤɭɳɭɸ ɫɬɪɨɤɭ ɤɨɞɚ ɢ ɩɪɨɫɥɟɠɢɜɚɟɬ ɪɚɛɨɬɭ ɜɵɡɵɜɚɟɦɵɯ ɩɨɞɩɪɨɝɪɚɦɦ 73
Trace To Next Source Line
ɉɪɨɝɪɚɦɦɚ ɜɵɩɨɥɧɹɟɬɫɹ ɞɨ ɛɥɢɠɚɣɲɟɝɨ ɨɬ ɬɟɤɭɳɟɝɨ ɩɨɥɨɠɟɧɢɹ ɤɭɪɫɨɪɚ ɢɫɩɨɥɧɹɟɦɨɝɨ ɨɩɟɪɚɬɨɪɚ
ȼ ɨɬɥɚɞɨɱɧɨɦ ɪɟɠɢɦɟ ɜɵɩɨɥɧɹɟɬ ɩɪɨɝɪɚɦɦɭ ɢ ɨɫɬɚɧɚɜɥɢɜɚɟɬɫɹ ɩɟɪɟɞ ɜɵɩɨɥɧɟɧɢɟɦ ɤɨɞɚ ɜ ɫɬɪɨɤɟ ɫ ɬɟɤɫɬɨɜɵɦ ɤɭɪɫɨɪɨɦ Run Until ȼ ɨɬɥɚɞɨɱɧɨɦ ɪɟɠɢɦɟ ɜɵɩɨɥɧɹɟɬ ɬɟɤɭɳɭɸ ɩɨɞɩɪɨReturn ɝɪɚɦɦɭ ɢ ɨɫɬɚɧɚɜɥɢɜɚɟɬɫɹ Show Execution Ɉɬɨɛɪɚɠɚɟɬ ɜ ɨɤɧɟ ɤɨɞɚ ɨɩɟɪɚɬɨɪ, ɧɚ ɤɨɬɨɪɨɦ ɛɵɥɨ Point ɩɪɟɪɜɚɧɨ ɜɵɩɨɥɧɟɧɢɟ ɩɪɨɝɪɚɦɦɵ Program Pause ɉɪɢɨɫɬɚɧɚɜɥɢɜɚɟɬ ɩɪɨɝɨɧ ɨɬɥɚɠɢɜɚɟɦɨɣ ɩɪɨɝɪɚɦɦɵ Run To Cursor
ɉɪɟɤɪɚɳɚɟɬ ɩɪɨɝɨɧ ɩɪɨɝɪɚɦɦɵ ɢ ɜɨɫɫɬɚɧɚɜɥɢɜɚɟɬ ɪɟɠɢɦ ɤɨɧɫɬɪɭɢɪɨɜɚɧɢɹ ɩɪɨɝɪɚɦɦɵ Inspect Ɉɬɤɪɵɜɚɟɬ ɨɤɧɨ ɩɪɨɜɟɪɤɢ ɬɟɤɭɳɟɝɨ ɡɧɚɱɟɧɢɹ Evaluate/Modify Ɉɬɤɪɵɜɚɟɬ ɨɤɧɨ ɩɪɨɜɟɪɤɢ/ɢɡɦɟɧɟɧɢɹ ɩɟɪɟɦɟɧɧɵɯ Add Watch Ⱦɨɛɚɜɥɹɟɬ ɩɟɪɟɦɟɧɧɭɸ ɢɥɢ ɜɵɪɚɠɟɧɢɟ ɜ ɨɤɧɨ ɧɚɛɥɸɞɟɧɢɹ Add Breakpoint Ⱦɨɛɚɜɥɹɟɬ ɬɨɱɤɭ ɨɫɬɚɧɨɜɚ Program Reset
Ɍɚɛɥɢɰɚ 1.4 ɉɢɤɬɨɝɪɚɮɢɱɟɫɤɢɟ ɤɧɨɩɤɢ ɩɚɧɟɥɢ ɢɧɫɬɪɭɦɟɧɬɨɜ Ɋɟɚɥɢɡɭɟɦɨɟ ɤɧɨɩɤɨɣ ɞɟɣɫɬɜɢɟ Ƚɪɭɩɩɚ Standard Ɉɬɤɪɵɜɚɟɬ ɞɨɫɬɭɩ ɤ Ɋɟɩɨɡɢɬɨɪɢɸ Ɉɛɴɟɤɬɨɜ. ɗɤɜɢɜɚɥɟɧɬ ɨɩɰɢɢ File | New | Other (ɷɬɨɣ ɤɧɨɩɤɢ ɧɟɬ ɜ ɜɟɪɫɢɹɯ 1, 2 ɢ 3) Ɉɬɤɪɵɜɚɟɬ ɫɭɳɟɫɬɜɭɸɳɢɣ ɮɚɣɥ. ɗɤɜɢɜɚɥɟɧɬ ɨɩɰɢɢ File | Open File ɋɨɯɪɚɧɹɟɬ ɮɚɣɥ ɧɚ ɞɢɫɤɟ. ɗɤɜɢɜɚɥɟɧɬ ɨɩɰɢɢ File | Save File (ɤɥɚɜɢɲɢ ɛɵɫɬɪɨɝɨ ɞɨɫɬɭɩɚ Ctrl-S) ɋɨɯɪɚɧɹɟɬ ɜɫɟ ɮɚɣɥɵ ɩɪɨɟɤɬɚ. ɗɤɜɢɜɚɥɟɧɬ ɨɩɰɢɢ File | Save All Ɉɬɤɪɵɜɚɟɬ ɫɨɡɞɚɧɧɵɣ ɪɚɧɟɟ ɩɪɨɟɤɬ ɩɪɨɝɪɚɦɦɵ. ɗɤɜɢɜɚɥɟɧɬ ɨɩɰɢɢ File | Open Project (ɤɥɚɜɢɲɢ ɛɵɫɬɪɨɝɨ ɞɨɫɬɭɩɚ Ctrl-F11) Ⱦɨɛɚɜɥɹɟɬ ɧɨɜɵɣ ɮɚɣɥ ɤ ɩɪɨɟɤɬɭ. ɗɤɜɢɜɚɥɟɧɬ ɨɩɰɢɢ Project | Add to project (ɤɥɚɜɢɲɢ ɛɵɫɬɪɨɝɨ ɞɨɫɬɭɩɚ Shift-F11) ɍɞɚɥɹɟɬ ɮɚɣɥ ɢɡ ɩɪɨɟɤɬɚ. ɗɤɜɢɜɚɥɟɧɬ ɨɩɰɢɢ Project | Remove from Project Ƚɪɭɩɩɚ View ȼɵɛɢɪɚɟɬ ɦɨɞɭɥɶ ɢɡ ɫɩɢɫɤɚ ɦɨɞɭɥɟɣ, ɫɜɹɡɚɧɧɵɯ ɫ ɬɟɤɭɳɢɦ ɩɪɨɟɤɬɨɦ. ɗɤɜɢɜɚɥɟɧɬ ɨɩɰɢɢ View | units (ɤɥɚɜɢɲɢ ɛɵɫɬɪɨɝɨ ɞɨɫɬɭɩɚ Shift-F12) ȼɵɛɢɪɚɟɬ ɮɨɪɦɭ ɢɡ ɫɩɢɫɤɚ ɮɨɪɦ, ɫɜɹɡɚɧɧɵɯ ɫ ɬɟɤɭɳɢɦ ɩɪɨɟɤɬɨɦ. ɗɤɜɢɜɚɥɟɧɬ ɨɩɰɢɢ View | Forms (ɤɥɚɜɢɲɢ ɛɵɫɬɪɨɝɨ ɞɨɫɬɭɩɚ Ctrl-F12) 74
ɉɟɪɟɤɥɸɱɚɟɬ ɚɤɬɢɜɧɨɫɬɶ ɦɟɠɞɭ ɨɤɧɨɦ ɮɨɪɦɵ ɢ ɨɤɧɨɦ ɤɨɞɚ ɩɪɨɝɪɚɦɦɵ. ɗɤɜɢɜɚɥɟɧɬ ɨɩɰɢɢ View | Toggle Form/Unit (ɤɥɚɜɢɲɚ ɛɵɫɬɪɨɝɨ ɞɨɫɬɭɩɚ F12) ɋɨɡɞɚɟɬ ɧɨɜɭɸ ɮɨɪɦɭ ɢ ɞɨɛɚɜɥɹɟɬ ɟɟ ɤ ɩɪɨɟɤɬɭ. ɗɤɜɢɜɚɥɟɧɬ ɨɩɰɢɢ File | New | Form (ɷɬɨɣ ɤɧɨɩɤɢ ɧɟɬ ɜ ɜɟɪɫɢɹɯ 1 ɢ 2) Ƚɪɭɩɩɚ Debug Ʉɨɦɩɢɥɢɪɭɟɬ ɢ ɜɵɩɨɥɧɹɟɬ ɩɪɨɝɪɚɦɦɭ. ɗɤɜɢɜɚɥɟɧɬ ɨɩɰɢɢ Run | Run (ɤɥɚɜɢɲɚ ɛɵɫɬɪɨɝɨ ɞɨɫɬɭɩɚ F9) Ɋɟɚɥɢɡɭɟɬ ɩɚɭɡɭ ɜ ɪɚɛɨɬɟ ɨɬɥɚɠɢɜɚɟɦɨɣ ɩɪɨɝɪɚɦɦɵ. ɗɤɜɢɜɚɥɟɧɬ ɨɩɰɢɢ Run | Program Pause Ɉɫɭɳɟɫɬɜɥɹɟɬ ɩɨɲɚɝɨɜɭɸ ɬɪɚɫɫɢɪɨɜɤɭ ɩɪɨɝɪɚɦɦɵ ɫ ɩɪɨɫɥɟɠɢɜɚɧɢɟɦ ɪɚɛɨɬɵ ɜɵɡɵɜɚɟɦɵɯ ɩɨɞɩɪɨɝɪɚɦɦ. ɗɤɜɢɜɚɥɟɧɬ ɨɩɰɢɢ Run | Trace into (ɤɥɚɜɢɲɚ ɛɵɫɬɪɨɝɨ ɞɨɫɬɭɩɚ F7) Ɉɫɭɳɟɫɬɜɥɹɟɬ ɩɨɲɚɝɨɜɭɸ ɬɪɚɫɫɢɪɨɜɤɭ ɩɪɨɝɪɚɦɦɵ, ɧɨ ɧɟ ɩɪɨɫɥɟɠɢɜɚɟɬ ɪɚɛɨɬɭ ɜɵɡɵɜɚɟɦɵɯ ɩɨɞɩɪɨɝɪɚɦɦ. ɗɤɜɢɜɚɥɟɧɬ ɨɩɰɢɢ Run | Step Over (ɤɥɚɜɢɲɚ ɛɵɫɬɪɨɝɨ ɞɨɫɬɭɩɚ F8) Ƚɪɭɩɩɚ Custome Ɉɬɤɪɵɜɚɟɬ ɞɨɫɬɭɩ ɤ ɜɫɬɪɨɟɧɧɨɣ ɫɩɪɚɜɨɱɧɨɣ ɫɥɭɠɛɟ. ɗɤɜɢɜɚɥɟɧɬ ɨɩɰɢɢ Help | Delphi Help (ɷɬɨɣ ɤɧɨɩɤɢ ɧɟɬ ɜ ɜɟɪɫɢɹɯ 1, 2 ɢ 3) Ƚɪɭɩɩɚ Desktops ɋɩɢɫɨɤ ɜɵɛɨɪɚ ɜɨɡɦɨɠɧɵɯ ɜɚɪɢɚɧɬɨɜ ɧɚɫɬɪɨɣɤɢ ɨɫɬɚɥɶɧɵɯ ɨɤɨɧ Delphi ɋɨɯɪɚɧɹɟɬ ɬɟɤɭɳɭɸ ɧɚɫɬɪɨɣɤɭ ɨɤɨɧ Delphi ȼɵɛɢɪɚɟɬ ɧɚɫɬɪɨɣɤɭ ɨɤɨɧ, ɫɨɨɬɜɟɬɫɬɜɭɸɳɭɸ ɨɬɥɚɞɨɱɧɨɦɭ ɪɟɠɢɦɭ Ƚɪɭɩɩɚ Internet ɇɚɱɢɧɚɟɬ ɫɨɡɞɚɧɢɟ ɧɨɜɨɝɨ ɩɪɢɥɨɠɟɧɢɹ ɩɨ ɬɟɯɧɨɥɨɝɢɢ WebSnap (ɞɥɹ ɂɧɬɟɪɧɟɬ) ɋɨɡɞɚɟɬ ɧɨɜɭɸ ɫɬɪɚɧɢɰɭ ɩɪɢɥɨɠɟɧɢɹ WebSnap ɋɨɡɞɚɟɬ ɧɨɜɵɣ ɦɨɞɭɥɶ ɞɚɧɧɵɯ ɩɪɢɥɨɠɟɧɢɹ WebSnap
ɉɪɢɥɨɠɟɧɢɟ 2. Ɇɟɧɸ ɤɨɦɩɨɧɟɧɬɨɜ Ʉɨɦɩɨɧɟɧɬ Edit ɫɬɪɚɧɢɰɵ Standart Ʉɨɦɩɨɧɟɧɬ Edit ɩɪɟɞɫɬɚɜɥɹɟɬ ɫɨɛɨɣ ɩɨɥɟ ɜɜɨɞɚ-ɪɟɞɚɤɬɢɪɨɜɚɧɢɹ ɫɬɪɨɤɢ ɫɢɦɜɨɥɨɜ. ɋɜɨɣɫɬɜɚ ɤɨɦɩɨɧɟɧɬɚ ɩɪɢɜɟɞɟɧɵ ɜ ɬɚɛɥ. 2.1.
75
Ɍɚɛɥɢɰɚ 2.1 ɋɜɨɣɫɬɜɚ ɤɨɦɩɨɧɟɧɬɚ Edit (ɩɨɥɟ ɪɟɞɚɤɬɢɪɨɜɚɧɢɹ) ɋɜɨɣɫɬɜɨ Ɉɩɢɫɚɧɢɟ Name ɂɦɹ ɤɨɦɩɨɧɟɧɬɚ. ɂɫɩɨɥɶɡɭɟɬɫɹ ɜ ɩɪɨɝɪɚɦɦɟ ɞɥɹ ɞɨɫɬɭɩɚ ɤ ɤɨɦɩɨɧɟɧɬɭ ɢ ɟɝɨ ɫɜɨɣɫɬɜɚɦ, ɜ ɱɚɫɬɧɨɫɬɢ, ɞɥɹ ɞɨɫɬɭɩɚ ɤ ɬɟɤɫɬɭ, ɜɜɟɞɟɧɧɨɦɭ ɜ ɩɨɥɟ ɪɟɞɚɤɬɢɪɨɜɚɧɢɹ Text Ɍɟɤɫɬ, ɧɚɯɨɞɹɳɢɣɫɹ ɜ ɩɨɥɟ ɜɜɨɞɚ ɢ ɪɟɞɚɤɬɢɪɨɜɚɧɢɹ Left Ɋɚɫɫɬɨɹɧɢɟ ɨɬ ɥɟɜɨɣ ɝɪɚɧɢɰɵ ɤɨɦɩɨɧɟɧɬɚ ɞɨ ɥɟɜɨɣ ɝɪɚɧɢɰɵ ɮɨɪɦɵ Top Ɋɚɫɫɬɨɹɧɢɟ ɨɬ ɜɟɪɯɧɟɣ ɝɪɚɧɢɰɵ ɤɨɦɩɨɧɟɧɬɚ ɞɨ ɜɟɪɯɧɟɣ ɝɪɚɧɢɰɵ ɮɨɪɦɵ Height ȼɵɫɨɬɚ ɩɨɥɹ Width ɒɢɪɢɧɚ ɩɨɥɹ Font ɒɪɢɮɬ, ɢɫɩɨɥɶɡɭɟɦɵɣ ɞɥɹ ɨɬɨɛɪɚɠɟɧɢɹ ɜɜɨɞɢɦɨɝɨ ɬɟɤɫɬɚ ParentFont ɉɪɢɡɧɚɤ ɧɚɫɥɟɞɨɜɚɧɢɹ ɤɨɦɩɨɧɟɧɬɨɦ ɯɚɪɚɤɬɟɪɢɫɬɢɤ ɲɪɢɮɬɚ ɮɨɪɦɵ, ɧɚ ɤɨɬɨɪɨɣ ɧɚɯɨɞɢɬɫɹ ɤɨɦɩɨɧɟɧɬ. ȿɫɥɢ ɡɧɚɱɟɧɢɟ ɫɜɨɣɫɬɜɚ ɪɚɜɧɨ True, ɬɨ ɩɪɢ ɢɡɦɟɧɟɧɢɢ ɫɜɨɣɫɬɜɚ Font ɮɨɪɦɵ ɚɜɬɨɦɚɬɢɱɟɫɤɢ ɦɟɧɹɟɬɫɹ ɡɧɚɱɟɧɢɟ ɫɜɨɣɫɬɜɚ Font ɤɨɦɩɨɧɟɧɬɚ Enabled ɂɫɩɨɥɶɡɭɟɬɫɹ ɞɥɹ ɨɝɪɚɧɢɱɟɧɢɹ ɜɨɡɦɨɠɧɨɫɬɢ ɢɡɦɟɧɢɬɶ ɬɟɤɫɬ ɜ ɩɨɥɟ ɪɟɞɚɤɬɢɪɨɜɚɧɢɹ. ȿɫɥɢ ɡɧɚɱɟɧɢɟ ɫɜɨɣɫɬɜɚ ɪɚɜɧɨ False, ɬɨ ɬɟɤɫɬ ɜ ɩɨɥɟ ɪɟɞɚɤɬɢɪɨɜɚɧɢɹ ɢɡɦɟɧɢɬɶ ɧɟɥɶɡɹ Visible ɉɨɡɜɨɥɹɟɬ ɫɤɪɵɬɶ ɤɨɦɩɨɧɟɧɬ (False) ɢɥɢ ɫɞɟɥɚɬɶ ɟɝɨ ȼɢɞɢɦɵɦ (True) Ʉɨɦɩɨɧɟɧɬ Button ɫɬɪɚɧɢɰɵ Standart Ʉɨɦɩɨɧɟɧɬ Button ɩɪɟɞɫɬɚɜɥɹɟɬ ɫɨɛɨɣ ɤɨɦɚɧɞɧɭɸ ɤɧɨɩɤɭ. ɋɜɨɣɫɬɜɚ ɤɨɦɩɨɧɟɧɬɚ ɩɪɢɜɟɞɟɧɵ ɜ ɬɚɛɥ. 2.2. Ɍɚɛɥɢɰɚ 2.2 ɋɜɨɣɫɬɜɚ ɤɨɦɩɨɧɟɧɬɚ Button (ɤɨɦɚɧɞɧɚɹ ɤɧɨɩɤɚ) ɋɜɨɣɫɬɜɨ Ɉɩɢɫɚɧɢɟ Name ɂɦɹ ɤɨɦɩɨɧɟɧɬɚ. ɂɫɩɨɥɶɡɭɟɬɫɹ ɜ ɩɪɨɝɪɚɦɦɟ ɞɥɹ ɞɨɫɬɭɩɚ ɤ ɤɨɦɩɨɧɟɧɬɭ ɢ ɟɝɨ ɫɜɨɣɫɬɜɚɦ Caption Ɍɟɤɫɬ ɧɚ ɤɧɨɩɤɟ Left Ɋɚɫɫɬɨɹɧɢɟ ɨɬ ɥɟɜɨɣ ɝɪɚɧɢɰɵ ɤɧɨɩɤɢ ɞɨ ɥɟɜɨɣ ɝɪɚɧɢɰɵ ɮɨɪɦɵ Top Ɋɚɫɫɬɨɹɧɢɟ ɨɬ ɜɟɪɯɧɟɣ ɝɪɚɧɢɰɵ ɤɧɨɩɤɢ ɞɨ ɜɟɪɯɧɟɣ ɝɪɚɧɢɰɵ ɮɨɪɦɵ Height ȼɵɫɨɬɚ ɤɧɨɩɤɢ Width ɒɢɪɢɧɚ ɤɧɨɩɤɢ Enabled ɉɪɢɡɧɚɤ ɞɨɫɬɭɩɧɨɫɬɢ ɤɧɨɩɤɢ. ȿɫɥɢ ɡɧɚɱɟɧɢɟ ɫɜɨɣɫɬɜɚ ɪɚɜɧɨ True, ɬɨ ɤɧɨɩɤɚ ɞɨɫɬɭɩɧɚ. ȿɫɥɢ ɡɧɚɱɟɧɢɟ ɫɜɨɣɫɬɜɚ ɪɚɜɧɨ False, ɬɨ ɤɧɨɩɤɚ ɧɟ ɞɨɫɬɭɩɧɚ, ɧɚɩɪɢɦɟɪ, ɜ ɪɟɡɭɥɶɬɚɬɟ ɳɟɥɱɤɚ ɧɚ ɤɧɨɩɤɟ ɫɨɛɵɬɢɟ Click ɧɟ ɜɨɡɧɢɤɚɟɬ 76
ɉɨɡɜɨɥɹɟɬ ɫɤɪɵɬɶ ɤɧɨɩɤɭ (False) ɢɥɢ ɫɞɟɥɚɬɶ ɟɟ ɜɢɞɢɦɨɣ (True) Hint ɉɨɞɫɤɚɡɤɚ – ɬɟɤɫɬ, ɤɨɬɨɪɵɣ ɩɨɹɜɥɹɟɬɫɹ ɪɹɞɨɦ ɫ ɭɤɚɡɚɬɟɥɟɦ ɦɵɲɢ ɩɪɢ ɩɨɡɢɰɢɨɧɢɪɨɜɚɧɢɢ ɭɤɚɡɚɬɟɥɹ ɧɚ ɤɨɦɚɧɞɧɨɣ ɤɧɨɩɤɟ (ɞɥɹ ɬɨɝɨ ɱɬɨɛɵ ɬɟɤɫɬ ɩɨɹɜɢɥɫɹ, ɧɚɞɨ ɱɬɨɛɵ ɡɧɚɱɟɧɢɟ ɫɜɨɣɫɬɜɚ ShowHint ɛɵɥɨ True) ShowHint Ɋɚɡɪɟɲɚɟɬ (True) ɢɥɢ ɡɚɩɪɟɳɚɟɬ (False) ɨɬɨɛɪɚɠɟɧɢɟ ɩɨɞɫɤɚɡɤɢ ɩɪɢ ɩɨɡɢɰɢɨɧɢɪɨɜɚɧɢɢ ɭɤɚɡɚɬɟɥɹ ɧɚ ɤɧɨɩɤɟ Visible
Ʉɨɦɩɨɧɟɧɬ Memo ɫɬɪɚɧɢɰɵ Standart Ʉɨɦɩɨɧɟɧɬ Memo ɩɪɟɞɫɬɚɜɥɹɟɬ ɫɨɛɨɣ ɷɥɟɦɟɧɬ ɪɟɞɚɤɬɢɪɨɜɚɧɢɹ ɬɟɤɫɬɚ, ɤɨɬɨɪɵɣ ɦɨɠɟɬ ɫɨɫɬɨɹɬɶ ɢɡ ɧɟɫɤɨɥɶɤɢɯ ɫɬɪɨɤ. ɋɜɨɣɫɬɜɚ ɤɨɦɩɨɧɟɧɬɚ ɩɪɢɜɟɞɟɧɵ ɜ ɬɚɛɥ. 2.3. Ɍɚɛɥɢɰɚ 2.3 ɋɜɨɣɫɬɜɚ ɤɨɦɩɨɧɟɧɬɚ Memo ɋɜɨɣɫɬɜɨ Ɉɩɢɫɚɧɢɟ Name ɂɦɹ ɤɨɦɩɨɧɟɧɬɚ. ɂɫɩɨɥɶɡɭɟɬɫɹ ɜ ɞɥɹ ɞɨɫɬɭɩɚ ɤ ɫɜɨɣɫɬɜɚɦ ɤɨɦɩɨɧɟɧɬɚ Text Ɍɟɤɫɬ, ɧɚɯɨɞɹɳɢɣɫɹ ɜ ɩɨɥɟ Memo, ɪɚɫɫɦɚɬɪɢɜɚɟɬɫɹ ɤɚɤ ɟɞɢɧɨɟ ɰɟɥɨɟ Lines Ɇɚɫɫɢɜ ɫɬɪɨɤ, ɫɨɨɬɜɟɬɫɬɜɭɸɳɢɣ ɫɨɞɟɪɠɢɦɨɦɭ ɩɨɥɹ. Ⱦɨɫɬɭɩ ɤ ɫɬɪɨɤɟ ɨɫɭɳɟɫɬɜɥɹɟɬɫɹ ɩɨ ɧɨɦɟɪɭ. ɋɬɪɨɤɢ ɧɭɦɟɪɭɸɬɫɹ ɫ ɧɭɥɹ Lines.Count Ʉɨɥɢɱɟɫɬɜɨ ɫɬɪɨɤ ɬɟɤɫɬɚ ɜ ɩɨɥɟ Memo Left Ɋɚɫɫɬɨɹɧɢɟ ɨɬ ɥɟɜɨɣ ɝɪɚɧɢɰɵ ɩɨɥɹ ɞɨ ɥɟɜɨɣ ɝɪɚɧɢɰɵ ɮɨɪɦɵ Top Ɋɚɫɫɬɨɹɧɢɟ ɨɬ ɜɟɪɯɧɟɣ ɝɪɚɧɢɰɵ ɩɨɥɹ ɞɨ ɜɟɪɯɧɟɣ ɝɪɚɧɢɰɵ ɮɨɪɦɵ Height ȼɵɫɨɬɚ ɩɨɥɹ Width ɒɢɪɢɧɚ ɩɨɥɹ Font ɒɪɢɮɬ, ɢɫɩɨɥɶɡɭɟɦɵɣ ɞɥɹ ɨɬɨɛɪɚɠɟɧɢɹ ɜɜɨɞɢɦɨɝɨ ɬɟɤɫɬɚ ParentFont ɉɪɢɡɧɚɤ ɧɚɫɥɟɞɨɜɚɧɢɹ ɫɜɨɣɫɬɜ ɲɪɢɮɬɚ ɪɨɞɢɬɟɥɶɫɤɨɣ ɮɨɪɦɵ
77
ɉɪɢɥɨɠɟɧɢɟ 3. Ɉɫɧɨɜɧɵɟ ɦɚɬɟɦɚɬɢɱɟɫɤɢɟ ɮɭɧɤɰɢɢ Ɍɚɛɥɢɰɚ 3.1 Ɉɫɧɨɜɧɵɟ ɦɚɬɟɦɚɬɢɱɟɫɤɢɟ ɮɭɧɤɰɢɢ Ɏɭɧɤɰɢɹ Ɂɧɚɱɟɧɢɟ Abs(n) Ⱥɛɫɨɥɸɬɧɨɟ ɡɧɚɱɟɧɢɟ n Sqrt(n) Ʉɜɚɞɪɚɬɧɵɣ ɤɨɪɟɧɶ ɢɡ n Sqr(n) Ʉɜɚɞɪɚɬ n Exp(n) ɗɤɫɩɨɧɟɧɬɚ n Ln(n) ɇɚɬɭɪɚɥɶɧɵɣ ɥɨɝɚɪɢɮɦ n Rardom(n) ɋɥɭɱɚɣɧɨɟ ɰɟɥɨɟ ɱɢɫɥɨ ɜ ɞɢɚɩɚɡɨɧɟ ɨɬ 0 ɞɨ n–1 (ɩɟɪɟɞ ɩɟɪɜɵɦ ɨɛɪɚɳɟɧɢɟɦ ɤ ɮɭɧɤɰɢɢ ɧɟɨɛɯɨɞɢɦɨ ɜɵɡɜɚɬɶ ɮɭɧɤɰɢɸ Randomize, ɤɨɬɨɪɚɹ ɜɵɩɨɥɧɢɬ ɢɧɢɰɢɚɥɢɡɚɰɢɸ ɩɪɨɝɪɚɦɦɧɨɝɨ ɝɟɧɟɪɚɬɨɪɚ ɫɥɭɱɚɣɧɵɯ ɱɢɫɟɥ) Sin(a) ɋɢɧɭɫ ɜɵɪɚɠɟɧɧɨɝɨ ɜ ɪɚɞɢɚɧɚɯ ɭɝɥɚ ɚ Cos(a) Ʉɨɫɢɧɭɫ ɜɵɪɚɠɟɧɧɨɝɨ ɜ ɪɚɞɢɚɧɚɯ ɭɝɥɚ a Arctan(a) Ⱥɪɤɬɚɧɝɟɧɫ ɜɵɪɚɠɟɧɧɨɝɨ ɜ ɪɚɞɢɚɧɚɯ ɭɝɥɚ ɚ ArcCos(X) Ⱥɪɤɤɨɫɢɧɭɫ ɜɵɪɚɠɟɧɧɨɝɨ ɜ ɪɚɞɢɚɧɚɯ ɭɝɥɚ ɏ ArcSin(X) Ⱥɪɤɫɢɧɭɫ ɜɵɪɚɠɟɧɧɨɝɨ ɜ ɪɚɞɢɚɧɚɯ ɭɝɥɚ ɏ Cotan(X) Ʉɨɬɚɧɝɟɧɫ ɜɵɪɚɠɟɧɧɨɝɨ ɜ ɪɚɞɢɚɧɚɯ ɭɝɥɚ ɏ Tan(X) Ɍɚɧɝɟɧɫ ɜɵɪɚɠɟɧɧɨɝɨ ɜ ɪɚɞɢɚɧɚɯ ɭɝɥɚ ɏ LogN(Base, X) Ʌɨɝɚɪɢɮɦ ɨɬ X ɩɪɢ ɨɫɧɨɜɚɧɢɢ Base Power(Base,X) ȼɨɡɜɟɞɟɧɢɟ ɱɢɫɥɚ Base ɜ ɫɬɟɩɟɧɶ X ɉɨɫɥɟɞɧɢɟ ɩɹɬɶ ɮɭɧɤɰɢɣ ɫɬɚɧɨɜɹɬɫɹ ɞɨɫɬɭɩɧɵɦɢ ɩɪɨɝɪɚɦɦɟ ɬɨɥɶɤɨ ɩɨɫɥɟ ɫɫɵɥɤɢ ɧɚ ɦɨɞɭɥɶ Math ɩɨɫɥɟ SysUtils ɜ ɩɪɟɞɥɨɠɟɧɢɢ uses. ȼɫɟ ɮɭɧɤɰɢɢ ɢ ɜɯɨɞɹɳɢɟ ɜ ɧɢɯ ɩɟɪɟɦɟɧɧɵɟ ɢɦɟɸɬ ɬɢɩ Extended. ȼɟɥɢɱɢɧɚ ɭɝɥɚ ɬɪɢɝɨɧɨɦɟɬɪɢɱɟɫɤɢɯ ɮɭɧɤɰɢɣ ɞɨɥɠɧɚ ɛɵɬɶ ɜɵɪɚɠɟɧɚ ɜ ɪɚɞɢɚɧɚɯ. Ⱦɥɹ ɩɪɟɨɛɪɚɡɨɜɚɧɢɹ ɜɟɥɢɱɢɧɵ ɭɝɥɚ ɢɡ ɝɪɚɞɭɫɨɜ ɜ ɪɚɞɢɚɧɵ ɢɫɩɨɥɶɡɭɟɬɫɹ ɮɨɪɦɭɥɚ (ɚ × 3,1415256) /180, ɝɞɟ ɚ – ɜɟɥɢɱɢɧɚ ɭɝɥɚ ɜ ɝɪɚɞɭɫɚɯ; 3,1415926 – ɱɢɫɥɨ «ɉɂ». ȼɦɟɫɬɨ ɤɨɧɫɬɚɧɬɵ 3,1415926 ɦɨɠɧɨ ɢɫɩɨɥɶɡɨɜɚɬɶ ɫɬɚɧɞɚɪɬɧɭɸ ɢɦɟɧɨɜɚɧɧɭɸ ɤɨɧɫɬɚɧɬɭ pi.
ɉɪɢɥɨɠɟɧɢɟ 4. Ƚɪɚɮɢɱɟɫɤɢɣ ɢɧɫɬɪɭɦɟɧɬɚɪɢɣ Ʉɥɚɫɫ TFont ɋ ɩɨɦɨɳɶɸ ɤɥɚɫɫɚ TFont ɫɨɡɞɚɟɬɫɹ ɨɛɴɟɤɬ-ɲɪɢɮɬ ɞɥɹ ɥɸɛɨɝɨ ɝɪɚɮɢɱɟɫɤɨɝɨ ɭɫɬɪɨɣɫɬɜɚ (ɷɤɪɚɧɚ, ɩɪɢɧɬɟɪɚ, ɩɥɨɬɬɟɪɚ ɢ ɬ. ɩ.). Ɉɫɧɨɜɧɵɟ ɫɜɨɣɫɬɜɚ ɤɥɚɫɫɚ ɩɪɟɞɫɬɚɜɥɟɧɵ ɜ ɬɚɛɥ. 7.1. 78
Ɍɚɛɥɢɰɚ 4.1 ɋɜɨɣɫɬɜɚ ɤɥɚɫɫɚ TFont ɋɜɨɣɫɬɜɨ Ɉɩɢɫɚɧɢɟ property Color: TColor; ɐɜɟɬ ɲɪɢɮɬɚ property FontAdapter: ɉɨɫɬɚɜɥɹɟɬ ɢɧɮɨɪɦɚɰɢɸ ɨ ɲɪɢɮɬɟ ɜ ɤɨɦɩɨɧɟɧIChangeNotifier; ɬɟ ActveX property Height: ȼɵɫɨɬɚ ɲɪɢɮɬɚ ɜ ɩɢɤɫɟɥɹɯ ɷɤɪɚɧɚ Integer; property Name: ɂɦɹ ɲɪɢɮɬɚ. ɉɨ ɭɦɨɥɱɚɧɢɸ ɢɦɟɟɬ ɡɧɚɱɟɧɢɟ MS Sans Serif TFontName; property Size: Integer; ȼɵɫɨɬɚ ɲɪɢɮɬɚ ɜ ɩɭɧɤɬɚɯ (1/72 ɞɸɣɦɚ). ɂɡɦɟɧɟɧɢɟ ɷɬɨɝɨ ɫɜɨɣɫɬɜɚ ɚɜɬɨɦɚɬɢɱɟɫɤɢ ɢɡɦɟɧɹɟɬ ɫɜɨɣɫɬɜɨ Height ɢ ɧɚɨɛɨɪɨɬ. property Style: ɋɬɢɥɶ ɲɪɢɮɬɚ. Ɇɨɠɟɬ ɩɪɢɧɢɦɚɬɶ ɡɧɚɱɟɧɢɟ ɤɚɤ TFontStyles; ɤɨɦɛɢɧɚɰɢɹ ɫɥɟɞɭɸɳɢɯ ɩɪɢɡɧɚɤɨɜ: fsBold (ɠɢɪɧɵɣ), fsltalic (ɤɭɪɫɢɜ), fsUnderline (ɩɨɞɱɟɪɤɧɭɬɵɣ), fsStrikeOut (ɩɟɪɟɱɟɪɤɧɭɬɵɣ) Ʉɥɚɫɫ ɌɊɟn ɋ ɩɨɦɨɳɶɸ ɤɥɚɫɫɚ TPɟn ɫɨɡɞɚɟɬɫɹ ɨɛɴɟɤɬ-ɩɟɪɨ, ɫɥɭɠɚɳɢɣ ɞɥɹ ɜɵɱɟɪɱɢɜɚɧɢɹ ɥɢɧɢɣ. Ɉɫɧɨɜɧɵɟ ɫɜɨɣɫɬɜɚ ɤɥɚɫɫɚ ɩɪɟɞɫɬɚɜɥɟɧɵ ɜ ɬɚɛɥ. 7.2.
ɋɜɨɣɫɬɜɨ property Color: TColor; property Mode: TPenMode; property Style: TPenStyle;
property Width: Integer;
Ɍɚɛɥɢɰɚ 4.2 ɋɜɨɣɫɬɜɚ ɤɥɚɫɫɚ ɌɊɟn Ɉɩɢɫɚɧɢɟ ɐɜɟɬ ɜɵɱɟɪɱɢɜɚɟɦɵɯ ɩɟɪɨɦ ɥɢɧɢɣ Ɉɩɪɟɞɟɥɹɟɬ ɫɩɨɫɨɛ ɜɡɚɢɦɨɞɟɣɫɬɜɢɹ ɥɢɧɢɣ ɫ ɮɨɧɨɦ (ɫɦ.ɧɢɠɟ) Ɉɩɪɟɞɟɥɹɟɬ ɫɬɢɥɶ ɥɢɧɢɣ (ɫɦ. ɪɢɫ. 7.1). ɍɱɢɬɵɜɚɟɬɫɹ ɬɨɥɶɤɨ ɞɥɹ ɬɨɥɳɢɧɵ ɥɢɧɢɣ 1 ɩɢɤɫɟɥɶ. Ⱦɥɹ ɬɨɥɫɬɵɯ ɥɢɧɢɣ ɫɬɢɥɶ ɜɫɟɝɞɚ ps Solid (ɫɩɥɨɲɧɚɹ) Ɍɨɥɳɢɧɚ ɥɢɧɢɣ ɜ ɩɢɤɫɟɥɹɯ ɷɤɪɚɧɚ
ɋɜɨɣɫɬɜɨ Mode ɦɨɠɟɬ ɩɪɢɧɢɦɚɬɶ ɨɞɧɨ ɢɡ ɫɥɟɞɭɸɳɢɯ ɡɧɚɱɟɧɢɣ: pmBlack pmWhite pmNop pmNot
ɥɢɧɢɢ ɜɫɟɝɞɚ ɱɟɪɧɵɟ. ɋɜɨɣɫɬɜɚ Color ɢ Style ɢɝɧɨɪɢɪɭɸɬɫɹ ɥɢɧɢɢ ɜɫɟɝɞɚ ɛɟɥɵɟ. ɋɜɨɣɫɬɜɚ Color ɢ Style ɢɝɧɨɪɢɪɭɸɬɫɹ ɰɜɟɬ ɮɨɧɚ ɧɟ ɦɟɧɹɟɬɫɹ (ɥɢɧɢɢ ɧɟ ɜɢɞɧɵ) ɢɧɜɟɪɫɢɹ ɰɜɟɬɚ ɮɨɧɚ. ɋɜɨɣɫɬɜɚ Color ɢ Style ɢɝɧɨɪɢɪɭɸɬɫɹ 79
ɰɜɟɬ ɥɢɧɢɣ ɨɩɪɟɞɟɥɹɟɬɫɹ ɫɜɨɣɫɬɜɨɦ Color ɩɟɪɚ ɢɧɜɟɪɫɢɹ ɰɜɟɬɚ ɩɟɪɚ. ɋɜɨɣɫɬɜɨ Style ɢɝɧɨɪɢɪɭɟɬɫɹ ɤɨɦɛɢɧɚɰɢɹ ɰɜɟɬɚ ɩɟɪɚ ɢ ɢɧɜɟɪɫɢɨɧɧɨɝɨ ɰɜɟɬɚ ɮɨɧɚ ɤɨɦɛɢɧɚɰɢɹ ɨɛɳɢɯ ɰɜɟɬɨɜ ɞɥɹ ɩɟɪɚ ɢ ɢɧɜɟɪɫɢɨɧɧɨɝɨ ɰɜɟɬɚ ɮɨɧɚ. ɋɜɨɣɫɬɜɨ Style ɢɝɧɨɪɢɪɭɟɬɫɹ pmMergeNotPen ɤɨɦɛɢɧɚɰɢɹ ɢɧɜɟɪɫɢɨɧɧɨɝɨ ɰɜɟɬɚ ɩɟɪɚ ɢ ɮɨɧɚ pmMaskNotPen ɤɨɦɛɢɧɚɰɢɹ ɨɛɳɢɯ ɰɜɟɬɨɜ ɞɥɹ ɢɧɜɟɪɫɢɨɧɧɨɝɨ ɰɜɟɬɚ ɩɟɪɚ ɢ ɮɨɧɚ. ɋɜɨɣɫɬɜɨ Style ɢɝɧɨɪɢɪɭɟɬɫɹ pmMerge ɤɨɦɛɢɧɚɰɢɹ ɰɜɟɬɨɜ ɩɟɪɚ ɢ ɮɨɧɚ pmNotMerge ɢɧɜɟɪɫɢɹ ɰɜɟɬɨɜ ɩɟɪɚ ɢ ɮɨɧɚ. ɋɜɨɣɫɬɜɨ Style ɢɝɧɨɪɢɪɭɟɬɫɹ pmMask ɨɛɳɢɟ ɰɜɟɬɚ ɩɟɪɚ ɢ ɮɨɧɚ pmNotMask ɢɧɜɟɪɫɢɹ ɨɛɳɢɯ ɰɜɟɬɨɜ ɩɟɪɚ ɢ ɮɨɧɚ pmXor ɨɛɴɟɞɢɧɟɧɢɟ ɰɜɟɬɨɜ ɩɟɪɚ ɢ ɮɨɧɚ ɨɩɟɪɚɰɢɟɣ XOR pinNotXor ɢɧɜɟɪɫɢɹ ɨɛɴɟɞɢɧɟɧɢɹ ɰɜɟɬɨɜ ɩɟɪɚ ɢ ɮɨɧɚ ɨɩɟɪɚɰɢɟɣ XOR pmCopy pmNotCopy pmMergePenNot pmMaskPenNot
ɋɬɢɥɢ ɥɢɧɢɣ ɩɨɤɚɡɚɧɵ ɧɚ ɪɢɫ. 4.1.
Ɋɢɫ. 4.1. ɋɬɢɥɢ ɥɢɧɢɣ Ʉɥɚɫɫ TBrush Ɉɛɴɟɤɬɵ ɤɥɚɫɫɚ TBrush (ɤɢɫɬɢ) ɫɥɭɠɚɬ ɞɥɹ ɡɚɩɨɥɧɟɧɢɹ ɜɧɭɬɪɟɧɧɟɝɨ ɩɪɨɫɬɪɚɧɫɬɜɚ ɡɚɦɤɧɭɬɵɯ ɮɢɝɭɪ. Ɉɫɧɨɜɧɵɟ ɫɜɨɣɫɬɜɚ ɤɥɚɫɫɚ ɩɪɟɞɫɬɚɜɥɟɧɵ ɜ ɬɚɛɥ. 7.3. Ɍɚɛɥɢɰɚ 4.3 ɋɜɨɣɫɬɜɚ ɤɥɚɫɫɚ TBrush ɋɜɨɣɫɬɜɨ Ɉɩɢɫɚɧɢɟ property Bitmap: TBitmap; ɋɨɞɟɪɠɢɬ ɪɚɫɬɪɨɜɨɟ ɢɡɨɛɪɚɠɟɧɢɟ, ɤɨɬɨɪɨɟ ɛɭɞɟɬ ɢɫɩɨɥɶɡɨɜɚɬɶɫɹ ɤɢɫɬɶɸ ɞɥɹ ɡɚɩɨɥɧɟɧɢɹ. ȿɫɥɢ ɷɬɨ ɫɜɨɣɫɬɜɨ ɨɩɪɟɞɟɥɟɧɨ, ɫɜɨɣɫɬɜɚ Color ɢ Style ɢɝɧɨɪɢɪɭɸɬɫɹ property Color: TColor; ɐɜɟɬ ɤɢɫɬɢ property Style: TBrushStyle; ɋɬɢɥɶ ɤɢɫɬɢ 80
Ʉɥɚɫɫ TCanvas ɗɬɨɬ ɤɥɚɫɫ ɫɨɡɞɚɟɬ «ɤɚɧɜɭ», ɧɚ ɤɨɬɨɪɨɣ ɦɨɠɧɨ ɪɢɫɨɜɚɬɶ ɱɟɪɬɟɠɧɵɦɢ ɢɧɫɬɪɭɦɟɧɬɚɦɢ – ɩɟɪɨɦ, ɤɢɫɬɶɸ ɢ ɲɪɢɮɬɨɦ. Ɉɛɴɟɤɬɵ ɤɥɚɫɫɚ Tɋɚnvas ɚɜɬɨɦɚɬɢɱɟɫɤɢ ɫɨɡɞɚɸɬɫɹ ɞɥɹ ɜɫɟɯ ɜɢɞɢɦɵɯ ɤɨɦɩɨɧɟɧɬɨɜ, ɤɨɬɨɪɵɟ ɞɨɥɠɧɵ ɭɦɟɬɶ ɧɚɪɢɫɨɜɚɬɶ ɫɟɛɹ. Ɉɧɢ ɢɧɤɚɩɫɭɥɢɪɭɸɬ ɨɛɴɟɤɬɵ Font, Pen, Brush, ɚ ɬɚɤɠɟ ɦɧɨɝɨɱɢɫɥɟɧɧɵɟ ɦɟɬɨɞɵ, ɢɫɩɨɥɶɡɭɸɳɢɟ ɷɬɢ ɨɛɴɟɤɬɵ. Ɉɫɧɨɜɧɵɟ ɫɜɨɣɫɬɜɚ ɤɥɚɫɫɚ ɩɪɟɞɫɬɚɜɥɟɧɵ ɜ ɬɚɛɥ. 7.4. Ɍɚɛɥɢɰɚ 4.4 ɋɜɨɣɫɬɜɨ property Brush: TBrush; property ClipRect: TRect; property CopyMode: TCopyMode; property Font: TFont; property Pen: TPen; property PenPos:TPoint; property Piels [X,Y:Integer]: TColor;
ɋɜɨɣɫɬɜɚ ɤɥɚɫɫɚ TCanvas Ɉɩɢɫɚɧɢɟ Ɉɛɴɟɤɬ-ɤɢɫɬɶ. Ɉɩɪɟɞɟɥɹɟɬ ɬɟɤɭɳɢɟ ɪɚɡɦɟɪɵ ɨɛɥɚɫɬɢ, ɧɭɠɞɚɸɳɟɣɫɹ ɜ ɩɪɨɪɢɫɨɜɤɟ ɍɫɬɚɧɚɜɥɢɜɚɟɬ ɫɩɨɫɨɛ ɜɡɚɢɦɨɞɟɣɫɬɜɢɹ ɪɚɫɬɪɨɜɨɝɨ ɢɡɨɛɪɚɠɟɧɢɹ ɫ ɰɜɟɬɨɦ ɮɨɧɚ Ɉɛɴɟɤɬ-ɲɪɢɮɬ Ɉɛɴɟɤɬ-ɩɟɪɨ Ɉɩɪɟɞɟɥɹɟɬ ɬɟɤɭɳɟɟ ɩɨɥɨɠɟɧɢɟ ɩɟɪɚ ɜ ɩɢɤɫɟɥɹɯ ɨɬɧɨɫɢɬɟɥɶɧɨ ɥɟɜɨɝɨ ɜɟɪɯɧɟɝɨ ɭɝɥɚ ɤɚɧɜɵ Ɇɚɫɫɢɜ ɩɢɤɫɟɥɟɣ ɤɚɧɜɵ
ɋɜɨɣɫɬɜɨ ɋopyMode ɦɨɠɟɬ ɩɪɢɧɢɦɚɬɶ ɨɞɧɨ ɢɡ ɫɥɟɞɭɸɳɢɯ ɡɧɚɱɟɧɢɣ: (ɫɜɨɣɫɬɜɨ ɢɫɩɨɥɶɡɭɟɬɫɹ ɩɪɢ ɤɨɩɢɪɨɜɚɧɢɢ ɱɚɫɬɢ ɨɞɧɨɣ ɤɚɧɜɵ (ɢɫɬɨɱɧɢɤɚ) ɜ ɞɪɭɝɭɸ (ɩɪɢɟɦɧɢɤ) ɦɟɬɨɞɨɦ copyRect) ɋɜɨɣɫɬɜɨ cmBlackness cmDestInvert cmMergeCopy cmMergePaint cmNotSrcCopy cmNotSrcErase cmPatCopy cmPatInvert cmPatPaint
Ɉɩɢɫɚɧɢɟ Ɂɚɩɨɥɧɹɟɬ ɨɛɥɚɫɬɶ ɪɢɫɨɜɚɧɢɹ ɱɟɪɧɵɦ ɰɜɟɬɨɦ Ɂɚɩɨɥɧɹɟɬ ɨɛɥɚɫɬɶ ɪɢɫɨɜɚɧɢɹ ɢɧɜɟɪɫɧɵɦ ɰɜɟɬɨɦ ɮɨɧɚ Ɉɛɴɟɞɢɧɹɟɬ ɢɡɨɛɪɚɠɟɧɢɟ ɧɚ ɤɚɧɜɟ ɢ ɤɨɩɢɪɭɟɦɨɟ ɢɡɨɛɪɚɠɟɧɢɟ ɨɩɟɪɚɰɢɟɣ and Ɉɛɴɟɞɢɧɹɟɬ ɢɡɨɛɪɚɠɟɧɢɟ ɧɚ ɤɚɧɜɟ ɢ ɤɨɩɢɪɭɟɦɨɟ ɢɡɨɛɪɚɠɟɧɢɟ ɨɩɟɪɚɰɢɟɣ OR Ʉɨɩɢɪɭɟɬ ɧɚ ɤɚɧɜɭ ɢɧɜɟɪɫɧɨɟ ɢɡɨɛɪɚɠɟɧɢɟ ɢɫɬɨɱɧɢɤɚ Ɉɛɴɟɞɢɧɹɟɬ ɢɡɨɛɪɚɠɟɧɢɟ ɧɚ ɤɚɧɜɟ ɢ ɤɨɩɢɪɭɟɦɨɟ ɢɡɨɛɪɚɠɟɧɢɟ ɨɩɟɪɚɰɢɟɣ OR ɢ ɢɧɜɟɪɬɢɪɭɟɬ ɩɨɥɭɱɟɧɧɨɟ Ʉɨɩɢɪɭɟɬ ɨɛɪɚɡɟɰ ɢɫɬɨɱɧɢɤɚ Ʉɨɦɛɢɧɢɪɭɟɬ ɨɛɪɚɡɟɰ ɢɫɬɨɱɧɢɤɚ ɫ ɢɡɨɛɪɚɠɟɧɢɟɦ ɧɚ ɤɚɧɜɟ ɫ ɩɨɦɨɳɶɸ ɨɩɟɪɚɰɢɢ XOR Ʉɨɦɛɢɧɢɪɭɟɬ ɢɡɨɛɪɚɠɟɧɢɟ ɢɫɬɨɱɧɢɤɚ ɫ ɟɝɨ ɨɛɪɚɡɰɨɦ ɫ ɩɨɦɨɳɶɸ ɨɩɟɪɚɰɢɢ OR, ɡɚɬɟɦ ɩɨɥɭɱɟɧɧɨɟ ɨɛɴɟɞɢɧɹɟɬɫɹ ɫ ɢɡɨɛɪɚɠɟɧɢɟɦ ɧɚ ɤɚɧɜɟ ɬɚɤɠɟ ɫ ɩɨɦɨɳɶɸ OR 81
cmSrcAnd cmSrcCopy cmSrcErase cmSrcInvert cmSrcPaint cmWhitness
Ɉɛɴɟɞɢɧɹɟɬ ɢɡɨɛɪɚɠɟɧɢɟ ɢɫɬɨɱɧɢɤɚ ɢ ɤɚɧɜɵ ɫ ɩɨɦɨɳɶɸ ɨɩɟɪɚɰɢɢ and Ʉɨɩɢɪɭɟɬ ɢɡɨɛɪɚɠɟɧɢɟ ɢɫɬɨɱɧɢɤɚ ɧɚ ɤɚɧɜɭ ɂɧɜɟɪɬɢɪɭɟɬ ɢɡɨɛɪɚɠɟɧɢɟ ɧɚ ɤɚɧɜɟ ɢ ɨɛɴɟɞɢɧɹɟɬ ɪɟɡɭɥɶɬɚɬ ɫ ɢɡɨɛɪɚɠɟɧɢɟɦ ɢɫɬɨɱɧɢɤɚ ɨɩɟɪɚɰɢɟɣ and Ɉɛɴɟɞɢɧɹɟɬ ɢɡɨɛɪɚɠɟɧɢɟ ɧɚ ɤɚɧɜɟ ɢ ɢɫɬɨɱɧɢɤ ɨɩɟɪɚɰɢɟɣ XOR Ɉɛɴɟɞɢɧɹɟɬ ɢɡɨɛɪɚɠɟɧɢɟ ɧɚ ɤɚɧɜɟ ɢ ɢɫɬɨɱɧɢɤ ɨɩɟɪɚɰɢɟɣ OR Ɂɚɩɨɥɧɹɟɬ ɨɛɥɚɫɬɶ ɪɢɫɨɜɚɧɢɹ ɛɟɥɵɦ ɰɜɟɬɨɦ
ɋ ɩɨɦɨɳɶɸ ɫɜɨɣɫɬɜɚ pixels ɜɫɟ ɩɢɤɫɟɥɢ ɤɚɧɜɵ ɩɪɟɞɫɬɚɜɥɹɸɬɫɹ ɜ ɜɢɞɟ ɞɜɭɯɦɟɪɧɨɝɨ ɦɚɫɫɢɜɚ ɬɨɱɟɤ. ɂɡɦɟɧɹɹ ɰɜɟɬ ɩɢɤɫɟɥɟɣ, ɦɨɠɧɨ ɩɪɨɪɢɫɨɜɵɜɚɬɶ ɢɡɨɛɪɚɠɟɧɢɟ ɩɨ ɨɬɞɟɥɶɧɵɦ ɬɨɱɤɚɦ. Ɇɟɬɨɞɵ ɤɥɚɫɫɚ ɩɪɟɞɫɬɚɜɥɟɧɵ ɜ ɬɚɛɥ. 4.5. Ɍɚɛɥɢɰɚ 4.5 Ɇɟɬɨɞɵ ɤɥɚɫɫɚ TCanvas Ɇɟɬɨɞ Ɉɩɢɫɚɧɢɟ procedure Arc(X1, Y1, ɑɟɪɬɢɬ ɞɭɝɭ ɷɥɥɢɩɫɚ ɜ ɨɯɜɚɬɵɜɚɸɳɟɦ ɩɪɹɦɨX2, Y2, ɏ3, Y3, ɏ4, Y4: ɭɝɨɥɶɧɢɤɟ (Xl,Yl)–(X2,Y2). ɇɚɱɚɥɨ ɞɭɝɢ ɥɟɠɢɬ Integer); ɧɚ ɩɟɪɟɫɟɱɟɧɢɢ ɷɥɥɢɩɫɚ ɢ ɥɭɱɚ, ɩɪɨɜɟɞɟɧɧɨɝɨ ɢɡ ɟɝɨ ɰɟɧɬɪɚ ɜ ɬɨɱɤɭ (ɏ3, Y3), ɚ ɤɨɧɟɰ – ɧɚ ɩɟɪɟɫɟɱɟɧɢɢ ɫ ɥɭɱɨɦ ɢɡ ɰɟɧɬɪɚ ɜ ɬɨɱɤɭ (ɏ4, Y4). Ⱦɭɝɚ ɱɟɪɬɢɬɫɹ ɩɪɨɬɢɜ ɱɚɫɨɜɨɣ ɫɬɪɟɥɤɢ Ʉɨɩɢɪɭɟɬ ɱɚɫɬɶ ɢɡɨɛɪɚɠɟɧɢɹ Source ɧɚ ɭɱɚɫɬɨɤ procedure BrushCopy ɤɚɧɜɵ Dest. Color ɭɤɚɡɵɜɚɟɬ ɰɜɟɬ ɜ Dest, ɤɨɬɨ(const Dest: TRect; Bitmap: TBitmap; const ɪɵɣ ɞɨɥɠɟɧ ɡɚɦɟɧɹɬɶɫɹ ɧɚ ɰɜɟɬ ɤɢɫɬɢ ɤɚɧɜɵ. Ɇɟɬɨɞ ɜɜɟɞɟɧ ɞɥɹ ɫɨɜɦɟɫɬɢɦɨɫɬɢ ɫ ɪɚɧɧɢɦɢ Source: TRect; Color: ɜɟɪɫɢɹɦɢ Delphi. ȼɦɟɫɬɨ ɧɟɝɨ ɫɥɟɞɭɟɬ ɩɨɥɶɡɨTColor); ɜɚɬɶɫɹ ɤɥɚɫɫɨɦ Ɍ Image List procedure Chord(XI, Yl, ɑɟɪɬɢɬ ɫɟɝɦɟɧɬ ɷɥɥɢɩɫɚ ɜ ɨɯɜɚɬɵɜɚɸɳɟɦ ɩɪɹX2, Y2, X3, Y3) ɦɨɭɝɨɥɶɧɢɤɟ (XI, ɍ1)–(X2, Y2). ɇɚɱɚɥɨ ɞɭɝɢ ɫɟɝɦɟɧɬɚ ɥɟɠɢɬ ɧɚ ɩɟɪɟɫɟɱɟɧɢɢ ɷɥɥɢɩɫɚ ɢ ɥɭɱɚ, ɩɪɨɜɟɞɟɧɧɨɝɨ ɢɡ ɟɝɨ ɰɟɧɬɪɚ ɜ ɬɨɱɤɭ (X3, Y3), ɚ ɤɨɧɟɰ – ɧɚ ɩɟɪɟɫɟɱɟɧɢɢ ɫ ɥɭɱɨɦ ɢɡ ɰɟɧɬɪɚ ɜ ɬɨɱɤɭ (X4, Y4). Ⱦɭɝɚ ɫɟɝɦɟɧɬɚ ɱɟɪɬɢɬɫɹ ɩɪɨɬɢɜ ɱɚɫɨɜɨɣ ɫɬɪɟɥɤɢ, ɚ ɧɚɱɚɥɶɧɚɹ ɢ ɤɨɧɟɱɧɚɹ ɬɨɱɤɢ ɞɭɝɢ ɫɨɟɞɢɧɹɸɬɫɹ ɩɪɹɦɨɣ procedure CopyRect Ʉɨɩɢɪɭɟɬ ɢɡɨɛɪɚɠɟɧɢɟ Source ɤɚɧɜɵ Canvas ɜ (Dest: TRect; Canvas: ɭɱɚɫɬɨɤ Dest ɬɟɤɭɳɟɣ ɤɚɧɜɵ. ɉɪɢ ɷɬɨɦ ɪɚɡɧɨTCanvas;Source: TRect); ɨɛɪɚɡɧɵɟ ɫɩɟɰɢɚɥɶɧɵɟ ɷɮɮɟɤɬɵ ɞɨɫɬɢɝɚɸɬɫɹ ɫ ɩɨɦɨɳɶɸ ɫɜɨɣɫɬɜɚ CopyMode 82
Ɉɫɭɳɟɫɬɜɥɹɟɬ ɩɪɨɪɢɫɨɜɤɭ ɝɪɚɮɢɱɟɫɤɨɝɨ ɨɛɴɟɤɬɚ Graphic ɬɚɤ, ɱɬɨɛɵ ɥɟɜɵɣ ɜɟɪɯɧɢɣ ɭɝɨɥ ɨɛɴɟɤɬɚ ɪɚɫɩɨɥɨɠɢɥɫɹ ɜ ɬɨɱɤɟ (X, Y) ɉɪɨɪɢɫɨɜɵɜɚɟɬ ɩɪɹɦɨɭɝɨɥɶɧɢɤ ɫ ɩɨɦɨɳɶɸ ɨɩɟɪɚɰɢɢ XOR, ɩɨɷɬɨɦɭ ɩɨɜɬɨɪɧɚɹ ɩɪɨɪɢɫɨɜɤɚ ɭɧɢɱɬɨɠɚɟɬ ɪɚɧɟɟ ɜɵɱɟɪɱɟɧɧɵɣ ɩɪɹɦɨɭɝɨɥɶɧɢɤ. ɂɫɩɨɥɶɡɭɟɬɫɹ ɜ ɨɫɧɨɜɧɨɦ ɞɥɹ ɩɪɨɪɢɫɨɜɤɢ ɧɟɫɬɚɧɞɚɪɬɧɵɯ ɢɧɬɟɪɮɟɣɫɧɵɯ ɷɥɟɦɟɧɬɨɜ ɩɪɢ ɩɨɥɭɱɟɧɢɢ ɢɦɢ ɮɨɤɭɫɚ ɜɜɨɞɚ ɢ ɩɪɢ ɩɨɬɟɪɟ ɟɝɨ procedure Ellipse(XI, Yl, ɑɟɪɬɢɬ ɷɥɥɢɩɫ ɜ ɨɯɜɚɬɵɜɚɸɳɟɦ ɩɪɹɦɨɭɝɨɥɶɧɢX2, Y2: Integers; ɤɟ (XI, Yl)–(X2, Y2). Ɂɚɩɨɥɧɹɟɬ ɜɧɭɬɪɟɧɧɟɟ ɩɪɨɫɬɪɚɧɫɬɜɨ ɷɥɥɢɩɫɚ ɬɟɤɭɳɟɣ ɤɢɫɬɶɸ procedure FillRect(const Ɂɚɩɨɥɧɹɟɬ ɬɟɤɭɳɟɣ ɤɢɫɬɶɸ ɩɪɹɦɨɭɝɨɥɶɧɭɸ ɨɛRect: TRect); ɥɚɫɬɶ Rect, ɜɤɥɸɱɚɹ ɟɟ ɥɟɜɭɸ ɢ ɜɟɪɯɧɸɸ ɝɪɚɧɢɰɵ, ɧɨ ɧɟ ɡɚɬɪɚɝɢɜɚɹ ɩɪɚɜɭɸ ɢ ɧɢɠɧɸɸ ɝɪɚɧɢɰɵ procedure FloodFill(X, ɉɪɨɢɡɜɨɞɢɬ ɡɚɥɢɜɤɭ ɤɚɧɜɵ ɬɟɤɭɳɟɣ ɤɢɫɬɶɸ. Y: Integer; Color: Ɂɚɥɢɜɤɚ ɧɚɱɢɧɚɟɬɫɹ ɫ ɬɨɱɤɢ (X, Y) ɢ ɪɚɫɩɪɨTColor; Fill Style: ɫɬɪɚɧɹɟɬɫɹ ɜɨɜɫɟ ɫɬɨɪɨɧɵ ɨɬ ɧɟɟ. ȿɫɥɢ TFillStyle); FillStyle=fsSurface, ɡɚɥɢɜɤɚ ɪɚɫɩɪɨɫɬɪɚɧɹɟɬɫɹ ɧɚ ɜɫɟ ɫɨɫɟɞɧɢɟ ɬɨɱɤɢ ɫ ɰɜɟɬɨɦ Color. ȿɫɥɢ FillStyle=fsBorder, ɧɚɨɛɨɪɨɬ, ɡɚɥɢɜɤɚ ɩɪɟɤɪɚɳɚɟɬɫɹ ɧɚ ɬɨɱɤɚɯ ɫ ɷɬɢɦ ɰɜɟɬɨɦ procedure FrameRect Ɉɱɟɪɱɢɜɚɟɬ ɝɪɚɧɢɰɵ ɩɪɹɦɨɭɝɨɥɶɧɢɤɚ Rect ɬɟ(const Rect: TRect); ɤɭɳɟɣ ɤɢɫɬɶɸ ɬɨɥɳɢɧɨɣ ɜ 1 ɩɢɤɫɟɥɶ ɛɟɡ ɡɚɩɨɥɧɟɧɢɹ ɜɧɭɬɪɟɧɧɟɣ ɱɚɫɬɢ ɩɪɹɦɨɭɝɨɥɶɧɢɤɚ procedure LineTo(X, ɑɟɪɬɢɬ ɥɢɧɢɸ ɨɬ ɬɟɤɭɳɟɝɨ ɩɨɥɨɠɟɧɢɹ ɩɟɪɚ ɞɨ ɬɨɱɤɢ (X,Y) Y: Integer); procedure Lock; Ȼɥɨɤɢɪɭɟɬ ɤɚɧɜɭ ɜ ɦɧɨɝɨɩɨɬɨɱɧɵɯ ɩɪɢɥɨɠɟɧɢɹɯ ɞɥɹ ɩɪɟɞɨɬɜɪɚɳɟɧɢɹ ɢɫɩɨɥɶɡɨɜɚɧɢɹ ɤɚɧɜɵ ɜ ɞɪɭɝɢɯ ɩɨɬɨɤɚɯ ɤɨɦɚɧɞ procedure MoveTo(X,Y: ɉɟɪɟɦɟɳɚɟɬ ɩɟɪɨ ɜ ɩɨɥɨɠɟɧɢɟ (X, Y) ɛɟɡ ɜɵInteger); ɱɟɪɱɢɜɚɧɢɹ ɥɢɧɢɣ procedure Pie(XI, Yl, Ɋɢɫɭɟɬ ɫɟɤɬɨɪ ɷɥɥɢɩɫɚ ɜ ɨɯɜɚɬɵɜɚɸɳɟɦ ɩɪɹɦɨX2, Y2, X3, Y3, X4, Y4: ɭɝɨɥɶɧɢɤɟ (XI, Yl) – (X2, Y2). ɇɚɱɚɥɨ ɞɭɝɢ ɥɟLongint); ɠɢɬ ɧɚ ɩɟɪɟɫɟɱɟɧɢɢ ɷɥɥɢɩɫɚ ɢ ɥɭɱɚ, ɩɪɨɜɟɞɟɧɧɨɝɨ ɢɡ ɟɝɨ ɰɟɧɬɪɚ ɜ ɬɨɱɤɭ (X3, Y3), ɚ ɤɨɧɟɰ - ɧɚ ɩɟɪɟɫɟɱɟɧɢɢ ɫ ɥɭɱɨɦ ɢɡ ɰɟɧɬɪɚ ɜ ɬɨɱɤɭ (X4, Y4). Ⱦɭɝɚ ɱɟɪɬɢɬɫɹ ɩɪɨɬɢɜ ɱɚɫɨɜɨɣ ɫɬɪɟɥɤɢ. ɇɚɱɚɥɨ ɢ ɤɨɧɟɰ ɞɭɝɢ ɫɨɟɞɢɧɹɸɬɫɹ ɩɪɹɦɵɦɢ ɥɢɧɢɹɦɢ ɫ ɟɟ ɰɟɧɬɪɨɦ procedure Draw(X,Y:Integer; Graphic:TGraphic); procedure DrawFocusRect (const Rect:TRect);
83
procedure Polygon ȼɵɱɟɪɱɢɜɚɟɬ ɩɟɪɨɦ ɦɧɨɝɨɭɝɨɥɶɧɢɤ ɩɨ ɬɨɱɤɚɦ, (Points: array of TPoint); ɡɚɞɚɧɧɵɦ ɜ ɦɚɫɫɢɜɟ Points. Ʉɨɧɟɱɧɚɹ ɬɨɱɤɚ ɫɨɟɞɢɧɹɟɬɫɹ ɫ ɧɚɱɚɥɶɧɨɣ ɢ ɦɧɨɝɨɭɝɨɥɶɧɢɤ ɡɚɩɨɥɧɹɟɬɫɹ ɤɢɫɬɶɸ. Ȼɟɡ ɡɚɩɨɥɧɟɧɢɹ – Polyline procedure Polyline ȼɵɱɟɪɱɢɜɚɟɬ ɩɟɪɨɦ ɥɨɦɚɧɭɸ ɩɪɹɦɭɸ ɩɨ ɬɨɱ(Points: array of TPoint); ɤɚɦ, ɡɚɞɚɧɧɵɦ ɜ ɦɚɫɫɢɜɟ Points procedure Rectan gle(XI, ȼɵɱɟɪɱɢɜɚɟɬ ɢ ɡɚɩɨɥɧɹɟɬ ɩɪɹɦɨɭɝɨɥɶɧɢɤ (XI, Yl, X2, Y2: Integer); Yl)–S(X2, Y2). Ⱦɥɹ ɜɵɱɟɪɱɢɜɚɧɢɹ ɛɟɡ ɡɚɩɨɥɧɟɧɢɹ ɢɫɩɨɥɶɡɭɣɬɟ FrameRect ɢɥɢ Polyline procedure Refresh; ɍɫɬɚɧɚɜɥɢɜɚɟɬ ɜ ɤɚɧɜɟ ɭɦɚɥɱɢɜɚɟɦɵɟ ɲɪɢɮɬ ɢ ɤɢɫɬɶ procedure RoundRect(Xl, ȼɵɱɟɪɱɢɜɚɟɬ ɢ ɡɚɩɨɥɧɹɟɬ ɩɪɹɦɨɭɝɨɥɶɧɢɤ Yl, X2,Y2, X3, Y3: Inte (XI,Yl) – (X2, Y2) ɫɨ ɫɤɪɭɝɥɟɧɧɵɦɢ ɭɝɥɚɦɢ. ger) ; ɉɪɹɦɨɭɝɨɥɶɧɢɤ (XI, Yl)–(X3, Y3) ɨɩɪɟɞɟɥɹɟɬ ɞɭɝɭ ɷɥɥɢɩɫɚ ɞɥɹ ɨɤɪɭɝɥɟɧɢɹ ɭɝɥɨɜ procedure Stretch Draw ȼɵɱɟɪɱɢɜɚɟɬ ɢ ɩɪɢ ɧɟɨɛɯɨɞɢɦɨɫɬɢ ɦɚɫɲɬɚɛɢ(const Rect:TRect; ɪɭɟɬ ɝɪɚɮɢɱɟɫɤɢɣ ɨɛɴɟɤɬ Graphic ɬɚɤ, ɱɬɨɛɵ ɨɧ Graphic:TGraphic ); ɩɨɥɧɨɫɬɶɸ ɡɚɧɹɥ ɩɪɹɦɨɭɝɨɥɶɧɢɤ Rect function TextExtent ȼɨɡɜɪɚɳɚɟɬ ɲɢɪɢɧɭ ɢ ɜɵɫɨɬɭ ɩɪɹɦɨɭɝɨɥɶɧɢɤɚ, ɨɯɜɚɬɵɜɚɸɳɟɝɨ ɬɟɤɫɬɨɜɭɸ ɫɬɪɨɤɭ Text (const Text:String):TSize; function TextHeight ȼɨɡɜɪɚɳɚɟɬ ɜɵɫɨɬɭ ɩɪɹɦɨɭɝɨɥɶɧɢɤɚ, ɨɯɜɚɬɵ(const Text: String): ɜɚɸɳɟɝɨ ɬɟɤɫɬɨɜɭɸ ɫɬɪɨɤɭ Text Intege; procedure TextOut(X, Y: ȼɵɜɨɞɢɬ ɬɟɤɫɬɨɜɭɸ ɫɬɪɨɤɭ Text ɬɚɤ, ɱɬɨɛɵ ɥɟInteger; const Text: ɜɵɣ ɜɟɪɯɧɢɣ ɭɝɨɥ ɩɪɹɦɨɭɝɨɥɶɧɢɤɚ, ɨɯɜɚɬɵString); ɜɚɸɳɟɝɨ ɬɟɤɫɬ, ɪɚɫɩɨɥɚɝɚɥɫɹ ɜ ɬɨɱɤɟ (X, Y) ȼɵɜɨɞɢɬ ɬɟɤɫɬɨɜɭɸ ɫɬɪɨɤɭ Text ɬɚɤ, ɱɬɨɛɵ ɥɟprocedure ɜɵɣ ɜɟɪɯɧɢɣ ɭɝɨɥ ɩɪɹɦɨɭɝɨɥɶɧɢɤɚ, ɨɯɜɚɬɵTextRect(Rect: TRect; ɜɚɸɳɟɝɨ ɬɟɤɫɬ, ɪɚɫɩɨɥɚɝɚɥɫɹ ɜ ɬɨɱɤɟ (ɯ, Y). ȿɫX, Y: Integer; const Text: ɥɢ ɩɪɢ ɷɬɨɦ ɤɚɤɚɹ-ɥɢɛɨ ɱɚɫɬɶ ɧɚɞɩɢɫɢ ɜɵɯɨɞɢɬ ɢɡ ɝɪɚɧɢɰ ɩɪɹɦɨɭɝɨɥɶɧɢɤɚ Rect, ɨɧɚ ɨɬɫɟɤɚɟɬɫɹ String); ɢ ɧɟ ɛɭɞɟɬ ɜɢɞɧɚ ȼɨɡɜɪɚɳɚɟɬ ɲɢɪɢɧɭ ɩɪɹɦɨɭɝɨɥɶɧɢɤɚ, ɨɯɜɚɬɵfunction TextWidth ɜɚɸɳɟɝɨ ɬɟɤɫɬɨɜɭɸ ɫɬɪɨɤɭ Text (const Text:String): Integer; function TryLock: ɉɵɬɚɟɬɫɹ ɡɚɛɥɨɤɢɪɨɜɚɬɶ ɤɚɧɜɭ. ȿɫɥɢ ɨɧɚ ɧɟ ɡɚBoolean; ɛɥɨɤɢɪɨɜɚɧɚ ɞɪɭɝɢɦ ɩɨɬɨɤɨɦ ɤɨɦɚɧɞ, – True, ɜ ɩɪɨɬɢɜɧɨɦ ɫɥɭɱɚɟ ɧɢɱɟɝɨ ɧɟ ɞɟɥɚɟɬ ɢ ɜɨɡɜɪɚɳɚɟɬ False procedure Unlock; ɍɦɟɧɶɲɚɟɬ ɧɚ 1 ɫɱɟɬɱɢɤ ɛɥɨɤɢɪɨɜɨɤ ɤɚɧɜɵ 84
ɅɂɌȿɊȺɌɍɊȺ 1. Ⱥɪɯɚɧɝɟɥɶɫɤɢɣ Ⱥ.ə. ɉɪɨɝɪɚɦɦɢɪɨɜɚɧɢɟ ɜ Delphi 7 / Ⱥ.ə. Ⱥɪɯɚɧɝɟɥɶɫɤɢɣ. – Ɇ. : ȻɂɇɈɆ, 2003. – 1152 ɫ. 2. Ⱥɪɯɚɧɝɟɥɶɫɤɢɣ Ⱥ.ə. Delphi 7 : ɫɩɪɚɜɨɱɧɨɟ ɩɨɫɨɛɢɟ / Ⱥ.ə. Ⱥɪɯɚɧɝɟɥɶɫɤɢɣ. – Ɇ. : ȻɂɇɈɆ, 2003. – 1024 ɫ . 3. Ⱥɪɯɚɧɝɟɥɶɫɤɢɣ Ⱥ.ə. ɉɪɢɟɦɵ ɩɪɨɝɪɚɦɦɢɪɨɜɚɧɢɹ ɜ Delphi / Ⱥ.ə. Ⱥɪɯɚɧɝɟɥɶɫɤɢɣ. – Ɇ. : ȻɂɇɈɆ, 2003. – 784 ɫ. 4. Ɍɸɤɚɱɟɜ ɇ.Ⱥ. ɉɪɨɝɪɚɦɦɢɪɨɜɚɧɢɟ ɜ Delphi ɞɥɹ ɧɚɱɢɧɚɸɳɢɯ / ɇ.Ⱥ. Ɍɸɤɚɱɟɜ, Ʉ.ɋ. Ɋɵɛɚɤ, ȿ.ȿ Ɇɢɯɚɣɥɨɜɚ. – ɋɉɛ. : Ȼɏȼ, 2007. – 672 ɫ. 5. Ʉɚɪɩɨɜ Ȼ . Delphi : ɫɩɟɰɢɚɥɶɧɵɣ ɫɩɪɚɜɨɱɧɢɤ. – ɋɉɛ.: ɉɢɬɟɪ, 2002. – 688 c. 6. Ɍɟɣɤɫɟɣɪɚ ɋ. Borland Delphi 6 : ɪɭɤɨɜɨɞɫɬɜɨ ɪɚɡɪɚɛɨɬɱɢɤɚ / ɋ. Ɍɟɣɤɫɟɣɪɚ, Ʉ. ɉɚɱɟɤɨ. – ɋɉɛ. : ȼɢɥɶɹɦɫ, 2002. – 1120 ɫ. 7. Ɏɚɪɨɧɨɜ ȼ.ȼ. ɋɢɫɬɟɦɚ ɩɪɨɝɪɚɦɦɢɪɨɜɚɧɢɹ Delphi 7 / ȼ.ȼ. Ɏɚɪɨɧɨɜ. – ɋɉɛ. : Ȼɏȼ-ɉɟɬɟɪɛɭɪɝ, 2005. – 912 ɫ.
85
ɍɱɟɛɧɨɟ ɢɡɞɚɧɢɟ
ȿ.ɇ. ɄɈɊɀɈȼ, Ɉ.Ⱥ. ɄɍɓȿȼȺ
ȼȼȿȾȿɇɂȿ ȼ ɌȿɏɇɈɅɈȽɂɘ ɉɊɈȽɊȺɆɆɂɊɈȼȺɇɂə ɑɚɫɬɶ 1. ɋɪɟɞɚ ɨɛɴɟɤɬɧɨ-ɨɪɢɟɧɬɢɪɨɜɚɧɧɨɝɨ ɩɪɨɝɪɚɦɦɢɪɨɜɚɧɢɹ Delphi ɍɱɟɛɧɨɟ ɩɨɫɨɛɢɟ ɞɥɹ ɜɭɡɨɜ
Ɋɟɞɚɤɬɨɪ ɘ.Ɉ. ɋɚɥɶɧɢɤɨɜɚ
ɉɨɞɩɢɫɚɧɨ ɜ ɩɟɱɚɬɶ 06.07.07. Ɏɨɪɦɚɬ 60×84/16. ɍɫɥ. ɩɟɱ. ɥ. 5,1. Ɍɢɪɚɠ 100 ɷɤɡ. Ɂɚɤɚɡ 1402. ɂɡɞɚɬɟɥɶɫɤɨ-ɩɨɥɢɝɪɚɮɢɱɟɫɤɢɣ ɰɟɧɬɪ ȼɨɪɨɧɟɠɫɤɨɝɨ ɝɨɫɭɞɚɪɫɬɜɟɧɧɨɝɨ ɭɧɢɜɟɪɫɢɬɟɬɚ. 394000, ɝ. ȼɨɪɨɧɟɠ, ɩɥ. ɢɦ. Ʌɟɧɢɧɚ, 10. Ɍɟɥ. 208-298, 598-026 (ɮɚɤɫ) http://www.ppc.vsu.ru; e-mail: [email protected] Ɉɬɩɟɱɚɬɚɧɨ ɜ ɬɢɩɨɝɪɚɮɢɢ ɂɡɞɚɬɟɥɶɫɤɨ-ɩɨɥɢɝɪɚɮɢɱɟɫɤɨɝɨ ɰɟɧɬɪɚ ȼɨɪɨɧɟɠɫɤɨɝɨ ɝɨɫɭɞɚɪɫɬɜɟɧɧɨɝɨ ɭɧɢɜɟɪɫɢɬɟɬɚ. 394000, ɝ. ȼɨɪɨɧɟɠ, ɭɥ. ɉɭɲɤɢɧɫɤɚɹ, 3. Ɍɟɥ. 204-133.
86