<< Click to display table of contents >> TSRVPreview.OnBeforePaint |
Occurs when the component paints itself, before painting the content of pages.
property OnBeforePaint: TSRVPOnPaint;
This event allows drawing additional information in this component.
This event allows drawing only beyond the area specified in ARect parameter, because any drawing inside this area will be overridden. This event may be considered redundant, because OnAfterPaint allows drawing both inside and outside of this area.
Since a clipping region is ARect, you need to create a new clipping region to draw outside ARect.
Example:
procedure TForm1.SRVPreview1BeforePaint(Sender: TObject; ACanvas: TCanvas;
ARect: TRect);
var
HRgn: Cardinal;
begin
// creating a clipping region for drawing anywhere in SRVPreview1
HRgn := CreateRectRgn(0, 0, SRVPreview1.Width, SRVPreview1.Height);
SelectClipRgn(ACanvas.Handle, HRgn);
// <drawing here>
DeleteObject(HRgn);
// restoring the original region
HRgn := CreateRectRgn(ARect.Left, ARect.Top, ARect.Right, ARect.Bottom);
SelectClipRgn(ACanvas.Handle, HRgn);
DeleteObject(HRgn);
end;