RAD Studio VCL Reference
|
Specifies the upper limit of the range of possible positions.
property Max: Integer;
__property int Max;
Use Max along with the Min property to establish the range of possible positions a progress bar. When the process tracked by the progress bar is complete, the value of Position should equal Max.
C++ Examples:
/* This example requires two ProgressBars, two labels and a Memo. The ProgressBar and the label captions are updated as the mouse moves inside the Memo. */ void __fastcall TForm1::FormCreate(TObject *Sender) { ProgressBar1->Min = 0; ProgressBar1->Max = Memo1->Width; ProgressBar2->Min = 0; ProgressBar1->Max = Memo1->Height; } void __fastcall TForm1::Memo1MouseMove(TObject *Sender, TShiftState Shift, int X, int Y) { Label1->Caption = IntToStr(X); Label2->Caption = IntToStr(Y); ProgressBar1->Position = X; ProgressBar2->Position = Y; }
/* Reads through all records in the Customers table. Updates the ProgressBar accordingly. */ void __fastcall TForm1::Button1Click(TObject *Sender) { ProgressBar1->Min = 0; ProgressBar1->Max = Customers->RecordCount; Customers->First(); for (int i = ProgressBar1->Min; i <= ProgressBar1->Max; i++) { ProgressBar1->Position = i; Customers->Next(); // do something with the current record } } void __fastcall TForm1::FormCreate(TObject *Sender) { Customers = new TTable(Form1); // The owner will clean this up. Customers->Active = false; // The Table component must not be active Customers->DatabaseName = "DBDEMOS"; Customers->TableType = ttParadox; Customers->TableName = "CustInfo"; Customers->Active = False; if (Customers->Exists) // Don't overwrite an existing table { Customers->Close(); Customers->DeleteTable(); } // The Table component must not be active // First, describe the type of table and give // it a name // Next, describe the fields in the table Customers->FieldDefs->Clear(); TFieldDef *pNewDef = Customers->FieldDefs->AddFieldDef(); pNewDef->Name = "Field1"; pNewDef->DataType = ftInteger; pNewDef->Required = true; pNewDef = Customers->FieldDefs->AddFieldDef(); pNewDef->Name = "Field2"; pNewDef->DataType = ftString; pNewDef->Size = 30; // Next, describe any indexes Customers->IndexDefs->Clear(); /* the 1st index has no name because it is a Paradox primary key */ Customers->IndexDefs->Add("","Field1", TIndexOptions() <<ixPrimary << ixUnique); Customers->IndexDefs->Add("Fld2Index","Field2", TIndexOptions() << ixCaseInsensitive); // Now that we have specified what we want, create the table Customers->CreateTable(); Customers->Active = True; for (int i = 1; i <= 20; i++) Customers->AppendRecord(ARRAYOFCONST((i*111, i*222))); DS2->DataSet = Customers; DBGrid2->DataSource->DataSet = Customers; Customers->Active = True; }
Delphi Examples:
{ This example requires two ProgressBars, two labels and a Memo. The ProgressBar and the label captions are updated as the mouse moves inside the Memo. } procedure TForm1.FormCreate(Sender: TObject); begin ProgressBar1.Min := 0; ProgressBar1.Max := Memo1.Width; ProgressBar2.Min := 0; ProgressBar1.Max := Memo1.Height; end; procedure TForm1.Memo1MouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer); begin Label1.Caption := InttoStr(X); Label2.Caption := InttoStr(Y); ProgressBar1.Position := X; ProgressBar2.Position := Y; end;
{ Reads through all records in the Customers table. Updates the ProgressBar accordingly. } procedure TForm1.Button1Click(Sender: TObject); var i: Integer; begin with ProgressBar1 do begin Min := 0; Max := Customers.RecordCount; Customers.First; for i := Min to Max do begin Position := i; Customers.Next; // do something with the current record end; end; end; procedure TForm1.FormCreate(Sender: TObject); var i: Integer; begin Customers:= TTable.Create(Form1); with Customers do begin DatabaseName := 'DBDEMOS'; TableType := ttParadox; TableName := 'CustInfo'; Active := False; // Overwrite any existing table if Customers.Exists then begin Customers.Close; Customers.DeleteTable; end; begin { The Table component must not be active } { First, describe the type of table and give } { it a name } { Next, describe the fields in the table } with FieldDefs do begin Clear; with AddFieldDef do begin Name := 'Field1'; DataType := ftInteger; Required := True; end; with AddFieldDef do begin Name := 'Field2'; DataType := ftString; Size := 30; end; end; { Next, describe any indexes } with IndexDefs do begin Clear; { The 1st index has no name because it is { a Paradox primary key } with AddIndexDef do begin Name := ''; Fields := 'Field1'; Options := [ixPrimary]; end; with AddIndexDef do begin Name := 'Fld2Indx'; Fields := 'Field2'; Options := [ixCaseInsensitive]; end; end; { Call the CreateTable method to create the table } CreateTable; Customers.Active:= True; for i := 1 to 100 do Customers.AppendRecord([i*111, i*222]); end; end; DS2.DataSet:= Customers; DBGrid2.DataSource.DataSet:= Customers; Customers.Active:= True; end;
Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
|
What do you think about this topic? Send feedback!
|