ProgressBar columns
Drawing of a ProgressBar
Grid doesn't allow customizing column to show ProgressBar shaped image, but there is a procedure DrawProgressBarEh in the ToolCtrlsEh module. You can use it to draw image of ProgressBar when an event of custom drawing of a Grid's cell is used.
Below you can see an example of using of the DrawProgressBarEh procedure:
procedure TForm1.DBGridEh6Columns3AdvDrawDataCell(Sender: TCustomDBGridEh;
Cell, AreaCell: TGridCoord; Column: TColumnEh; const ARect: TRect;
var Params: TColCellParamsEh; var Processed: Boolean);
begin
Sender.DefaultDrawColumnDataCell(Cell, AreaCell, Column, ARect, Params);
DrawProgressBarEh(mtTable1.FieldByName('ItemsTotal').AsFloat, 0, 50000,
Sender.Canvas, ARect, clSkyBlue, cl3DDkShadow, clNone);
Processed := True;
end;Procedure DrawProgressBarEh has next parameters:
CurrentValue: Double;
MinValue: Double;
MaxValue: Double;
Canvas: TCanvas;
const Rect: TRect;
Color: TColor;
FrameColor: TColor;
BackgroundColor: TColor;
const PBParPtr: PProgressBarParamsEh = nil
Extended options are of the following type:
PProgressBarParamsEh = ^TProgressBarParamsEh;
TProgressBarParamsEh = record ...TProgressBarParamsEh has the following fields:
ShowText: Boolean;
TextType: TProgressBarTextTypeEh;
TProgressBarTextTypeEh = (pbttAsValue, pbttAsPercent);
pbttAsValue - display the value passed in the CurrentValue parameter.pbttAsPercent - Display the value as a percentage calculated using the formula MaxValue - MinValue = 100%.TextDecimalPlaces: Byte;
TextAlignment : TAlignment;
FrameFigureType: TProgressBarFrameFigureTypeEh;
TProgressBarFrameFigureTypeEh = (pbfftRectangle, pbfftRoundRect);
pbfftRectangle - Rectangle. pbfftRoundRect - Rectangle with rounded corners.FrameSizeType: TProgressBarFrameSizeTypeEh;
TProgressBarFrameSizeTypeEh = (pbfstFull, pbfstVal);
pbfstFull - A border is drawn around the entire area of the progress bar.
pbfstVal - The border is drawn around the completed area of the progress bar.
Indent: Byte
FontName: String;
FontColor: TColor;
FontSize: Integer;
FontStyle: TFontStyles;
Code example:
procedure TForm1.DBGridEh1Columns5AdvDrawDataCell(Sender: TCustomDBGridEh; Cell,
AreaCell: TGridCoord; Column: TColumnEh; const ARect: TRect;
var Params: TColCellParamsEh; var Processed: Boolean);
var
Prm: TProgressBarParamsEh;
begin
Sender.DefaultDrawColumnDataCell(Cell, AreaCell, Column, ARect, Params);
Prm.ShowText := True;
Prm.TextType := TProgressBarTextTypeEh.pbttAsPercent;
Prm.TextDecimalPlaces := 1;
Prm.TextAlignment := TAlignment.taCenter;
Prm.FrameFigureType := TProgressBarFrameFigureTypeEh.pbfftRectangle;
Prm.FrameSizeType := TProgressBarFrameSizeTypeEh.pbfstFull;
Prm.Indent := 2;
Prm.FontName := '';
Prm.FontColor := clDefault;
Prm.FontSize := Sender.Canvas.Font.Size - 1;
Prm.FontStyle := [];
DrawProgressBarEh(MemTableEh1.FieldByName('ItemsTotal').AsFloat, 0, 50000,
Sender.Canvas, ARect, clSkyBlue, cl3DDkShadow, clNone,
@Prm);
Processed := True;
end;