How to draw a line at the current date and time.
This example uses the same technique as FAQ 25, but instead of displaying a logo, it draws a line at the current date and time.
The key to this technique is to implement an OnDrawProgress event handler. This event is fired at various stages in the drawing process, and so allows additional graphics to be added at each stage. For example, you may want to add graphics on top of the plot background and allocation shadows, but behind the allocations themselves — in this particular case, you'd draw your graphics when the "Progress" argument is equal to dpShadowsDone. These are the values and meanings of the Progress argument.
TssDrawProgress | Meaning |
---|---|
dpBeforeStart | Before any drawing has been done. Can be used as a reset. |
dpFrameDone | The outer frame has been drawn. |
dpBackgroundDone | The background has been drawn, including any alternating colour. |
dpLabelsDone | The resource name and date/time labels have been drawn. This is the earliest point at which the TssResource.PlotRect is valid. |
dpShadowsDone | The allocation shadows have been drawn. |
dpAllocationsDone | The allocations have been drawn. |
dpAllDone | All drawing is finished. |
This example draws a blue line at the current date and time.

procedure TForm1.RACDrawProgress(Sender: TObject; Canvas: TCanvas; DrawRect: TRect; Progress: TssDrawProgress); var x: integer; begin // indicate the current time with a vertical line if Progress = dpShadowsDone then begin x := RAC.DateTimeToX(Now); Canvas.Pen.Color := clBlue; Canvas.Pen.Width := 2; Canvas.MoveTo(x, DrawRect.Top); Canvas.LineTo(x, DrawRect.Bottom); end; end;
Note: This event handler can be invoked many times a second while the user is dragging the chart or an allocation. It is important that it completes quickly in order to maintain a responsive user experience.
- Overview
- Download
- Screen Shots
- Properties
- FAQ & Getting Started
- User Comments
- Support Forum
- Change History
- License
- Buy
What People Say |
---|
![]() I did want to drop you a note and tell you what a wonderful component. It's a must have component if you are a serious Delphi developer. ![]() Miguel Henley, Brazil |
More … |