Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

TdxStatusBarPanel.OnDrawPanel Event

In This Article

Enables you to custom paint the panel.

#Declaration

Delphi
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.

Delphi
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