DelphiFAQ Home Search:

Word wrapped TButton

 

commentsThis article has not been rated yet. After reading, feel free to leave comments and rate it.

If you want to have your TButton objects displayed with wrapped caption, you will notice that this is not possible - not possible without a little trick.
Of course, you could search the web for some third-party component, but there's an easier way to accomplish this. Just follow these steps:

  1. Put a TButton with empty caption on your form
  2. Create a TLabel with your desired caption and place
    it anywhere on the form
  3. Display the form as text (Alt+F12) and it will look as
    on the left side in the table
  4. Move the TLabel declaration into the TButton and
    change the coordinates since it is now relative to
    the button.
  5. (idea from Richard B. Winston:)
    Select the button and then "Component|Create Component Template".
    After you choose a name and palette page for the template,
    you will be able to select the button with embedded label from
    the component palette and use it just like any other component.
(before step 4)
object Button1: TButton
  Left = 176
  Top = 184
  Width = 75
  Height = 25
  Caption = ''
  TabOrder = 2
end
object Label1: TLabel
  Left = 200
  Top = 168
  Width = 32
  Height = 13
  Caption = 'My long caption'
  WordWrap = True
end
(after step 4)
object Button1: TButton
  Left = 176
  Top = 184
  Width = 75
  Height = 25
  Caption = ''
  TabOrder = 2
  object Label1: TLabel
    Left = 2
    Top = 2
    Width = 32
    Height = 13
    Caption = 'My long caption'
    WordWrap = True
  end
end

Comments:

 

 

NEW: Optional: Register   Login
Email address (not necessary):

Rate as
Hide my email when showing my comment.
Please notify me once a day about new comments on this topic.
Please provide a valid email address if you select this option, or post under a registered account.
 

Show city and country
Show country only
Hide my location
You can mark text as 'quoted' by putting [quote] .. [/quote] around it.
Please type in the code:

Please do not post inappropriate pictures. Inappropriate pictures include pictures of minors and nudity.
The owner of this web site reserves the right to delete such material.

photo Add a picture: