Advertisement
ksyshshot

курсач 7

May 28th, 2023
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Delphi 3.21 KB | Source Code | 0 0
  1. unit UnitChangeWord;
  2.  
  3. interface
  4.  
  5. uses
  6.   Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  7.   Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Vcl.ExtCtrls;
  8.  
  9. type
  10.   TFormChangeWord = class(TForm)
  11.     EditEnglishWord: TEdit;
  12.     LabelEnglishWord: TLabel;
  13.     LabelRussianWord: TLabel;
  14.     EditRussianWord: TEdit;
  15.     ButtonOk: TButton;
  16.     ButtonCancel: TButton;
  17.     PanelRadioGroup: TPanel;
  18.     RadioGroupPartsOfSpeech: TRadioGroup;
  19.     procedure ButtonOkClick(Sender: TObject);
  20.     procedure ButtonCancelClick(Sender: TObject);
  21.     procedure EditEnglishWordKeyPress(Sender: TObject; var Key: Char);
  22.     procedure EditEnglishWordChange(Sender: TObject);
  23.     procedure EditRussianWordChange(Sender: TObject);
  24.     procedure RadioGroupPartsOfSpeechClick(Sender: TObject);
  25.     procedure EditRussianWordKeyPress(Sender: TObject; var Key: Char);
  26.   private
  27.     { Private declarations }
  28.   public
  29.     { Public declarations }
  30.   end;
  31.  
  32. var
  33.   FormChangeWord: TFormChangeWord;
  34.  
  35. implementation
  36.  
  37. {$R *.dfm}
  38.  
  39. procedure TFormChangeWord.ButtonCancelClick(Sender: TObject);
  40. begin
  41.     EditEnglishWord.Text := '';
  42.     EditRussianWord.Text := '';
  43.     ModalResult := mrCancel;
  44. end;
  45.  
  46. procedure TFormChangeWord.ButtonOkClick(Sender: TObject);
  47. begin
  48.     ModalResult := mrOk;
  49. end;
  50.  
  51. procedure TFormChangeWord.EditEnglishWordChange(Sender: TObject);
  52. begin
  53.     if (EditRussianWord.Text <> '') and (EditEnglishWord.Text <> '') and (RadioGroupPartsOfSpeech.ItemIndex <> -1) then
  54.     begin
  55.         ButtonOk.Enabled := true;
  56.     end
  57.     else
  58.     begin
  59.         ButtonOk.Enabled := false;
  60.     end;
  61. end;
  62.  
  63. procedure TFormChangeWord.EditEnglishWordKeyPress(Sender: TObject;
  64.   var Key: Char);
  65. var
  66.     EditLength: Integer;
  67. begin
  68.     EditLength := Length(EditEnglishWord.Text);
  69.     if not(Key in [#96..#122, #8, #45, #28, ' ']) then
  70.         Key := #0;
  71.     if (EditLength = 0) and ((Key = '-') or (Key = ' ')) then
  72.         Key := #0;
  73.     if (EditLength > 0) and (EditEnglishWord.Text[EditLength] in ['-', ' ']) and (Key in ['-', ' ']) then
  74.         Key := #0;
  75. end;
  76.  
  77. procedure TFormChangeWord.EditRussianWordChange(Sender: TObject);
  78. begin
  79.     if (EditRussianWord.Text <> '') and (EditEnglishWord.Text <> '') and (RadioGroupPartsOfSpeech.ItemIndex <> -1) then
  80.     begin
  81.         ButtonOk.Enabled := true;
  82.     end
  83.     else
  84.     begin
  85.         ButtonOk.Enabled := false;
  86.     end;
  87. end;
  88.  
  89. procedure TFormChangeWord.EditRussianWordKeyPress(Sender: TObject;
  90.   var Key: Char);
  91. var
  92.     EditLength: Integer;
  93. begin
  94.     EditLength := Length(EditRussianWord.Text);
  95.     if ((Key < #224) or (Key > #255)) and not(Key in [#8, #45, #28, ' ']) then
  96.         Key := #0;
  97.     if (EditLength = 0) and (Key in ['-', ' ']) then
  98.         Key := #0;
  99.     if (EditLength > 0) and (EditRussianWord.Text[EditLength] in ['-', ' ']) and (Key in ['-', ' ']) then
  100.         Key := #0;
  101. end;
  102.  
  103. procedure TFormChangeWord.RadioGroupPartsOfSpeechClick(Sender: TObject);
  104. begin
  105.     if (EditRussianWord.Text <> '') and (EditEnglishWord.Text <> '') and (RadioGroupPartsOfSpeech.ItemIndex <> -1) then
  106.     begin
  107.         ButtonOk.Enabled := true;
  108.     end
  109.     else
  110.     begin
  111.         ButtonOk.Enabled := false;
  112.     end;
  113. end;
  114.  
  115. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement