1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122:
| unit Unit1; interface
uses Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.ComCtrls, Vcl.StdCtrls;
type TForm1 = class(TForm) StatusBar1: TStatusBar; Button1: TButton; Button2: TButton; procedure StatusBar1DrawPanel(StatusBar: TStatusBar; Panel: TStatusPanel; const Rect: TRect); procedure Button1Click(Sender: TObject); procedure FormCreate(Sender: TObject); procedure Button2Click(Sender: TObject); private public end;
var Form1: TForm1; FC0,FC1,FC2,FC3 : INTEGER; BG0, BG1, BG2, BG3 : INTEGER; PT0, PT1, PT2, PT3 : String; implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject); begin PT0:= 'Panel[000]'; PT1:= 'Panel[111]'; PT2:= 'Panel[222]'; PT3:= 'Panel[333]'; FC0:= 16777215; BG0:= 16711680; FC1:= 16777215; BG1:= 0; FC2:= 16777215; BG2:= 16711680; FC3:= 16777215; BG3:= 0; StatusBar1.Repaint; end;
procedure TForm1.Button2Click(Sender: TObject); begin PT0:= 'Panel[0]'; PT1:= 'Panel[1]'; PT2:= 'Panel[2]'; PT3:= 'Panel[3]'; FC0:= clRed; BG0:= clYellow; FC1:= clYellow; BG1:= clRed; FC2:= clBlue; BG2:= clYellow; FC3:= clYellow; BG3:= clBlack; StatusBar1.Repaint; end;
procedure TForm1.FormCreate(Sender: TObject); begin StatusBar1.Panels[0].Style := psOwnerDraw; StatusBar1.Panels[1].Style := psOwnerDraw; StatusBar1.Panels[2].Style := psOwnerDraw; StatusBar1.Panels[3].Style := psOwnerDraw; end;
procedure TForm1.StatusBar1DrawPanel(StatusBar: TStatusBar; Panel: TStatusPanel; const Rect: TRect); begin if Panel = StatusBar1.Panels[0] then begin with StatusBar.Canvas do begin Brush.Color := BG0; Font.Color:= FC0; FillRect(Rect); TextOut(Rect.left + 2, Rect.top + 2, PT0); end; end; if Panel = StatusBar1.Panels[1] then begin with StatusBar.Canvas do begin Brush.Color := BG1; Font.Color:= FC1; FillRect(Rect); TextOut(Rect.left + 2, Rect.top + 2, PT1); end; end; if Panel = StatusBar1.Panels[2] then begin with StatusBar.Canvas do begin Brush.Color := BG2; Font.Color:= FC2; FillRect(Rect); TextOut(Rect.left + 2, Rect.top + 2, PT2); end; end; if Panel = StatusBar1.Panels[3] then begin with StatusBar.Canvas do begin Brush.Color := BG3; Font.Color:= FC3; FillRect(Rect); TextOut(Rect.left + 2, Rect.top + 2, PT3); end; end; end;
end. |