Solved

Different OnDrawPanel for different TStausBar's

Posted on 2002-05-22
5
307 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Intraweb download file link ? 1 155
Delphi Yen format 3 45
JAudiorecorder record freezing the app 29 76
Sending files from  idTcpServer Socket to idTcpClient 2 44
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…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

838 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