home *** CD-ROM | disk | FTP | other *** search
/ PC Plus SuperCD (UK) 2000 May / PCP163A.iso / Runimage / Cbuilder4 / Examples / Apps / ScrollBa / MAIN.CPP next >
Encoding:
C/C++ Source or Header  |  1999-01-26  |  4.0 KB  |  107 lines

  1. //----------------------------------------------------------------------------
  2. //Borland C++Builder
  3. //Copyright (c) 1987, 1998 Borland International Inc. All Rights Reserved.
  4. //----------------------------------------------------------------------------
  5. //---------------------------------------------------------------------------
  6. #include <vcl.h>
  7. #pragma hdrstop
  8.  
  9. #include "main.h"
  10. #include <stdlib.h>
  11. //---------------------------------------------------------------------------
  12. #pragma resource "*.dfm"
  13. TForm1 *Form1;
  14. //---------------------------------------------------------------------------
  15. __fastcall TForm1::TForm1(TComponent* Owner)
  16.     : TForm(Owner)
  17. {
  18. }
  19. //---------------------------------------------------------------------------
  20. void __fastcall TForm1::ScrollBar1Scroll(TObject *Sender,
  21.     TScrollCode ScrollCode, int &ScrollPos)
  22. {
  23.     char buf[5];
  24.     PosEdit->Text = itoa(ScrollBar1->Position, buf, 10);
  25.  
  26.     switch (ScrollCode)
  27.     {
  28.         case scLineUp:
  29.             Label2->Caption = "User clicked the top or left scroll arrow or presses the Up arrow key.";
  30.             break;
  31.         case scLineDown:
  32.             Label2->Caption = "User clicked the bottom or right scroll arrow or pressed the Down arrow key.";
  33.             break;
  34.         case scPageUp:
  35.             Label2->Caption = "User clicked the area to the left of the thumb tab or pressed the PgUp key.";
  36.             break;
  37.         case scPageDown:
  38.             Label2->Caption = "User clicked the area to the right of the thumb tab or pressed the PgDn key.";
  39.             break;
  40.         case scPosition:
  41.             Label2->Caption = "User positioned the thumb tab and released it.";
  42.             break;
  43.         case scTrack:
  44.             Label2->Caption = "User is moving the thumb tab.";
  45.             break;
  46.         case scTop:
  47.             Label2->Caption = "User moved the thumb tab to the top or far left on the scroll bar.";
  48.             break;
  49.         case scBottom:
  50.             Label2->Caption = "User moved the thumb tab to the bottom or far right on the scroll bar.";
  51.             break;
  52.         case scEndScroll:
  53.             Label2->Caption = "User is done moving the thumb tab on the scroll bar.";
  54.             break;
  55.         default:
  56.             break;
  57.     }
  58. }
  59. //---------------------------------------------------------------------------
  60. void __fastcall TForm1::Button1Click(TObject *Sender)
  61. {
  62.     char buf[5];
  63.  
  64.     if (atoi(PosEdit->Text.c_str()))
  65.         ScrollBar1->Position = atoi(PosEdit->Text.c_str());
  66.     else
  67.         PosEdit->Text = itoa(ScrollBar1->Position, buf, 10);
  68.  
  69.     if (atoi(MinEdit->Text.c_str()))
  70.         ScrollBar1->Min = atoi(MinEdit->Text.c_str());
  71.     else
  72.         MinEdit->Text = itoa(ScrollBar1->Min, buf, 10);
  73.  
  74.     if (atoi(MaxEdit->Text.c_str()))
  75.         ScrollBar1->Max = atoi(MaxEdit->Text.c_str());
  76.     else
  77.         MaxEdit->Text = itoa(ScrollBar1->Max, buf, 10);
  78.  
  79.     if (atoi(LargeEdit->Text.c_str()))
  80.         ScrollBar1->LargeChange = (short) atoi(LargeEdit->Text.c_str());
  81.     else
  82.         LargeEdit->Text = itoa(ScrollBar1->LargeChange, buf, 10);
  83.  
  84.     if (atoi(SmallEdit->Text.c_str()))
  85.         ScrollBar1->SmallChange = (short) atoi(SmallEdit->Text.c_str());
  86.     else
  87.         SmallEdit->Text = itoa(ScrollBar1->SmallChange, buf, 10);
  88.         
  89.     Button1->Enabled = false;
  90. }
  91. //---------------------------------------------------------------------------
  92. void __fastcall TForm1::FormCreate(TObject *Sender)
  93. {
  94.     char buf[5];
  95.     PosEdit->Text = itoa(ScrollBar1->Position, buf, 10);
  96.     MinEdit->Text = itoa(ScrollBar1->Min, buf, 10);
  97.     MaxEdit->Text = itoa(ScrollBar1->Max, buf, 10);
  98.     LargeEdit->Text = itoa(ScrollBar1->LargeChange, buf, 10);
  99.     SmallEdit->Text = itoa(ScrollBar1->SmallChange, buf, 10);
  100. }
  101. //---------------------------------------------------------------------------
  102. void __fastcall TForm1::EnableButton(TObject *Sender, char &Key)
  103. {
  104.     Button1->Enabled = true;
  105. }
  106. //---------------------------------------------------------------------------
  107.