home *** CD-ROM | disk | FTP | other *** search
/ Delphi 4 Bible / Delphi_4_Bible_Tom_Swan_IDG_Books_1998.iso / source / SPINBUTT / MAIN.PAS < prev    next >
Pascal/Delphi Source File  |  1998-04-13  |  1KB  |  73 lines

  1. unit Main;
  2.  
  3. interface
  4.  
  5. uses
  6.   SysUtils, Windows, Messages, Classes, Graphics, Controls,
  7.   Forms, Dialogs, Spin, StdCtrls, ExtCtrls, Buttons;
  8.  
  9. type
  10.   TMainForm = class(TForm)
  11.     SpinButton1: TSpinButton;
  12.     Label1: TLabel;
  13.     SpinEdit1: TSpinEdit;
  14.     SpinEdit: TLabel;
  15.     SpinLabel: TLabel;
  16.     BitBtn1: TBitBtn;
  17.     Bevel1: TBevel;
  18.     Bevel2: TBevel;
  19.     BitBtn2: TBitBtn;
  20.     procedure FormCreate(Sender: TObject);
  21.     procedure SpinButton1DownClick(Sender: TObject);
  22.     procedure SpinButton1UpClick(Sender: TObject);
  23.     procedure BitBtn1Click(Sender: TObject);
  24.     procedure SetSpinButtonCaption;
  25.   private
  26.     { Private declarations }
  27.     Count: Integer;
  28.   public
  29.     { Public declarations }
  30.   end;
  31.  
  32. var
  33.   MainForm: TMainForm;
  34.  
  35. implementation
  36.  
  37. {$R *.DFM}
  38.  
  39. const
  40.   minCount = -99;
  41.   maxCount = 99;
  42.  
  43. procedure TMainForm.SetSpinButtonCaption;
  44. begin
  45.   SpinLabel.Caption := IntToStr(Count);
  46. end;
  47.  
  48. procedure TMainForm.FormCreate(Sender: TObject);
  49. begin
  50.   Count := 0;
  51. end;
  52.  
  53. procedure TMainForm.SpinButton1DownClick(Sender: TObject);
  54. begin
  55.   if Count > minCount then Dec(Count);
  56.   SetSpinButtonCaption;
  57. end;
  58.  
  59. procedure TMainForm.SpinButton1UpClick(Sender: TObject);
  60. begin
  61.   if Count < maxCount then Inc(Count);
  62.   SetSpinButtonCaption;
  63. end;
  64.  
  65. procedure TMainForm.BitBtn1Click(Sender: TObject);
  66. begin
  67.   Count := 0;
  68.   SetSpinButtonCaption;
  69. end;
  70.  
  71. end.
  72.  
  73.