Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- unit UnitChangeWord;
- interface
- uses
- Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
- Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Vcl.ExtCtrls;
- type
- TFormChangeWord = class(TForm)
- EditEnglishWord: TEdit;
- LabelEnglishWord: TLabel;
- LabelRussianWord: TLabel;
- EditRussianWord: TEdit;
- ButtonOk: TButton;
- ButtonCancel: TButton;
- PanelRadioGroup: TPanel;
- RadioGroupPartsOfSpeech: TRadioGroup;
- procedure ButtonOkClick(Sender: TObject);
- procedure ButtonCancelClick(Sender: TObject);
- procedure EditEnglishWordKeyPress(Sender: TObject; var Key: Char);
- procedure EditEnglishWordChange(Sender: TObject);
- procedure EditRussianWordChange(Sender: TObject);
- procedure RadioGroupPartsOfSpeechClick(Sender: TObject);
- procedure EditRussianWordKeyPress(Sender: TObject; var Key: Char);
- private
- { Private declarations }
- public
- { Public declarations }
- end;
- var
- FormChangeWord: TFormChangeWord;
- implementation
- {$R *.dfm}
- procedure TFormChangeWord.ButtonCancelClick(Sender: TObject);
- begin
- EditEnglishWord.Text := '';
- EditRussianWord.Text := '';
- ModalResult := mrCancel;
- end;
- procedure TFormChangeWord.ButtonOkClick(Sender: TObject);
- begin
- ModalResult := mrOk;
- end;
- procedure TFormChangeWord.EditEnglishWordChange(Sender: TObject);
- begin
- if (EditRussianWord.Text <> '') and (EditEnglishWord.Text <> '') and (RadioGroupPartsOfSpeech.ItemIndex <> -1) then
- begin
- ButtonOk.Enabled := true;
- end
- else
- begin
- ButtonOk.Enabled := false;
- end;
- end;
- procedure TFormChangeWord.EditEnglishWordKeyPress(Sender: TObject;
- var Key: Char);
- var
- EditLength: Integer;
- begin
- EditLength := Length(EditEnglishWord.Text);
- if not(Key in [#96..#122, #8, #45, #28, ' ']) then
- Key := #0;
- if (EditLength = 0) and ((Key = '-') or (Key = ' ')) then
- Key := #0;
- if (EditLength > 0) and (EditEnglishWord.Text[EditLength] in ['-', ' ']) and (Key in ['-', ' ']) then
- Key := #0;
- end;
- procedure TFormChangeWord.EditRussianWordChange(Sender: TObject);
- begin
- if (EditRussianWord.Text <> '') and (EditEnglishWord.Text <> '') and (RadioGroupPartsOfSpeech.ItemIndex <> -1) then
- begin
- ButtonOk.Enabled := true;
- end
- else
- begin
- ButtonOk.Enabled := false;
- end;
- end;
- procedure TFormChangeWord.EditRussianWordKeyPress(Sender: TObject;
- var Key: Char);
- var
- EditLength: Integer;
- begin
- EditLength := Length(EditRussianWord.Text);
- if ((Key < #224) or (Key > #255)) and not(Key in [#8, #45, #28, ' ']) then
- Key := #0;
- if (EditLength = 0) and (Key in ['-', ' ']) then
- Key := #0;
- if (EditLength > 0) and (EditRussianWord.Text[EditLength] in ['-', ' ']) and (Key in ['-', ' ']) then
- Key := #0;
- end;
- procedure TFormChangeWord.RadioGroupPartsOfSpeechClick(Sender: TObject);
- begin
- if (EditRussianWord.Text <> '') and (EditEnglishWord.Text <> '') and (RadioGroupPartsOfSpeech.ItemIndex <> -1) then
- begin
- ButtonOk.Enabled := true;
- end
- else
- begin
- ButtonOk.Enabled := false;
- end;
- end;
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement