Solved

Different OnDrawPanel for different TStausBar's

Posted on 2002-05-22
5
311 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
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…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

726 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