home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1998 January / Pcwk0198.iso / Dcomplib / ALPHAPNL.LZH / AP_TESTM.PAS < prev    next >
Pascal/Delphi Source File  |  1995-05-22  |  3KB  |  106 lines

  1. unit Ap_testm;
  2.  
  3. interface
  4.  
  5. uses
  6.   SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
  7.   Forms, Dialogs, StdCtrls, ExtCtrls, Alphabar, DB, DBTables, Grids,
  8.   DBGrids, Menus;
  9.  
  10. type
  11.   TMainform = class(TForm)
  12.     EmployeeTable: TTable;
  13.     DataSource1: TDataSource;
  14.     DBGrid1: TDBGrid;
  15.     EmployeeTableLastName: TStringField;
  16.     EmployeeTableFirstName: TStringField;
  17.     EmployeeTableSalary: TFloatField;
  18.     PanelKind: TRadioGroup;
  19.     Bevel1: TBevel;
  20.     Bevel2: TBevel;
  21.     Label1: TLabel;
  22.     Label2: TLabel;
  23.     SymbolEdit: TEdit;
  24.     SymbolPanel: TAlphaPanel;
  25.     AlphaPanel: TAlphaPanel;
  26.     PopupMenu1: TPopupMenu;
  27.     pomIndexPanel: TMenuItem;
  28.     pomFilterPanel: TMenuItem;
  29.     procedure PanelKindClick(Sender: TObject);
  30.     procedure AlphaPanelValueChange(Sender: TObject);
  31.     procedure pomIndexPanelClick(Sender: TObject);
  32.     procedure pomFilterPanelClick(Sender: TObject);
  33.     procedure SymbolPanelValueChange(Sender: TObject);
  34.   private
  35.     { Private-Deklarationen }
  36.   public
  37.     { Public-Deklarationen }
  38.   end;
  39.  
  40. var
  41.   Mainform: TMainform;
  42.  
  43. implementation
  44.  
  45. {$R *.DFM}
  46.  
  47. procedure TMainform.PanelKindClick(Sender: TObject);
  48. begin
  49.   case PanelKind.ItemIndex of
  50.     0 : begin {** Index panel }
  51.           EmployeeTable.CancelRange;
  52.           AlphaPanel.CatchButtons := false;
  53.           AlphaPanel.Hint := 'click to move the table cursor';
  54.         end;
  55.     1 : begin {** Filter panel }
  56.           AlphaPanel.CatchButtons := true;
  57.           AlphaPanel.ActiveButton := #0;
  58.           AlphaPanel.Hint := 'click to activate/deactivate a filter';
  59.         end;
  60.   end;
  61. end;
  62.  
  63. procedure TMainform.AlphaPanelValueChange(Sender: TObject);
  64. begin
  65.   case PanelKind.ItemIndex of
  66.     0 : EmployeeTable.FindNearest([AlphaPanel.ActiveButton]);
  67.     1 : begin
  68.           if AlphaPanel.ActiveButton = #0 then
  69.           begin
  70.             EmployeeTable.CancelRange;
  71.             EmployeeTable.First;
  72.           end
  73.           else
  74.             with EmployeeTable do
  75.             begin
  76.               EditRangeStart;
  77.               FieldByName('LastName').AsString := AlphaPanel.ActiveButton;
  78.               EditRangeEnd;
  79.               FieldByName('LastName').AsString := chr(ord(AlphaPanel.ActiveButton) + 1);
  80.               ApplyRange;
  81.             end;
  82.         end;
  83.   end;
  84. end;
  85.  
  86. procedure TMainform.pomIndexPanelClick(Sender: TObject);
  87. begin
  88.   pomIndexPanel.Checked := true;
  89.   pomFilterPanel.Checked := false;
  90.   PanelKind.ItemIndex := 0;
  91. end;
  92.  
  93. procedure TMainform.pomFilterPanelClick(Sender: TObject);
  94. begin
  95.   pomIndexPanel.Checked := false;
  96.   pomFilterPanel.Checked := true;
  97.   PanelKind.ItemIndex := 1;
  98. end;
  99.  
  100. procedure TMainform.SymbolPanelValueChange(Sender: TObject);
  101. begin
  102.   SymbolEdit.Text := SymbolEdit.Text + SymbolPanel.ActiveButton;
  103. end;
  104.  
  105. end.
  106.