home *** CD-ROM | disk | FTP | other *** search
/ Delphi 4 Bible / Delphi_4_Bible_Tom_Swan_IDG_Books_1998.iso / source / StatusOD / Main.pas < prev    next >
Pascal/Delphi Source File  |  1998-04-23  |  1KB  |  54 lines

  1. unit Main;
  2.  
  3. interface
  4.  
  5. uses
  6.   Windows, Messages, SysUtils, Classes, Graphics, Controls,
  7.   Forms, Dialogs, ComCtrls, ImgList;
  8.  
  9. type
  10.   TMainForm = class(TForm)
  11.     StatusBar1: TStatusBar;
  12.     ImageList1: TImageList;
  13.     procedure StatusBar1DrawPanel(StatusBar: TStatusBar;
  14.       Panel: TStatusPanel; const Rect: TRect);
  15.   private
  16.     { Private declarations }
  17.   public
  18.     { Public declarations }
  19.   end;
  20.  
  21. var
  22.   MainForm: TMainForm;
  23.  
  24. implementation
  25.  
  26. {$R *.DFM}
  27.  
  28. procedure TMainForm.StatusBar1DrawPanel(StatusBar: TStatusBar;
  29.   Panel: TStatusPanel; const Rect: TRect);
  30. var
  31.   SavedStyles: TFontStyles;
  32. begin
  33.   with StatusBar, Canvas do
  34.   begin
  35.     SavedStyles := Font.Style;  // Save current font styles
  36.     // Set font style or draw an icon depending
  37.     // on which Panel needs updating.
  38.     case Panel.Index of
  39.       0 : Font.Style := [fsBold];
  40.       1 : Font.Style := [fsItalic];
  41.       2 : ImageList1.Draw(Canvas,
  42.             Rect.Left + 2, Rect.Top + 2, 0);
  43.       3 : Font.Style := [fsBold, fsItalic];
  44.     end;
  45.     // Draw text in all panels except the third,
  46.     // which displays an icon.
  47.     if Panel.Index <> 2 then
  48.       TextRect(Rect, Rect.Left, Rect.Top, Panel.Text);
  49.     Font.Style := SavedStyles;  // Restore saved font styles
  50.   end;
  51. end;
  52.  
  53. end.
  54.