Solved

Different OnDrawPanel for different TStausBar's

Posted on 2002-05-22
5
308 Views
Last Modified: 2012-06-21
I want to be able to cange the font to bold the text on a number of TStatusPanels. I set the TStatusPanel.Style to psOwnerDraw and add a TStatusBar.OnDrawPanel event which paint my text via TextRect. The problem is that the OnDrawPanel applies for each Panel that has the style set to psOwnerDraw. I want a number of panels to have bold but different text. Can I do this?

Thanks, Tom.
0
Comment
Question by:tomcorcoran
  • 2
  • 2
5 Comments
 
LVL 14

Accepted Solution

by:
DragonSlayer earned 50 total points
ID: 7028952
OnDrawPanel also passes a Panel parameter, so from there you can know which Panel you will be drawing to.

e.g. if you only want to Bold the text for Panels 0 and 3:

if Panel.Index in [0, 3] then
  StatusBar1.Canvas.Pen.Font.Style := [fsBold];
StatusBar1.Canvas.TextOut(Rect.Left, Rect.Top, 'This is Panel ' + IntToStr(Panel.Index));
0
 
LVL 9

Expert Comment

by:ginsonic
ID: 7028973
listening
0
 

Author Comment

by:tomcorcoran
ID: 7029480
I had the TStatusPanel text and bold attributes stored in a TList so I got at them via the Panel.Index. Great idea, thanks.

FYI, it's StatusBar1.Canvas.Font.Style := [fsBold];

Now the text which is in the OnOwnerDraw panels is a pixel or two higher than the text in the normal panels. I would like the difference not to be obvious to the idea. TRct.Bottom can't be directly adjusted. Any ideas?

Thanks a million, Tom.

0
 
LVL 14

Expert Comment

by:DragonSlayer
ID: 7030971
Ooops, my mistake on the Pen part :)

to adjust the Rect, you need to create your own variable

var
  myRect: TRect;
begin
  myRect := Rect;
  // now you can adjust the Rect, for example:
  // Dec(myRect.Bottom, 2);
  StatusBar1.Canvas.TextOutRect(myRect, myRect.Left, myRect.Top + 2, 'Hello');
end;
0
 

Author Comment

by:tomcorcoran
ID: 7031672
That worked a peach mate, thanks! Tom.
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!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

679 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question