TdxStatusBarPanel.OnDrawPanel Event
Enables you to custom paint the panel.
Declaration
property OnDrawPanel: TdxStatusBarDrawPanelEvent read; write;
Remarks
The Sender parameter identifies the panel being painted.
The ACanvas parameter provides access to the canvas used to paint.
The ARect parameter specifies the bounding rectangle of the panel.
The ADone parameter of the event specifies whether default painting needs to be performed. If set to True, default painting is not performed after the event handler is executed. Leaving the parameter set to False can be used if you need to custom paint the background of the panel only.
The sample code below handles the OnDrawPanel event to paint a blinking image within a status bar section. Note that you need a TTimer component to invalidate the status bar with the predefined time intervals.
var
DrawImage: Boolean;
procedure TForm1.FormCreate(Sender: TObject);
begin
DrawImage := True;
end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
DrawImage := not DrawImage;
dxStatusBar1.Invalidate;
end;
procedure TForm1.dxStatusBar1Panels2DrawPanel(Sender: TdxStatusBarPanel;
ACanvas: TcxCanvas; const ARect: TRect; var ADone: Boolean);
var
Brush: HBRUSH;
Bitmap: TBitmap;
begin
Bitmap := TBitmap.Create;
Bitmap.LoadFromFile('d:\image.bmp');
if DrawImage then
ACanvas.Draw(ARect.Left, ARect.Top, Bitmap)
else
begin
ACanvas.Brush.Color := clBtnFace;
ACanvas.Brush.Style := bsSolid;
ACanvas.FillRect(ARect);
end;
ADone := True;
end;
See Also