Delphi32.com - Home!
| Home/News | Downloads | Forums | D32 Magazine | Resources | Info and Facts |  
 
 How can I have a TBitBtn component that has a word wrapped caption?


How can I have a TBitBtn component that has a word wrapped caption?   

    The following example demonstrates drawing word wrapped text directly on a TBitBtn's glyph. Example:

    procedure TForm .FormCreate(Sender: TObject);
    var
      R : TRect;
      N : Integer;
      Buff : array[0..255] of Char;
    begin
      with BitBtn  do begin
        Caption := 'A really really long caption';
        Glyph.Canvas.Font := Self.Font;
        Glyph.Width  := Width - 6;
        Glyph.Height := Height - 6;
        R := Bounds(0, 0, Glyph.Width, 0);
        StrPCopy(Buff, Caption);
        Caption := '';
        DrawText(Glyph.Canvas.Handle,
                 Buff,
                 StrLen(Buff),
                 R,
                 DT_CENTER or DT_WORDBREAK or DT_CALCRECT);
        OffsetRect(R,
                   (Glyph.Width - R.Right) div 2,
                   (Glyph.Height - R.Bottom) div 2);
        DrawText(Glyph.Canvas.Handle,
                 Buff,
                 StrLen(Buff),
                 R,
                 DT_CENTER or DT_WORDBREAK);
      end;
    end;
    

     



  << Previous Faq     Complete List     Next Faq >>  



 
 Hits/month  2,500,000+ 
 Downloads
 (Since May 2000)
 7,393,709 
 Total Files  6,023 
 Forum msgs  7,670 
 Articles/FAQs  70+/900+ 
Kylix
Tips n Tricks
FAQs
Knowledge Base
Bug Listings
Articles
Books
Newsgroups
Links
Submissions
Testimonials
Advertising
Contact Us
About Us
Search Amazon:
Top Selling Software at Amazon

| Home/News | Downloads | Forums | Resources | Info and Facts | Testimonials |
  Site Search:
 


Comments/Problems: Webmaster@delphi32.com
Copyright © 1998-2006, Delphi32.com. All rights reserved.
Terms of Use