Solved

Different OnDrawPanel for different TStausBar's

Posted on 2002-05-22
5
298 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
Comment Utility
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
Comment Utility
listening
0
 

Author Comment

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

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

771 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now