?
Solved

Delphi, part of a caption displayed in bold.

Posted on 2007-08-08
4
Medium Priority
?
1,013 Views
Last Modified: 2013-11-23
Delphi...

Dows anyone know if it is possible to set a caption of a button so that it is two words one on top of the other first word bold and second word plain.

e.g.

<b>Button</b>
Caption

so far i have button1.caption:='Button'+#10#13+'Caption';

but i don't know how to make 'Button' appear bold.  Any help greatly appreciated. Thanks.
0
Comment
Question by:alanrogerson2
  • 2
3 Comments
 
LVL 19

Expert Comment

by:MerijnB
ID: 19660100
check this component, it seems to be free if you don't need the sources.
For commercial use it's very cheap: http://www.tmssoftware.com/htmlbtns.htm
0
 
LVL 9

Accepted Solution

by:
sas13 earned 2000 total points
ID: 19660405
Solution for standard component TBitBtn:

procedure TForm1.BitBtn1Click(Sender: TObject);
var
  _bmp: TBitmap;
  _rect: TRect;
  _h: integer;
begin
 _bmp := TBitmap.Create;
 try
  _bmp.Width := BitBtn1.Width-8;
  _bmp.Height := BitBtn1.Height-8;
  _bmp.Canvas.Font.Assign(BitBtn1.Font);
  _bmp.Canvas.Font.Style := [fsBold];
  _rect := _bmp.Canvas.ClipRect;
  DrawText(_bmp.Canvas.Handle, 'Button', 6, _rect, DT_CENTER+DT_SINGLELINE+DT_TOP);
  _h := _bmp.Canvas.TextHeight('X');
  _rect.Top := _h;
  _bmp.Canvas.Font.Style := [];
  DrawText(_bmp.Canvas.Handle, 'Caption', 7, _rect, DT_CENTER+DT_SINGLELINE+DT_TOP);
  BitBtn1.Caption := EmptyStr;
  BitBtn1.Glyph.Assign(_bmp);
 finally
  _bmp.Free;
 end
end;
0
 
LVL 19

Expert Comment

by:MerijnB
ID: 20129636
points split?
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

Programmer's Notepad is, one of the best free text editing tools available, simply because the developers appear to have second-guessed every weird problem or issue a programmer is likely to run into. One of these problems is selecting and deletiā€¦
Jaspersoft Studio is a plugin for Eclipse that lets you create reports from a datasource.  In this article, we'll go over creating a report from a default template and setting up a datasource that connects to your database.
THe viewer will learn how to use NetBeans IDE 8.0 for Windows to perform CRUD operations on a MySql database.
The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.

840 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