Advertisement
gguuppyy

SearchUnit

May 4th, 2024
34
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.20 KB | None | 0 0
  1. Unit SearchUnit;
  2.  
  3. Interface
  4.  
  5. Uses
  6. Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants,
  7. System.Classes, Vcl.Graphics,
  8. Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls,
  9. CandidateListUnit, PartyUnit, NameComponentUnit;
  10.  
  11. Type
  12. TSearchForm = Class(TForm)
  13. TitleLabel: TLabel;
  14. SearchEdit: TEdit;
  15. SearchButton: TButton;
  16.  
  17. Procedure CreateParams(Var Params: TCreateParams); override;
  18. Function FormHelp(Command: Word; Data: NativeInt; Var CallHelp: Boolean): Boolean;
  19. Procedure FormKeyDown(Sender: TObject; Var Key: Word; Shift: TShiftState);
  20.  
  21. Procedure SearchEditChange(Sender: TObject);
  22. Procedure SearchEditContextPopup(Sender: TObject; MousePos: TPoint; Var Handled: Boolean);
  23. Procedure SearchEditKeyDown(Sender: TObject; Var Key: Word; Shift: TShiftState);
  24. Procedure SearchEditKeyPress(Sender: TObject; Var Key: Char);
  25. Procedure SearchEditKeyUp(Sender: TObject; Var Key: Word; Shift: TShiftState);
  26.  
  27. Procedure SearchButtonClick(Sender: TObject);
  28.  
  29. Private
  30. { Private declarations }
  31. Public
  32. { Public declarations }
  33. End;
  34.  
  35. Var
  36. SearchForm: TSearchForm;
  37. PartyName: TPartyName;
  38.  
  39. Implementation
  40.  
  41. {$R *.dfm}
  42.  
  43. Uses
  44. MenuUnit;
  45.  
  46. Procedure TSearchForm.CreateParams(Var Params: TCreateParams);
  47. Begin
  48. Inherited;
  49. Params.ExStyle := Params.ExStyle Or WS_EX_APPWINDOW;
  50. End;
  51.  
  52. Function TSearchForm.FormHelp(Command: Word; Data: NativeInt; Var CallHelp: Boolean): Boolean;
  53. Begin
  54. CallHelp := False;
  55. FormHelp := False;
  56. End;
  57.  
  58. Procedure TSearchForm.FormKeyDown(Sender: TObject; Var Key: Word; Shift: TShiftState);
  59. Begin
  60. If Key = VK_ESCAPE Then
  61. Close;
  62. End;
  63.  
  64.  
  65. Procedure TSearchForm.SearchEditChange(Sender: TObject);
  66. Begin
  67. PartyName := TPartyName(Trim(SearchEdit.Text));
  68. SearchButton.Enabled := Trim(SearchEdit.Text) <> '';
  69. End;
  70.  
  71. Procedure TSearchForm.SearchEditContextPopup(Sender: TObject; MousePos: TPoint; Var Handled: Boolean);
  72. Begin
  73. NameComponentContextPopup(SearchEdit.Text, SearchEdit.SelStart, SearchEdit.SelLength, MAX_PARTY_NAME_LENGTH, Handled);
  74. End;
  75.  
  76. Procedure TSearchForm.SearchEditKeyDown(Sender: TObject; Var Key: Word; Shift: TShiftState);
  77. Begin
  78. NameComponentKeyDown(SearchEdit.Text, SearchEdit.SelStart, SearchEdit.SelLength, MAX_PARTY_NAME_LENGTH, Key, Shift);
  79. End;
  80.  
  81. Procedure TSearchForm.SearchEditKeyPress(Sender: TObject; Var Key: Char);
  82. Begin
  83. If Key = ENTER Then
  84. SearchButtonClick(SearchButton)
  85. Else
  86. NameComponentKeyPress(SearchEdit.Text, SearchEdit.SelStart, SearchEdit.SelLength, MAX_PARTY_NAME_LENGTH, Key);
  87. End;
  88.  
  89. Procedure TSearchForm.SearchEditKeyUp(Sender: TObject; Var Key: Word; Shift: TShiftState);
  90. Begin
  91. NameComponentKeyUp();
  92. End;
  93.  
  94.  
  95. Procedure TSearchForm.SearchButtonClick(Sender: TObject);
  96. Begin
  97. If IsExistParty(CandidateList, PartyName) Then
  98. Begin
  99. PartyForm := TPartyForm.Create(Self);
  100. PartyForm.Icon := SearchForm.Icon;
  101. PartyForm.ShowModal;
  102. End
  103. Else
  104. Application.MessageBox('Такой партии не найдено!', 'Предупреждение', MB_OK + MB_ICONWARNING)
  105. End;
  106.  
  107. End.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement