Разработка_и_анализ_требований_практика
.pdfɅȺȻ. Ɋ. ʋ 5 ɊȿȺɅ-ə ȺɊɏ-ɕ ɇȺ ȻȺɁȿ ɈȻɔȿɄɌɇɈ-ɊȿɅəɐ. ɈɌɈȻɊȺɀȿɇɂə ɋ ɌɂɉɂɁɂɊɈȼȺɇɇɕɆɂ ɈȻɔȿɄɌȺɆɂ
ȿɩɜɛɝɦɠɨɣɠ ɨɩɝɩɞɩ ɧɩɟɮɦɺ ɝ ɪɫɩɠɥɭ
Ɍɚɛɥɢɰɚ 5.18
|
ɋɜɨɣɫɬɜɚ ɤɥɚɫɫɚ TStudentBook |
|
Ɉɩɢɫɚɧɢɟ |
ɋɜɨɣɫɬɜɨ |
|
Fk_book: integer |
ɋɫɵɥɤɚ ɧɚ ɤɧɢɝɭ, ɜɵɞɚɧɧɭɸ ɫɬɭɞɟɧɬɭ |
Fk_student: integer |
ɋɫɵɥɤɚ ɧɚ ɫɬɭɞɟɧɬɚ, ɤɨɬɨɪɨɦɭ ɜɵɞɚɥɢ ɤɧɢɝɭ |
Ɍɚɛɥɢɰɚ 5.19
|
ɋɜɨɣɫɬɜɚ ɤɥɚɫɫɚ TStudents |
|
Ɉɩɢɫɚɧɢɟ |
ɋɜɨɣɫɬɜɨ |
|
Family: string |
Ɏɚɦɢɥɢɹ ɫɬɭɞɟɧɬɚ |
Name: string |
ɂɦɹ ɫɬɭɞɟɧɬɚ |
SecondName: string |
Ɉɬɱɟɫɬɜɨ ɫɬɭɞɟɧɬɚ |
Num: integer |
ɇɨɦɟɪ ɡɚɱɟɬɧɨɣ ɤɧɢɠɤɢ ɫɬɭɞɟɧɬɚ |
Group: string |
Ƚɪɭɩɩɚ ɫɬɭɞɟɧɬɚ |
ɇɟɜɢɡɭɚɥɶɧɵɟ ɤɨɦɩɨɧɟɧɬɵ ɢɧɬɟɪɮɟɣɫɚ, ɢɫɩɨɥɶɡɭɟɦɵɟ ɜ ɩɪɢɦɟɪɟ
TimageList ɩɪɟɞɧɚɡɧɚɱɟɧ ɞɥɹ ɯɪɚɧɟɧɢɹ ɢ ɩɨɫɥɟɞɭɸɳɟɝɨ ɢɫɩɨɥɶɡɨɜɚɧɢɹ ɪɚɡɥɢɱɧɵɯ ɢɡɨɛɪɚɠɟɧɢɣ.
Ⱦɥɹ ɢɫɩɨɥɶɡɨɜɚɧɢɹ ɷɬɨɝɨ ɤɨɦɩɨɧɟɧɬɚ ɩɨɦɟɫɬɢɬɟ ɟɝɨ ɧɚ ɮɨɪɦɭ ɢ ɞɜɨɣ-
ɧɵɦ ɳɟɥɱɤɨɦ ɦɵɲɢ ɡɚɩɭɫɬɢɬɟ Ɇɚɫɬɟɪ ɫɨɡɞɚɧɢɹ ɢɡɨɛɪɚɠɟɧɢɣ (ɪɢɫ. 5.8).
ȼɆɚɫɬɟɪɟ ɫɨɡɞɚɧɢɹ ɢɡɨɛɪɚɠɟɧɢɣ ɦɨɠɧɨ ɞɨɛɚɜɥɹɬɶ, ɪɟɞɚɤɬɢɪɨɜɚɬɶ
ɢɭɞɚɥɹɬɶ ɢɡɨɛɪɚɠɟɧɢɹ ɮɨɪɦɚɬɚ ɢɤɨɧɨɤ.
Ɋɢɫ. 5.8. Ɇɚɫɬɟɪ ɫɨɡɞɚɧɢɹ ɢɡɨɛɪɚɠɟɧɢɣ ɜ TImageList
ɍɠɰɨɩɦɩɞɣɣ ɫɛɢɫɛɜɩɭɥɣ ɪɫɩɞɫɛɧɧɨɩɞɩ ɩɜɠɬɪɠɲɠɨɣɺ. Ɇɛɜ. ɪɫɛɥɭɣɥɮɧ |
-81- |
ɅȺȻ. Ɋ. ʋ 5 ɊȿȺɅ-ə ȺɊɏ-ɕ ɇȺ ȻȺɁȿ ɈȻɔȿɄɌɇɈ-ɊȿɅəɐ. ɈɌɈȻɊȺɀȿɇɂə ɋ ɌɂɉɂɁɂɊɈȼȺɇɇɕɆɂ ɈȻɔȿɄɌȺɆɂ
ȿɩɜɛɝɦɠɨɣɠ ɨɩɝɩɞɩ ɧɩɟɮɦɺ ɝ ɪɫɩɠɥɭ
Ɋɢɫ. 5.9. Ɉɤɧɨ ɧɚɫɬɪɨɣɤɢ ɞɟɣɫɬɜɢɣ ɤɨɦɩɨɧɟɧɬɚ TActionManager
TActionManager – ɦɟɧɟɞɠɟɪ ɞɟɣɫɬɜɢɣ. ɉɪɢɦɟɧɹɟɬɫɹ ɞɥɹ ɭɩɪɚɜɥɟɧɢɹ ɞɟɣɫɬɜɢɹɦɢ, ɩɨɜɬɨɪɧɨ ɢɫɩɨɥɶɡɭɟɦɵɦɢ ɜ ɩɪɨɟɤɬɟ. Ⱦɥɹ ɭɫɬɚɧɨɜɤɢ ɢɡɨɛɪɚɠɟɧɢɣ, ɨɬɨɛɪɚɠɚɟɦɵɯ ɜ ɞɟɣɫɬɜɢɹɯ, ɧɭɠɧɨ ɧɚɫɬɪɨɢɬɶ ɫɜɨɣɫɬɜɨ Images. Ⱦɥɹ ɷɬɨɝɨ ɳɟɥɤɧɢɬɟ ɞɜɚ ɪɚɡɚ ɩɨ ɤɨɦɩɨɧɟɧɬɭ (ɪɢɫ. 5.9).
Ⱦɥɹ ɞɨɛɚɜɥɟɧɢɹ ɞɟɣɫɬɜɢɹ ɧɚɠɦɢɬɟ ɤɥɚɜɢɲɭ Ins. ȼ ɫɩɢɫɤɟ Actions ɩɨɹɜɢɬɫɹ ɧɨɜɨɟ ɞɟɣɫɬɜɢɟ. Ⱦɥɹ ɧɚɫɬɪɨɣɤɢ ɫɜɨɣɫɬɜ ɢ ɫɨɛɵɬɢɣ ɞɟɣɫɬɜɢɹ ɢɫɩɨɥɶɡɭɣɬɟ Ɉɛɥɚɫɬɶ ɢɧɫɩɟɤɬɨɪɚ. ɋɜɨɣɫɬɜɚ, ɤɨɬɨɪɵɟ ɦɨɠɧɨ ɧɚɫɬɪɚɢɜɚɬɶ ɭ ɞɟɣɫɬɜɢɹ, ɩɪɟɞɫɬɚɜɥɟɧɵ ɜ ɬɚɛɥ. 5.20. ɋɨɛɵɬɢɹ ɞɟɣɫɬɜɢɣ ɨɩɢɫɚɧɵ ɜ ɬɚɛɥ. 5.21.
ɋɜɨɣɫɬɜɨ
Caption
Name ImageIndex Visible
ɋɨɛɵɬɢɟ
OnExecute
OnHint
Ɍɚɛɥɢɰɚ 5.20
ɋɜɨɣɫɬɜɚ ɞɟɣɫɬɜɢɣ
Ɉɩɢɫɚɧɢɟ Ɉɬɨɛɪɚɠɚɟɦɨɟ ɧɚɡɜɚɧɢɟ ɞɟɣɫɬɜɢɹ ɂɦɹ ɞɟɣɫɬɜɢɹ
ɇɨɦɟɪ ɪɢɫɭɧɤɚ, ɚɫɫɨɰɢɢɪɭɟɦɨɝɨ ɫ ɞɟɣɫɬɜɢɟɦ ȼɢɞɢɦɨɫɬɶ ɞɟɣɫɬɜɢɹ
Ɍɚɛɥɢɰɚ 5.21
ɋɨɛɵɬɢɹ ɞɟɣɫɬɜɢɣ
Ɉɩɢɫɚɧɢɟ
ɋɨɛɵɬɢɟ, ɩɪɨɢɫɯɨɞɹɳɟɟ ɩɪɢ ɜɵɩɨɥɧɟɧɢɢ ɞɟɣɫɬɜɢɹ ɋɨɛɵɬɢɟ, ɩɪɨɢɫɯɨɞɹɳɟɟ ɩɪɢ ɨɬɨɛɪɚɠɟɧɢɢ ɜɫɩɥɵɜɚɸɳɟɣ ɩɨɞɫɤɚɡɤɢ
ɍɠɰɨɩɦɩɞɣɣ ɫɛɢɫɛɜɩɭɥɣ ɪɫɩɞɫɛɧɧɨɩɞɩ ɩɜɠɬɪɠɲɠɨɣɺ. Ɇɛɜ. ɪɫɛɥɭɣɥɮɧ |
-82- |
ɅȺȻ. Ɋ. ʋ 5 ɊȿȺɅ-ə ȺɊɏ-ɕ ɇȺ ȻȺɁȿ ɈȻɔȿɄɌɇɈ-ɊȿɅəɐ. ɈɌɈȻɊȺɀȿɇɂə ɋ ɌɂɉɂɁɂɊɈȼȺɇɇɕɆɂ ɈȻɔȿɄɌȺɆɂ
ȿɩɜɛɝɦɠɨɣɠ ɨɩɝɩɞɩ ɧɩɟɮɦɺ ɝ ɪɫɩɠɥɭ
ȼɢɡɭɚɥɶɧɵɟ ɤɨɦɩɨɧɟɧɬɵ, ɢɫɩɨɥɶɡɭɟɦɵɟ ɜ ɩɪɢɦɟɪɟ
TBitBtn ɩɪɟɞɫɬɚɜɥɹɟɬ ɫɨɛɨɣ ɤɧɨɩɤɭ ɫ ɢɡɨɛɪɚɠɟɧɢɟɦ. ɋɜɨɣɫɬɜɚ ɤɨɦɩɨɧɟɧɬɚ ɩɪɟɞɫɬɚɜɥɟɧɵ ɜ ɬɚɛɥ. 5.22, ɫɨɛɵɬɢɟ ɤɨɦɩɨɧɟɧɬɚ – ɜ ɬɚɛɥ. 5.23.
TDBGrid – ɤɨɦɩɨɧɟɧɬ, ɨɬɨɛɪɚɠɚɸɳɢɣ ɫɟɬɤɭ ɫɬɪɨɤ. ɉɪɟɞɧɚɡɧɚɱɟɧ ɞɥɹ ɨɬɨɛɪɚɠɟɧɢɹ ɧɚɛɨɪɚ ɞɚɧɧɵɯ. ɋɨɛɵɬɢɹ TDBGrid ɩɪɟɞɫɬɚɜɥɟɧɵ ɜ ɬɚɛɥ. 5.24.
|
|
|
Ɍɚɛɥɢɰɚ 5.22 |
|
|
|
ɋɜɨɣɫɬɜɚ ɤɨɦɩɨɧɟɧɬɚ TBitBtn |
|
|
|
|
ɋɜɨɣɫɬɜɚ |
Ɉɩɢɫɚɧɢɟ |
||
|
|
|
ɇɚɞɩɢɫɶ, ɨɬɨɛɪɚɠɚɟɦɚɹ ɧɚ ɤɧɨɩɤɟ |
Caption |
|||
ModalResult |
Ɂɧɚɱɟɧɢɟ, ɤɨɬɨɪɨɟ ɡɚɩɢɫɵɜɚɟɬɫɹ ɜ ɪɟɡɭɥɶɬɚɬ ɨɬɨɛɪɚɠɟɧɢɹ ɦɨɞɚɥɶɧɨɣ ɮɨɪɦɵ |
||
Glyph |
ɂɡɨɛɪɚɠɟɧɢɟ, ɨɬɨɛɪɚɠɚɟɦɨɟ ɧɚ ɤɧɨɩɤɟ |
||
|
|
|
Ɍɚɛɥɢɰɚ 5.23 |
|
|
|
ɋɨɛɵɬɢɟ ɤɨɦɩɨɧɟɧɬɚ TBitBtn |
|
|
|
Ɉɩɢɫɚɧɢɟ |
ɋɨɛɵɬɢɟ |
|
|
|
OnClick |
ɋɨɛɵɬɢɟ, ɩɪɨɢɫɯɨɞɹɳɟɟ ɩɨ ɧɚɠɚɬɢɸ ɧɚ ɤɧɨɩɤɭ |
||
|
|
|
Ɍɚɛɥɢɰɚ 5.24 |
|
|
|
ɋɨɛɵɬɢɹ ɤɨɦɩɨɧɟɧɬɚ TDBGrid |
|
|
Ɉɩɢɫɚɧɢɟ |
|
ɋɨɛɵɬɢɟ |
|||
Align |
|
ȼɵɪɚɜɧɢɜɚɧɢɟ ɤɨɦɩɨɧɟɧɬɚ ɩɨ ɮɨɪɦɟ |
|
Columns |
|
ɇɚɫɬɪɨɣɤɚ ɜɢɡɭɚɥɶɧɵɯ ɫɜɨɣɫɬɜ (ɧɚɡɜɚɧɢɟ, ɲɪɢɮɬ ɢ ɬ. ɞ.) ɩɨɥɟɣ, ɨɬɨɛɪɚɠɚɟ- |
|
DataSource |
|
ɦɵɯ ɜ ɫɟɬɤɟ ɫɬɪɨɤ |
|
ɂɫɬɨɱɧɢɤ ɞɚɧɧɵɯ ɞɥɹ ɨɬɨɛɪɚɠɟɧɢɹ ɞɚɧɧɵɯ ɜ ɫɟɬɤɟ ɬɚɛɥɢɰɵ |
|||
|
|
|
Ɍɚɛɥɢɰɚ 5.25 |
|
|
|
ɋɜɨɣɫɬɜɚ ɤɨɦɩɨɧɟɧɬɚ TLabel |
ɋɜɨɣɫɬɜɨ
Caption
Font
WordWrap
Ɉɩɢɫɚɧɢɟ
Ɉɬɨɛɪɚɠɚɟɦɚɹ ɧɚɞɩɢɫɶ ɒɪɢɮɬ ɨɬɨɛɪɚɠɚɟɦɨɣ ɧɚɞɩɢɫɢ ɉɟɪɟɧɨɫ ɩɨ ɫɥɨɝɚɦ
Ɍɚɛɥɢɰɚ 5.26
ɋɜɨɣɫɬɜɚ ɤɨɦɩɨɧɟɧɬɚ TEdit
ɋɜɨɣɫɬɜɨ |
|
Ɉɩɢɫɚɧɢɟ |
Text |
|
Ɉɬɨɛɪɚɠɚɟɦɵɣ ɬɟɤɫɬ |
|
|
Ɍɚɛɥɢɰɚ 5.27 |
|
|
ɋɨɛɵɬɢɹ ɤɨɦɩɨɧɟɧɬɚ TEdit |
|
|
Ɉɩɢɫɚɧɢɟ |
ɋɨɛɵɬɢɟ |
|
|
OnChange |
ɂɡɦɟɧɟɧɢɟ ɧɚɞɩɢɫɢ ɜ ɤɨɦɩɨɧɟɧɬɟ |
|
OnClick |
|
ɓɟɥɱɨɤ ɥɟɜɨɣ ɤɧɨɩɤɨɣ ɦɵɲɤɢ ɩɨ ɤɨɦɩɨɧɟɧɬɭ |
ɍɠɰɨɩɦɩɞɣɣ ɫɛɢɫɛɜɩɭɥɣ ɪɫɩɞɫɛɧɧɨɩɞɩ ɩɜɠɬɪɠɲɠɨɣɺ. Ɇɛɜ. ɪɫɛɥɭɣɥɮɧ |
-83- |
ɅȺȻ. Ɋ. ʋ 5 ɊȿȺɅ-ə ȺɊɏ-ɕ ɇȺ ȻȺɁȿ ɈȻɔȿɄɌɇɈ-ɊȿɅəɐ. ɈɌɈȻɊȺɀȿɇɂə ɋ ɌɂɉɂɁɂɊɈȼȺɇɇɕɆɂ ɈȻɔȿɄɌȺɆɂ
ȿɩɜɛɝɦɠɨɣɠ ɨɩɝɩɞɩ ɧɩɟɮɦɺ ɝ ɪɫɩɠɥɭ
|
|
|
|
|
Ɍɚɛɥɢɰɚ 5.28 |
|
|
|
ɋɜɨɣɫɬɜɚ ɤɨɦɩɨɧɟɧɬɚ TComboBox |
||
|
|
|
|
Ɉɩɢɫɚɧɢɟ |
|
ɋɜɨɣɫɬɜɨ |
|
||||
Text |
Ɉɬɨɛɪɚɠɚɟɦɨɟ ɡɧɚɱɟɧɢɟ |
|
|||
Items |
ɋɨɞɟɪɠɢɬ ɡɧɚɱɟɧɢɹ ɜɵɩɚɞɚɸɳɟɝɨ ɫɩɢɫɤɚ |
|
|||
ItemIndex |
ɇɨɦɟɪ ɨɬɨɛɪɚɠɚɟɦɨɝɨ ɡɧɚɱɟɧɢɹ ɢɡ ɜɵɩɚɞɚɸɳɟɝɨ ɫɩɢɫɤɚ |
||||
Style |
ɋɬɢɥɶ ɨɬɨɛɪɚɠɟɧɢɹ ɡɧɚɱɟɧɢɹ ɜɵɩɚɞɚɸɳɟɝɨ ɫɩɢɫɤɚ |
||||
|
|
|
|
|
Ɍɚɛɥɢɰɚ 5.29 |
|
|
|
ɋɨɛɵɬɢɹ ɤɨɦɩɨɧɟɧɬɚ TComboBox |
||
|
|
|
|
Ɉɩɢɫɚɧɢɟ |
|
ɋɨɛɵɬɢɟ |
|
|
|||
OnChange |
|
|
ɂɡɦɟɧɟɧɢɟ ɧɚɞɩɢɫɢ ɜ ɤɨɦɩɨɧɟɧɬɟ |
|
|
OnClick |
|
|
ɓɟɥɱɨɤ ɥɟɜɨɣ ɤɧɨɩɤɨɣ ɦɵɲɤɢ ɩɨ ɤɨɦɩɨɧɟɧɬɭ |
||
OnSelect |
|
|
ȼɵɛɨɪ ɡɧɚɱɟɧɢɹ ɢɡ ɜɵɩɚɞɚɸɳɟɝɨ ɫɩɢɫɤɚ |
|
|
|
|
|
|
|
Ɍɚɛɥɢɰɚ 5.30 |
|
|
|
ɋɜɨɣɫɬɜɚ ɤɨɦɩɨɧɟɧɬɚ TPageControl |
||
|
|
|
|
Ɉɩɢɫɚɧɢɟ |
|
ɋɜɨɣɫɬɜɨ |
|
|
|
||
Align |
|
|
ɋɩɨɫɨɛ ɪɚɫɩɨɥɨɠɟɧɢɹ ɤɨɦɩɨɧɟɧɬɚ ɧɚ ɮɨɪɦɟ |
||
ActivePage |
|
|
ɋɜɨɣɫɬɜɨ ɨɩɪɟɞɟɥɹɟɬ ɬɟɤɭɳɭɸ ɫɬɪɚɧɢɰɭ |
|
|
ActivePageIndex |
ɋɜɨɣɫɬɜɨ ɨɩɪɟɞɟɥɹɟɬ ɧɨɦɟɪ ɬɟɤɭɳɟɣ ɫɬɪɚɧɢɰɵ |
||||
Caption |
|
|
ɇɚɡɜɚɧɢɟ ɥɢɫɬɚ |
|
|
|
|
|
|
|
Ɍɚɛɥɢɰɚ 5.31 |
|
|
|
ɋɨɛɵɬɢɟ ɤɨɦɩɨɧɟɧɬɚ TPageControl |
||
|
|
|
|
|
|
|
|
|
ɋɨɛɵɬɢɟ |
|
Ɉɩɢɫɚɧɢɟ |
OnChange |
|
|
|
ɂɡɦɟɧɟɧɢɟ ɬɟɤɭɳɟɣ ɫɬɪɚɧɢɰɵ |
TLabel – ɤɨɦɩɨɧɟɧɬ, ɨɬɨɛɪɚɠɚɸɳɢɣ ɧɟɪɟɞɚɤɬɢɪɭɟɦɭɸ ɫɬɪɨɤɭ. ɋɜɨɣɫɬɜɚ TLabel ɩɪɟɞɫɬɚɜɥɟɧɵ ɜ ɬɚɛɥ. 5.25.
TEdit – ɤɨɦɩɨɧɟɧɬ, ɨɬɨɛɪɚɠɚɸɳɢɣ ɪɟɞɚɤɬɢɪɭɟɦɭɸ ɧɚɞɩɢɫɶ. ɋɜɨɣɫɬɜɨ TEdit ɩɪɟɞɫɬɚɜɥɟɧɨ ɜ ɬɚɛɥ. 5.26, ɫɨɛɵɬɢɹ ɞɚɧɧɨɝɨ ɤɨɦɩɨɧɟɧɬɚ ɩɪɢɜɟɞɟɧɵ ɜ ɬɚɛɥ. 5.27.
TComboBox – ɤɨɦɩɨɧɟɧɬ, ɩɪɟɞɫɬɚɜɥɹɸɳɢɣ ɫɨɛɨɣ ɤɨɦɛɢɧɢɪɨɜɚɧɧɵɣ ɜɵɩɚɞɚɸɳɢɣ ɫɩɢɫɨɤ. ɋɜɨɣɫɬɜɚ ɤɨɦɩɨɧɟɧɬɚ ɩɪɟɞɫɬɚɜɥɟɧɵ ɜ ɬɚɛɥ. 5.28, ɟɝɨ ɫɨɛɵɬɢɹ – ɜ ɬɚɛɥ. 5.29.
TPageControl – ɤɨɦɩɨɧɟɧɬ, ɫɨɞɟɪɠɚɳɢɣ ɫɩɢɫɨɤ ɫɬɪɚɧɢɰɵ ɢ ɡɚɤɥɚɞɨɤ, ɫ ɩɨɦɨɳɶɸ ɤɨɬɨɪɵɯ ɦɨɠɧɨ ɩɟɪɟɯɨɞɢɬɶ ɫ ɨɞɧɨɣ ɫɬɪɚɧɢɰɵ ɧɚ ɞɪɭɝɭɸ. ɉɨɫɥɟ ɞɨɛɚɜɥɟɧɢɹ ɤɨɦɩɨɧɟɧɬɚ ɧɚ ɮɨɪɦɭ ɞɥɹ ɞɨɛɚɜɥɟɧɢɹ ɧɨɜɨɣ ɫɬɪɚɧɢɰɵ ɧɭɠɧɨ ɜɵɡɜɚɬɶ ɤɨɧɬɟɤɫɬɧɨɟ ɦɟɧɸ, ɜ ɤɨɬɨɪɨɦ ɜɵɛɪɚɬɶ ɩɭɧɤɬ New Page. ɋɜɨɣɫɬɜɚ ɤɨɦɩɨɧɟɧɬɚ TPageControl ɩɪɟɞɫɬɚɜɥɟɧɵ ɜ ɬɚɛɥ. 5.30, ɫɨɛɵɬɢɟ ɤɨɦɩɨɧɟɧɬɚ
TPageControl ɩɪɢɜɟɞɟɧɵ ɜ ɬɚɛɥ. 5.31.
TPanel – ɤɨɦɩɨɧɟɧɬ, ɩɪɟɞɧɚɡɧɚɱɟɧɧɵɣ ɞɥɹ ɨɪɝɚɧɢɡɚɰɢɢ ɪɚɫɩɨɥɨɠɟɧɢɹ ɞɪɭɝɢɯ ɜɢɡɭɚɥɶɧɵɯ ɤɨɦɩɨɧɟɧɬɨɜ ɧɚ ɮɨɪɦɟ. ȼɵɪɚɜɧɢɜɚɧɢɟ ɤɨɦɩɨɧɟɧɬɚ TPanel ɧɚɫɬɪɚɢɜɚɟɬɫɹ ɜ ɫɜɨɣɫɬɜɟ Align.
ɋɛɢɫɛɜɩɭɥɛ ɣɨɭɠɫɯɠɤɬɛ
Ⱦɨɛɚɜɥɟɧɢɟ ɧɨɜɨɣ ɮɨɪɦɵ ɨɫɭɳɟɫɬɜɥɹɟɬɫɹ ɩɭɬɟɦ ɜɵɛɨɪɚ ɜ ɝɥɚɜɧɨɦ ɦɟ-
ɧɸ ɩɭɧɤɬɚ File |
New |
Form – Delphi for Win32. ɉɪɢ ɷɬɨɦ ɛɭɞɟɬ ɫɨɡɞɚɧɚ |
|
|
|
||
ɍɠɰɨɩɦɩɞɣɣ ɫɛɢɫɛɜɩɭɥɣ ɪɫɩɞɫɛɧɧɨɩɞɩ ɩɜɠɬɪɠɲɠɨɣɺ. Ɇɛɜ. ɪɫɛɥɭɣɥɮɧ |
-84- |
ɅȺȻ. Ɋ. ʋ 5 ɊȿȺɅ-ə ȺɊɏ-ɕ ɇȺ ȻȺɁȿ ɈȻɔȿɄɌɇɈ-ɊȿɅəɐ. ɈɌɈȻɊȺɀȿɇɂə ɋ ɌɂɉɂɁɂɊɈȼȺɇɇɕɆɂ ɈȻɔȿɄɌȺɆɂ
ȿɩɜɛɝɦɠɨɣɠ ɨɩɝɩɞɩ ɧɩɟɮɦɺ ɝ ɪɫɩɠɥɭ
ɧɨɜɚɹ ɮɨɪɦɚ, ɤɨɬɨɪɚɹ ɩɨɹɜɢɬɫɹ ɧɚ ɷɤɪɚɧɟ. ɉɪɢ ɞɨɛɚɜɥɟɧɢɢ ɧɨɜɨɣ ɮɨɪɦɵ ɜ ɩɪɨɟɤɬ ɨɧɚ ɜɫɬɚɟɬ ɜ ɫɩɢɫɨɤ ɚɜɬɨɦɚɬɢɱɟɫɤɢ ɫɨɡɞɚɜɚɟɦɵɯ ɮɨɪɦ.
Ɋɢɫ. 5.10. Ɉɤɧɨ ɫɜɨɣɫɬɜɚ ɩɪɨɟɤɬɚ
Ⱦɥɹ ɭɞɚɥɟɧɢɹ ɮɨɪɦɵ ɢɡ ɷɬɨɝɨ ɫɩɢɫɤɚ ɧɭɠɧɨ ɜ ɝɥɚɜɧɨɦ ɦɟɧɸ ɜɵɛɪɚɬɶ ɩɭɧɤɬ Project Options. ɉɨɹɜɢɬɫɹ ɞɢɚɥɨɝ, ɩɪɟɞɫɬɚɜɥɟɧɧɵɣ ɧɚ ɪɢɫ. 5.10. Ⱦɥɹ ɭɞɚɥɟɧɢɹ ɮɨɪɦɵ ɢɡ ɫɩɢɫɤɚ ɚɜɬɨɦɚɬɢɱɟɫɤɢ ɫɨɡɞɚɜɚɟɦɵɯ ɮɨɪɦ ɧɭɠɧɨ ɜɵɛɪɚɬɶ ɟɟ ɜ ɫɩɢɫɤɟ Auto-create form ɢ ɧɚɠɚɬɶ ɤɧɨɩɤɭ >.
ɉ ɪ ɢ ɦ ɟ ɪ ɫ ɨ ɡ ɞ ɚ ɧ ɢ ɹ ɢ ɧ ɬ ɟ ɪ ɮ ɟ ɣ ɫ ɚ
ɋɨɡɞɚɞɢɦ ɢɧɬɟɪɮɟɣɫ, ɨɛɥɚɞɚɸɳɢɣ ɫɥɟɞɭɸɳɟɣ ɮɭɧɤɰɢɨɧɚɥɶɧɨɫɬɶɸ: ɪɟɞɚɤɬɢɪɨɜɚɧɢɟ ɫɩɢɫɤɚ ɫɬɭɞɟɧɬɨɜ; ɪɟɞɚɤɬɢɪɨɜɚɧɢɟ ɫɩɢɫɤɚ ɤɧɢɝ; ɜɵɞɚɱɚ ɤɧɢɝ ɫɬɭɞɟɧɬɚɦ.
Ⱦɥɹ ɷɬɨɝɨ ɫɨɡɞɚɞɢɦ ɱɟɬɵɪɟ ɮɨɪɦɵ.
Ƚɥɚɜɧɚɹ ɮɨɪɦɚ
Ƚɥɚɜɧɚɹ ɮɨɪɦɚ ɹɜɥɹɟɬɫɹ ɨɫɧɨɜɧɨɣ ɪɚɛɨɱɟɣ ɮɨɪɦɨɣ ɜɫɟɣ ɩɪɨɝɪɚɦɦɵ. ɉɪɢɦɟɪ ɢɧɬɟɪɮɟɣɫɚ ɩɪɟɞɫɬɚɜɥɟɧ ɧɚ ɪɢɫ. 5.11 ɢ ɪɢɫ. 5.12.
Ⱦɥɹ ɫɨɡɞɚɧɢɹ ɝɥɚɜɧɨɣ ɮɨɪɦɵ ɜɵɩɨɥɧɢɬɟ ɫɥɟɞɭɸɳɢɟ ɲɚɝɢ:
1.ɉɨɦɟɫɬɢɬɟ ɧɚ ɮɨɪɦɭ ɤɨɦɩɨɧɟɧɬ TPageControl, ɧɚɫɬɪɨɣɬɟ ɭ ɧɟɝɨ ɫɜɨɣɫɬɜɨ Align ɪɚɜɧɵɦ alClent – ɤɨɦɩɨɧɟɧɬ ɡɚɣɦɟɬ ɜɫɟ ɫɜɨɛɨɞɧɨɟ ɦɟɫɬɨ ɧɚ ɮɨɪɦɟ.
2.ɓɟɥɤɧɢɬɟ ɩɪɚɜɨɣ ɤɥɚɜɢɲɟɣ ɦɵɲɤɢ ɩɨ ɤɨɦɩɨɧɟɧɬɭ TPageControl. ɉɨɹɜɢɬɫɹ ɤɨɧɬɟɤɫɬɧɨɟ ɦɟɧɸ, ɜ ɤɨɬɨɪɨɦ ɜɵɛɟɪɢɬɟ ɩɭɧɤɬ New Page. Ȼɭɞɟɬ ɫɨɡɞɚɧɚ ɧɨɜɚɹ ɫɬɪɚɧɢɰɚ.
3.ɉɨɜɬɨɪɢɬɟ ɞɟɣɫɬɜɢɟ ɩ. 2 ɞɥɹ ɫɨɡɞɚɧɢɹ ɟɳɟ ɨɞɧɨɣ ɫɬɪɚɧɢɰɵ.
ɍɠɰɨɩɦɩɞɣɣ ɫɛɢɫɛɜɩɭɥɣ ɪɫɩɞɫɛɧɧɨɩɞɩ ɩɜɠɬɪɠɲɠɨɣɺ. Ɇɛɜ. ɪɫɛɥɭɣɥɮɧ |
-85- |
ɅȺȻ. Ɋ. ʋ 5 ɊȿȺɅ-ə ȺɊɏ-ɕ ɇȺ ȻȺɁȿ ɈȻɔȿɄɌɇɈ-ɊȿɅəɐ. ɈɌɈȻɊȺɀȿɇɂə ɋ ɌɂɉɂɁɂɊɈȼȺɇɇɕɆɂ ɈȻɔȿɄɌȺɆɂ
ȿɩɜɛɝɦɠɨɣɠ ɨɩɝɩɞɩ ɧɩɟɮɦɺ ɝ ɪɫɩɠɥɭ
4.Ⱦɨɛɚɜɶɬɟ ɧɚ ɮɨɪɦɭ ɤɨɦɩɨɧɟɧɬ TDBGrid, ɧɚɫɬɪɨɣɬɟ ɭ ɧɟɝɨ ɫɜɨɣɫɬɜɨ Align ɪɚɜɧɵɦ alTop – ɤɨɦɩɨɧɟɧɬ ɡɚɣɦɟɬ ɜɟɪɯɧɸɸ ɱɚɫɬɶ ɫɬɪɚɧɢɰɵ. Ɍɚɤ ɠɟ ɧɟɨɛɯɨɞɢɦɨ ɧɚɫɬɪɨɢɬɶ ɫɜɨɣɫɬɜɨ Heigth – ɜɵɫɨɬɚ ɤɨɦɩɨɧɟɧɬɚ.
5.ɓɟɥɤɧɢɬɟ ɞɜɚ ɪɚɡɚ ɩɨ ɤɨɦɩɨɧɟɧɬɭ TDBGrid – ɩɨɹɜɢɬɫɹ ɧɨɜɨɟ ɨɤɧɨ
(ɪɢɫ. 5.13).
6.Ⱦɥɹ ɞɨɛɚɜɥɟɧɢɹ ɩɨɥɹ ɧɭɠɧɨ ɜɵɡɜɚɬɶ ɤɨɧɬɟɤɫɬɧɨɟ ɦɟɧɸ, ɜ ɤɨɬɨɪɨɦ ɫɥɟɞɭɟɬ ɜɵɛɪɚɬɶ ɩɭɧɤɬ Add ɢɥɢ ɧɚɠɚɬɶ ɤɧɨɩɤɭ Ins.
7.ȼɵɛɟɪɢɬɟ ɫɨɡɞɚɧɧɨɟ ɩɨɥɟ ɢ ɜ Ɉɛɥɚɫɬɢ ɢɧɫɩɟɤɬɨɪɚ ɧɚɫɬɪɨɣɬɟ ɫɜɨɣɫɬɜɚ Caption (ɧɚɡɜɚɧɢɟ ɫɬɨɥɛɰɚ) ɢ Fieldname (ɧɚɡɜɚɧɢɟ ɨɬɨɛɪɚɠɚɟɦɨɝɨ ɩɨɥɹ).
8.ɉɨɜɬɨɪɢɬɟ ɩ. 6–7 ɫɬɨɥɶɤɨ ɪɚɡ, ɫɤɨɥɶɤɨ ɧɟɨɛɯɨɞɢɦɨ ɫɨɡɞɚɬɶ ɩɨɥɟɣ.
9.Ⱦɨɛɚɜɶɬɟ ɧɚ ɮɨɪɦɭ ɤɨɦɩɨɧɟɧɬ TPanel, ɧɚɫɬɪɨɣɬɟ ɫɜɨɣɫɬɜɨ Align ɪɚɜɧɵɦ alTop – ɤɨɦɩɨɧɟɧɬ ɡɚɣɦɟɬ ɦɟɫɬɨ ɫɪɚɡɭ ɡɚ ɤɨɦɩɨɧɟɧɬɨɦ TDBGrid. Ɉɱɢɫɬɢɬɟ ɫɜɨɣɫɬɜɨ Caption ɭ ɤɨɦɩɨɧɟɧɬɚ TPanel.
10.Ⱦɨɛɚɜɶɬɟ ɧɚ ɮɨɪɦɭ ɤɨɦɩɨɧɟɧɬ TPanel, ɧɚɫɬɪɨɣɬɟ ɫɜɨɣɫɬɜɨ Align ɪɚɜɧɵɦ alButom – ɤɨɦɩɨɧɟɧɬ ɡɚɣɦɟɬ ɦɟɫɬɨ ɜɧɢɡɭ ɫɬɪɚɧɢɰɵ. Ɉɱɢɫɬɢɬɟ ɫɜɨɣɫɬɜɨ Caption ɭ ɤɨɦɩɨɧɟɧɬɚ TPanel.
11.Ⱦɨɛɚɜɶɬɟ ɟɳɟ ɨɞɢɧ ɤɨɦɩɨɧɟɧɬ TDBGrid, ɧɚɫɬɪɨɣɬɟ ɫɜɨɣɫɬɜɨ Align ɪɚɜɧɵɦ alClient – ɤɨɦɩɨɧɟɧɬ ɡɚɣɦɟɬ ɜɫɟ ɫɜɨɛɨɞɧɨɟ ɦɟɫɬɨ ɧɚ ɮɨɪɦɟ.
12.ɇɚɫɬɪɨɣɬɟ ɭ ɤɨɦɩɨɧɟɧɬɚ, ɞɨɛɚɜɥɟɧɧɨɝɨ ɜ ɩ. 11, ɫɬɨɥɛɰɵ ɬɚɤ ɠɟ, ɤɚɤ ɨɩɢɫɚɧɨ ɜ ɩ. 5–8.
Ɋɢɫ. 5.11. ɂɧɬɟɪɮɟɣɫ ɜɵɞɚɱɢ ɫɬɭɞɟɧɬɚɦ ɤɧɢɝ
ɍɠɰɨɩɦɩɞɣɣ ɫɛɢɫɛɜɩɭɥɣ ɪɫɩɞɫɛɧɧɨɩɞɩ ɩɜɠɬɪɠɲɠɨɣɺ. Ɇɛɜ. ɪɫɛɥɭɣɥɮɧ |
-86- |
ɅȺȻ. Ɋ. ʋ 5 ɊȿȺɅ-ə ȺɊɏ-ɕ ɇȺ ȻȺɁȿ ɈȻɔȿɄɌɇɈ-ɊȿɅəɐ. ɈɌɈȻɊȺɀȿɇɂə ɋ ɌɂɉɂɁɂɊɈȼȺɇɇɕɆɂ ɈȻɔȿɄɌȺɆɂ
ȿɩɜɛɝɦɠɨɣɠ ɨɩɝɩɞɩ ɧɩɟɮɦɺ ɝ ɪɫɩɠɥɭ
Ɋɢɫ. 5.12. ɂɧɬɟɪɮɟɣɫ ɪɟɞɚɤɬɢɪɨɜɚɧɢɹ ɫɩɢɫɤɚ ɤɧɢɝ
Ɋɢɫ. 5.13. Ɋɟɞɚɤɬɨɪ ɨɬɨɛɪɚɠɚɟɦɵɯ ɩɨɥɟɣ
13.Ⱦɨɛɚɜɶɬɟ ɧɟɫɤɨɥɶɤɨ ɤɨɦɩɨɧɟɧɬɨɜ TBitBtn ɧɚ ɤɨɦɩɨɧɟɧɬɵ TPanel
ɫɨɝɥɚɫɧɨ ɪɢɫ. 5.11 ɢ ɪɢɫ. 5.12.
14.Ⱦɥɹ ɞɨɛɚɜɥɟɧɢɹ ɩɢɤɬɨɝɪɚɦɦ ɜ ɩɪɨɟɤɬ ɧɭɠɧɨ ɞɨɛɚɜɢɬɶ ɤɨɦɩɨɧɟɧɬ TImageList. Ⱦɨɛɚɜɥɟɧɢɟ ɩɢɤɬɨɝɪɚɦɦɵ ɨɫɭɳɟɫɬɜɥɹɟɬɫɹ ɩɭɬɟɦ ɞɜɨɣɧɨɝɨ ɳɟɥɱɤɚ ɩɨ ɤɨɦɩɨɧɟɧɬɭ TImageList – ɩɨɹɜɢɬɫɹ ɨɤɧɨ ɧɚɫɬɪɨɣɤɢ ɢɡɨɛɪɚɠɟɧɢɣ (ɫɦ. ɪɢɫ. 5.8). ȼ ɷɬɨɦ ɨɤɧɟ ɧɚɠɦɢɬɟ ɤɧɨɩɤɭ Add, ɜ ɩɨɹɜɢɜɲɟɦɫɹ ɞɢɚɥɨɝɟ ɜɵɛɟɪɢɬɟ ɝɪɚɮɢɱɟɫɤɢɣ ɮɚɣɥ ɩɢɤɬɨɝɪɚɦɦɵ.
15.Ⱦɥɹ ɪɟɚɥɢɡɚɰɢɢ ɞɟɣɫɬɜɢɣ ɧɭɠɧɨ ɞɨɛɚɜɢɬɶ ɤɨɦɩɨɧɟɧɬ TActionManager. ɇɚɫɬɪɨɣɬɟ ɫɜɨɣɫɬɜɨ Images, ɯɪɚɧɹɳɟɟ ɩɢɤɬɨɝɪɚɦɦɵ.
16.Ⱦɥɹ ɞɨɛɚɜɥɟɧɢɹ ɞɟɣɫɬɜɢɣ ɧɭɠɧɨ ɞɜɚ ɪɚɡɚ ɳɟɥɤɧɭɬɶ ɩɨ ɤɨɦɩɨɧɟɧɬɭ TActionManager – ɩɨɹɜɢɬɫɹ ɪɟɞɚɤɬɨɪ ɞɟɣɫɬɜɢɣ (ɫɦ. ɪɢɫ. 5.9).
17.Ⱦɥɹ ɞɨɛɚɜɥɟɧɢɹ ɞɟɣɫɬɜɢɹ ɧɭɠɧɨ ɧɚɠɚɬɶ ɤɥɚɜɢɲɭ Ins.
18.Ⱦɥɹ ɧɚɫɬɪɨɣɤɢ ɫɜɨɣɫɬɜɚ ɞɟɣɫɬɜɢɹ ɜɵɛɟɪɢɬɟ ɟɝɨ ɜ ɪɟɞɚɤɬɨɪɟ ɞɟɣɫɬɜɢɣ – ɟɝɨ ɫɜɨɣɫɬɜɚ ɨɬɨɛɪɚɡɹɬɫɹ ɜ Ɉɛɥɚɫɬɢ ɢɧɫɩɟɤɬɨɪɚ. ɋɜɨɣɫɬɜɚ, ɤɨɬɨɪɵɟ ɧɭɠɧɨ ɧɚɫɬɪɨɢɬɶ, ɩɪɟɞɫɬɚɜɥɟɧɵ ɜ ɬɚɛɥ. 5.32.
|
Ɍɚɛɥɢɰɚ 5.32 |
|
|
ɋɜɨɣɫɬɜɚ ɞɟɣɫɬɜɢɹ |
|
|
Ɉɩɢɫɚɧɢɟ |
|
ɋɜɨɣɫɬɜɨ |
|
|
Caption |
Ɉɬɨɛɪɚɠɚɟɦɨɟ ɧɚɡɜɚɧɢɟ |
|
Category |
Ʉɚɬɟɝɨɪɢɹ ɞɟɣɫɬɜɢɹ |
|
Name |
ɂɦɹ ɞɟɣɫɬɜɢɹ |
|
ImageIndex |
ɇɨɦɟɪ ɩɢɤɬɨɝɪɚɦɦɵ ɢɡ ɤɨɦɩɨɧɟɧɬɚ TImageList |
|
|
|
|
|
ɍɠɰɨɩɦɩɞɣɣ ɫɛɢɫɛɜɩɭɥɣ ɪɫɩɞɫɛɧɧɨɩɞɩ ɩɜɠɬɪɠɲɠɨɣɺ. Ɇɛɜ. ɪɫɛɥɭɣɥɮɧ |
-87- |
ɅȺȻ. Ɋ. ʋ 5 ɊȿȺɅ-ə ȺɊɏ-ɕ ɇȺ ȻȺɁȿ ɈȻɔȿɄɌɇɈ-ɊȿɅəɐ. ɈɌɈȻɊȺɀȿɇɂə ɋ ɌɂɉɂɁɂɊɈȼȺɇɇɕɆɂ ɈȻɔȿɄɌȺɆɂ
ȿɩɜɛɝɦɠɨɣɠ ɨɩɝɩɞɩ ɧɩɟɮɦɺ ɝ ɪɫɩɠɥɭ
19.Ɍɚɤɠɟ ɧɟɨɛɯɨɞɢɦɨ ɧɚɫɬɪɨɢɬɶ ɫɨɛɵɬɢɟ, ɩɪɨɢɫɯɨɞɹɳɟɟ ɩɪɢ ɜɵɩɨɥɧɟɧɢɢ ɞɟɣɫɬɜɢɹ. Ⱦɥɹ ɷɬɨɝɨ ɜ Ɉɛɥɚɫɬɢ ɢɧɫɩɟɤɬɨɪɚ ɜɵɛɟɪɢɬɟ ɜɤɥɚɞɤɭ Events
ɢɞɜɚ ɪɚɡɚ ɳɟɥɤɧɢɬɟ ɩɨ ɫɨɛɵɬɢɸ OnExecute – ɩɨɹɜɢɬɫɹ ɪɟɞɚɤɬɨɪ ɤɨɞɚ, ɜ ɤɨɬɨɪɨɦ ɧɭɠɧɨ ɡɚɩɢɫɚɬɶ ɤɨɞ (ɫɦ. ɫ. 83–86).
20.ɇɭɠɧɨ ɫɨɡɞɚɬɶ ɫɬɨɥɶɤɨ ɞɟɣɫɬɜɢɣ, ɫɤɨɥɶɤɨ ɤɧɨɩɨɤ ɧɚ ɮɨɪɦɟ.
21.Ⱦɥɹ ɧɚɡɧɚɱɟɧɢɹ ɞɟɣɫɬɜɢɹ ɤɧɨɩɤɢ ɧɭɠɧɨ ɜɵɞɟɥɢɬɶ ɤɧɨɩɤɭ ɢ ɜ Ɉɛɥɚɫɬɢ ɢɧɫɩɟɤɬɨɪɚ ɧɚɫɬɪɨɢɬɶ ɫɜɨɣɫɬɜɨ Action, ɜɵɛɪɚɜ ɬɨ ɞɟɣɫɬɜɢɟ, ɤɨɬɨɪɨɟ ɞɨɥɠɧɨ ɩɪɨɢɫɯɨɞɢɬɶ ɩɪɢ ɧɚɠɚɬɢɢ ɤɧɨɩɤɢ.
ɇɚɫɬɪɨɣɤɚ ɢɧɬɟɪɮɟɣɫɚ ɨɫɬɚɥɶɧɵɯ ɮɨɪɦ ɜɵɩɨɥɧɹɟɬɫɹ ɩɨ ɷɬɨɦɭ ɠɟ ɩɪɢɧɰɢɩɭ.
Ɏɨɪɦɚ ɪɟɞɚɤɬɢɪɨɜɚɧɢɹ ɩɚɪɚɦɟɬɪɨɜ ɫɬɭɞɟɧɬɚ
ɗɬɚ ɮɨɪɦɚ ɞɨɥɠɧɚ ɩɨɡɜɨɥɹɬɶ ɩɨɥɶɡɨɜɚɬɟɥɸ ɡɚɞɚɜɚɬɶ ɩɚɪɚɦɟɬɪɵ ɫɬɭɞɟɧɬɨɜ ɩɪɢ ɞɨɛɚɜɥɟɧɢɢ ɧɨɜɨɣ ɡɚɩɢɫɢ ɢ ɪɟɞɚɤɬɢɪɨɜɚɧɢɢ ɫɬɚɪɨɣ (ɫɦ. ɪɢɫ. 5.14).
Ɏɨɪɦɚ ɪɟɞɚɤɬɢɪɨɜɚɧɢɹ ɩɚɪɚɦɟɬɪɨɜ ɤɧɢɝ
Ɏɨɪɦɚ ɞɨɥɠɧɚ ɩɨɡɜɨɥɹɬɶ ɩɨɥɶɡɨɜɚɬɟɥɸ ɡɚɞɚɜɚɬɶ ɩɚɪɚɦɟɬɪɵ ɤɧɢɝɢ ɩɪɢ ɪɟɞɚɤɬɢɪɨɜɚɧɢɢ ɢ ɢɡɦɟɧɹɬɶ ɩɚɪɚɦɟɬɪɵ ɫɭɳɟɫɬɜɭɸɳɢɯ ɤɧɢɝ (ɫɦ. ɪɢɫ. 5.15).
Ɋɢɫ. 5.14. Ɏɨɪɦɚ ɪɟɞɚɤɬɢɪɨɜɚɧɢɹ ɩɚɪɚɦɟɬɪɨɜ ɫɬɭɞɟɧɬɚ
Ɋɢɫ. 5.15. Ɏɨɪɦɚ ɪɟɞɚɤɬɢɪɨɜɚɧɢɹ ɩɚɪɚɦɟɬɪɨɜ ɤɧɢɝ
ɍɠɰɨɩɦɩɞɣɣ ɫɛɢɫɛɜɩɭɥɣ ɪɫɩɞɫɛɧɧɨɩɞɩ ɩɜɠɬɪɠɲɠɨɣɺ. Ɇɛɜ. ɪɫɛɥɭɣɥɮɧ |
-88- |
ɅȺȻ. Ɋ. ʋ 5 ɊȿȺɅ-ə ȺɊɏ-ɕ ɇȺ ȻȺɁȿ ɈȻɔȿɄɌɇɈ-ɊȿɅəɐ. ɈɌɈȻɊȺɀȿɇɂə ɋ ɌɂɉɂɁɂɊɈȼȺɇɇɕɆɂ ɈȻɔȿɄɌȺɆɂ
ȿɩɜɛɝɦɠɨɣɠ ɨɩɝɩɞɩ ɧɩɟɮɦɺ ɝ ɪɫɩɠɥɭ
Ɋɢɫ. 5.16. Ɏɨɪɦɚ ɨɬɨɛɪɚɠɟɧɢɹ ɫɩɢɫɤɚ ɤɧɢɝ
Ɏɨɪɦɚ ɨɬɨɛɪɚɠɟɧɢɹ ɫɩɢɫɤɚ ɤɧɢɝ
Ɏɨɪɦɚ ɞɨɥɠɧɚ ɨɬɨɛɪɚɠɚɬɶ ɫɩɢɫɨɤ ɜɫɟɯ ɤɧɢɝ, ɞɥɹ ɬɨɝɨ ɱɬɨɛɵ ɦɨɠɧɨ ɛɵɥɨ ɜɵɛɪɚɬɶ ɤɧɢɝɭ ɩɪɢ ɜɵɞɚɱɟ ɟɟ ɫɬɭɞɟɧɬɭ (ɫɦ. ɪɢɫ. 5.16).
ɉɨɫɥɟ ɫɨɡɞɚɧɢɹ ɮɨɪɦ ɧɟɨɛɯɨɞɢɦɨ ɩɨɞɤɥɸɱɢɬɶ ɤɥɚɫɫɵ. Ⱦɥɹ ɷɬɨɝɨ ɧɭɠɧɨ ɢɯ ɫɨɡɞɚɬɶ ɞɥɹ ɞɚɥɶɧɟɣɲɟɝɨ ɢɫɩɨɥɶɡɨɜɚɧɢɹ.
Ɋɩɟɥɦɹɲɠɨɣɠ ɥɦɛɬɬɩɝ
ɉɨɫɥɟ ɫɨɡɞɚɧɢɹ ɮɨɪɦ ɤ ɢɧɬɟɪɮɟɣɫɭ ɧɭɠɧɨ ɩɨɞɤɥɸɱɢɬɶ ɤɥɚɫɫɵ. Ⱦɥɹ ɷɬɨɝɨ ɜ ɝɥɚɜɧɨɣ ɮɨɪɦɟ ɩɪɨɟɤɬɚ ɪɟɚɥɢɡɭɟɦ ɞɜɚ ɫɨɛɵɬɢɹ:
OnCreate. ɉɨ ɷɬɨɦɭ ɫɨɛɵɬɢɸ ɫɨɡɞɚɟɬɫɹ ɨɛɴɟɤɬ TConnection, ɜɵɩɨɥɧɹɟɬɫɹ ɩɨɞɤɥɸɱɟɧɢɟ ɤ ȻȾ ɢ ɫɨɡɞɚɸɬɫɹ ɨɛɴɟɤɬɵ ɤɥɚɫɫɚ ɛɢɡɧɟɫ-ɥɨɝɢɤɢ;
OnClose. ɉɨ ɷɬɨɦɭ ɫɨɛɵɬɢɸ ɭɞɚɥɹɸɬɫɹ ɜɫɟ ɫɨɡɞɚɧɧɵɟ ɨɛɴɟɤɬɵ. Ⱦɥɹ ɫɨɡɞɚɧɢɹ ɫɨɛɵɬɢɣ:
ɜ Ʉɨɧɫɬɪɭɤɬɨɪɟ ɮɨɪɦ ɜɵɛɟɪɢɬɟ ɨɛɴɟɤɬ, ɞɥɹ ɤɨɬɨɪɨɝɨ ɜɵ ɯɨɬɢɬɟ ɫɨɡɞɚɬɶ ɫɨɛɵɬɢɟ;
ɨɬɤɪɨɣɬɟ ɜɤɥɚɞɤɭ Events ɜ Ɉɛɥɚɫɬɢ ɢɧɫɩɟɤɬɨɪɚ;
ɧɚɣɞɢɬɟ ɬɪɟɛɭɟɦɨɟ ɫɨɛɵɬɢɟ ɢ ɞɜɚɠɞɵ ɳɟɥɤɧɢɬɟ ɩɨ ɧɟɦɭ. ɉɪɢ ɷɬɨɦ ɨɬɤɪɨɟɬɫɹ ɪɟɞɚɤɬɨɪ ɢɫɯɨɞɧɨɝɨ ɤɨɞɚ ɧɚ ɦɟɫɬɟ ɬɨɥɶɤɨ ɱɬɨ ɫɨɡɞɚɧɧɨɝɨ ɫɨɛɵɬɢɹ.
ɉ ɪ ɢ ɦ ɟ ɪ ɤ ɨ ɞ ɚ ɞ ɥ ɹ ɫ ɨ ɛ ɵ ɬ ɢ ɹ O n C r e a t e
var
//Ɉɛɴɹɜɥɟɧɢɟ ɩɟɪɟɦɟɧɧɨɣ ɤɥɚɫɫɚ ɩɨ ɪɚɛɨɬɟ ɫ ini-ɮɚɣɥɚɦɢ ini: tinifile;
// Ɉɛɴɹɜɥɟɧɢɟ ɩɟɪɟɦɟɧɧɵɯ ɞɥɹ ɯɪɚɧɟɧɢɹ ɩɚɪɚɦɟɬɪɨɜ ɩɨɞɤɥɸɱɟɧɢɹ
servername, path: string; begin
ɍɠɰɨɩɦɩɞɣɣ ɫɛɢɫɛɜɩɭɥɣ ɪɫɩɞɫɛɧɧɨɩɞɩ ɩɜɠɬɪɠɲɠɨɣɺ. Ɇɛɜ. ɪɫɛɥɭɣɥɮɧ |
-89- |
ɅȺȻ. Ɋ. ʋ 5 ɊȿȺɅ-ə ȺɊɏ-ɕ ɇȺ ȻȺɁȿ ɈȻɔȿɄɌɇɈ-ɊȿɅəɐ. ɈɌɈȻɊȺɀȿɇɂə ɋ ɌɂɉɂɁɂɊɈȼȺɇɇɕɆɂ ɈȻɔȿɄɌȺɆɂ
ȿɩɜɛɝɦɠɨɣɠ ɨɩɝɩɞɩ ɧɩɟɮɦɺ ɝ ɪɫɩɠɥɭ
try
//ɉɨɞɤɥɸɱɟɧɢɟ ɤ ini–ɮɚɣɥɭ
ini:=TIniFile.Create(ExtractFilePath(Application.ExeName)+'
config.ini');
// ɑɬɟɧɢɟ ɢɦɟɧɢ ɫɟɪɜɟɪɚ, ɤ ɤɨɬɨɪɨɦɭ ɧɟɨɛɯɨɞɢɦɨ ɩɨɞɤɥɸɱɢɬɶɫɹ if ini.ReadString('options','servername','')='' then begin
servername:='localhost'; //Ɉɬɨɛɪɚɠɟɧɢɟ ɞɢɚɥɨɝɚ ɜɜɨɞɚ ɢɦɟɧɢ ɫɟɪɜɟɪɚ
if InputQuery('ȼɜɟɞɢɬɟ ɢɦɹ ɫɟɪɜɟɪɚ','',servername)
then
begin
// Ɂɚɩɢɫɶ ɢɦɟɧɢ ɫɟɪɜɟɪɚ ɜ ini-ɮɚɣɥ ini.WriteString('options','servername',servername);
end;
end;
//ɑɬɟɧɢɟ ɢɦɟɧɢ ɫɟɪɜɟɪɚ servername:=ini.ReadString('options','servername','');
//ɑɬɟɧɢɟ ɩɭɬɢ ɤ ɮɚɣɥɭ ȻȾ, ɟɫɥɢ ɨɧ ɩɭɫɬ
if ini.ReadString('options','path','')='' then begin
// ȼɵɜɨɞ ɞɢɚɥɨɝɚ ɜɜɨɞɚ ɩɭɬɢ ɤ ɮɚɣɥɭ ȻȾ
if InputQuery('ȼɜɟɞɢɬɟ ɩɭɬɶ ɤ ɮɚɣɥɭ ȻȾ','',path) then begin
// Ɂɚɩɢɫɶ ɩɭɬɢ ɤ ɮɚɣɥɭ ȻȾ ɜ ini-ɮɚɣɥ ini.WriteString('options','path',path);
end;
end;
//ɑɬɟɧɢɟ ɩɭɬɢ ɤ ɮɚɣɥɭ ȻȾ ɢɡ ini-ɮɚɣɥɚ path:=ini.ReadString('options','path',''); try
//ɋɨɡɞɚɧɢɟ ɨɛɴɟɤɬɚ ɩɨɞɤɥɸɱɟɧɢɹ fConnection:=TConnection.Create;
//ɍɫɬɚɧɨɜɤɚ ɩɚɪɚɦɟɬɪɨɜ ɩɨɞɤɥɸɱɟɧɢɹ fConnection.ServerName:=servername; fConnection.DataBaseName:=path; fConnection.UserName:='SYSDBA'; fConnection.Password:='masterkey';
//ɉɨɞɤɥɸɱɟɧɢɟ ɤ ȻȾ
ɍɠɰɨɩɦɩɞɣɣ ɫɛɢɫɛɜɩɭɥɣ ɪɫɩɞɫɛɧɧɨɩɞɩ ɩɜɠɬɪɠɲɠɨɣɺ. Ɇɛɜ. ɪɫɛɥɭɣɥɮɧ |
-90- |