[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 368
  • Last Modified:

How can I format the text of the StatusBar?

Hi all,
How can I format the text of the StatusBar?
e.g. Change the text of StatusBar.Panels[1]  to  "Red" and "Bold"?
(Just change the StatusBar.Panels[1], don't change other Panels)

Thanks, Bin
0
xbbin
Asked:
xbbin
  • 7
  • 4
  • 2
  • +2
1 Solution
 
ginsonicCommented:
Read these :

How to draw coloured text on a TStatusBar
http://www.lmc-mediaagentur.de/dpool/tips01/0034.htm

How to write bold text on a TStatusBar
http://www.lmc-mediaagentur.de/dpool/tips02/0164.htm
0
 
xbbinAuthor Commented:
Hi ginsonic,
How can I just format the text of StatusBar.Panels[1], don't format StatusBar.Panels[0] and StatusBar.Panels[2]?
0
 
DraregCommented:
Procedure  TForm1.StatusBar1DrawPanel(StatusBar: TStatusBar;
  Panel: TStatusPanel;  Const  Rect: TRect);
Begin
  If Panel = StatusBar1.Panels[0] Then
      With StatusBar1.Canvas Do
          Begin
              Font.Color := clRed ;
              TextOut(Rect.left, Rect.top + 2, 'Hello' ) ;
              Font.Color := clBlue ;
              TextOut(Rect.left+30, Rect.top + 2, 'World' ) ;
          End ;

  If Panel = StatusBar1.Panels[2] Then
      With StatusBar1.Canvas Do
          Begin
              Font.Color := clYellow ;
              TextOut(Rect.Left + 12, Rect.Top + 2, 'Patatouf') ;
          End ;
End ;
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
DelFreakCommented:
Listening...
0
 
ginsonicCommented:
Have you read my tips ? All what you need are there
.
procedure TForm1.StatusBar1DrawPanel(StatusBar: TStatusBar;
Panel: TStatusPanel; const Rect: TRect);
begin

  if Panel = StatusBar.Panels[1] then
  begin
    StatusBar.Canvas.Font.Color := clRed;
    StatusBar.Canvas.TextOut(Rect.Left, Rect.Top, MyText' )
   end;

end;
0
 
ginsonicCommented:
In tip sample is used Panel[0] but you can choice your own panel . Just use
 if Panel = StatusBar.Panels[YourPanel] then ...
0
 
ginsonicCommented:
DelFreak have you receive my mail ?
How work the project into your system ?

Regards,
Nick
0
 
xbbinAuthor Commented:
Hi ginsonic,
How can I change the text color at runtime?
0
 
Stuart_JohnsonCommented:
LOL!  Didn't you read Ginsonic's post three posts back?  That's exactly the way you do it.
0
 
xbbinAuthor Commented:
Yes, I means How can I click a button to change the color to clRed, click another button change to clBlack.
0
 
Stuart_JohnsonCommented:
var
  StatFontColor: TColor;

procedure TForm1.Button1Click(Sender: TObject);
begin
  if StatFontColor = clBlack then
    StatFontColor := clRed
  else
    StatFontColor := clBlack;

  StatusBar1.Invalidate;
end;

procedure TForm1.StatusBar1DrawPanel(StatusBar: TStatusBar;
Panel: TStatusPanel; const Rect: TRect);
begin

 if Panel = StatusBar.Panels[1] then
 begin
   StatusBar.Canvas.Font.Color := StatFontColor;
   StatusBar.Canvas.TextOut(Rect.Left, Rect.Top, MyText' )
  end;

end;
0
 
ginsonicCommented:
Was very simple :)
0
 
xbbinAuthor Commented:
Sorry, I just a delphi beginner.

Hi Drareg,
Here have some points for you: http://www.experts-exchange.com/jsp/qManageQuestion.jsp?ta=delphi&qid=20279202

Hi Stuart Johnson,
Here have some points for you: http://www.experts-
exchange.com/jsp/qManageQuestion.jsp?ta=delphi&qid=20279198

Thanks, Bin
0
 
ginsonicCommented:
Look like you are an Ex-Ex beginner user, too :)
Any time with pleasure. Just ask .

Regards,
Nick aka ginsonic
0
 
DelFreakCommented:
Hey Nick! Yeah I got it. Thanks man! Works okay. I just love socket related stuff. Hehehe!


Cheers,
DelFreak
0
 
ginsonicCommented:
Glad to hear that.
See you on net .
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 7
  • 4
  • 2
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now