SearchFme.pas 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. unit SearchFme;
  2. interface
  3. uses
  4. SearchDm,
  5. Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  6. Dialogs, StdCtrls, ExtCtrls, ZjGridDBA, ZJGrid, JimLabels;
  7. type
  8. TSearchFrame = class(TFrame)
  9. zaSearchResult: TZjGridDBA;
  10. pnlTitle: TPanel;
  11. labTitle: TJimGradLabel;
  12. pnlSearch: TPanel;
  13. pnlSearchType: TPanel;
  14. gbType: TGroupBox;
  15. rbOverRange: TRadioButton;
  16. rbCommon: TRadioButton;
  17. pnlSearchKey: TPanel;
  18. edtKeyword: TEdit;
  19. btnSearch: TButton;
  20. pnlSearchResult: TPanel;
  21. zgSearchResult: TZJGrid;
  22. rbBelowRange: TRadioButton;
  23. rbRelaFile: TRadioButton;
  24. procedure rbCommonClick(Sender: TObject);
  25. procedure btnSearchClick(Sender: TObject);
  26. procedure zgSearchResultMouseDown(Sender: TObject;
  27. Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
  28. private
  29. FSearchData: TSearchData;
  30. FLocateType: TLocateType;
  31. public
  32. constructor Create(AParent: TFrame; ASearchData: TSearchData);
  33. destructor Destroy; override;
  34. property LocateType: TLocateType read FLocateType write FLocateType;
  35. end;
  36. implementation
  37. {$R *.dfm}
  38. { TSearchFrame }
  39. constructor TSearchFrame.Create(AParent: TFrame; ASearchData: TSearchData);
  40. begin
  41. inherited Create(AParent);
  42. FSearchData := ASearchData;
  43. zaSearchResult.DataSet := FSearchData.cdsSearch;
  44. end;
  45. destructor TSearchFrame.Destroy;
  46. begin
  47. inherited;
  48. end;
  49. procedure TSearchFrame.rbCommonClick(Sender: TObject);
  50. begin
  51. edtKeyword.Enabled := rbCommon.Checked;
  52. {if rbCommon.Checked then
  53. zaSearchResult.Column('Code').Width := 80
  54. else
  55. zaSearchResult.Column('Code').Width := 0;}
  56. end;
  57. procedure TSearchFrame.btnSearchClick(Sender: TObject);
  58. begin
  59. if rbCommon.Checked then
  60. FSearchData.SearchKeyword(edtKeyword.Text)
  61. else if rbOverRange.Checked then
  62. FSearchData.SearchOverRange
  63. else if rbBelowRange.Checked then
  64. FSearchData.SearchBelowRange
  65. else if rbRelaFile.Checked then
  66. FSearchData.SearchRelaFile;
  67. end;
  68. procedure TSearchFrame.zgSearchResultMouseDown(Sender: TObject;
  69. Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
  70. begin
  71. if (Button = mbLeft) and (ssDouble in Shift) then
  72. FSearchData.LocateCurrent(LocateType);
  73. end;
  74. end.