size : 1577 uploaded_on : Tue Apr 20 00:00:00 1999 modified_on : Wed Dec 8 14:03:39 1999 title : Different panel text colors on a statusbar org_filename : ODStatusBar.txt author : Gerd Kayser authoremail : Gerd.Kayser@Okay.Net description : How to display text in different colors on a statusbar keywords : Owner draw statusbar tested : not tested yet submitted_by : The CKB Crew submitted_by_email : ckb@netalive.org uploaded_by : nobody modified_by : nobody owner : nobody lang : plain file-type : text/plain category : delphi-commoncontrols __END_OF_HEADER__ var Form1 : TForm1; Col1: Integer; Col2: Integer; implementation {$R *.DFM} procedure TForm1.Button1Click(Sender: TObject); begin Col1 := clBlue; // for Panels[1] Col2 := clGreen; // for Panels[2] StatusBar1.Panels[1].Style := psOwnerDraw; StatusBar1.Panels[2].Style := psOwnerDraw; StatusBar1.Panels[1].Text := 'Blue'; StatusBar1.Panels[2].Text := 'Green'; end; procedure TForm1.Button2Click(Sender: TObject); begin StatusBar1.Panels[1].Style := psText; StatusBar1.Panels[2].Style := psText; StatusBar1.Panels[1].Text := 'Normal'; StatusBar1.Panels[2].Text := 'Normal'; end; procedure TForm1.Button3Click(Sender: TObject); begin if StatusBar1.Panels[0].Style = psOwnerDraw then StatusBar1.Panels[0].Style := psText else StatusBar1.Panels[0].Style := psOwnerDraw; end; procedure TForm1.StatusBar1DrawPanel(StatusBar: TStatusBar; Panel: TStatusPanel; const Rect: TRect); var L : Integer; W: Integer; begin with StatusBar.Canvas do begin // Position for text W := TextWidth(Panel.Text); case Panel.Alignment of taLeftJustify : L := Rect.Left + 1; taCenter : L := ((Rect.Right - Rect.Left - W) div 2) + Rect.Left; taRightJustify : L := Rect.Right - W - 3; end; // Set color case Panel.Index of 1: Font.Color := Col1; // panels[1] 2: Font.Color := Col2; // panels[2] else Font.Color := clRed; end; // Text output TextOut(L, Rect.Top + 1, Panel.Text); end; end;