Forum > General

DrawText for multiline button caption failure

<< < (3/3)


--- Quote from: theo on April 04, 2010, 12:41:50 pm ---
--- Quote from: anna on April 04, 2010, 11:56:51 am ---It does't work. All text is in one line regardless of length of words.

--- End quote ---

Yes, Sorry it works for GTK2.

You could try this for windows but I don't know if it works on other WS:

--- Code: ---procedure TForm1.FormCreate(Sender: TObject);
var S: AnsiString;
    R: TRect;
    S:='Hello World Hello World Hello World Hello World';
    BitBtn1.Glyph.Canvas.Font := BitBtn1.Font;
    BitBtn1.Glyph.Width := BitBtn1.Width - 6;
    BitBtn1.Glyph.Height := BitBtn1.Height - 6;
    R := Bounds(0, 0, BitBtn1.Glyph.Width, BitBtn1.Glyph.Height);
    BitBtn1.Caption := '';
    R := Bounds(1, 1, BitBtn1.Glyph.Width-1, BitBtn1.Glyph.Height-1);

--- End code ---

--- End quote ---

Thank you for listing. How to define size of text to be written by TextRect ?
Next operators don't work:

I monitored TextHeight(S) method before TextRect and was surprised that it's 13 for unknown reasons.


[0] Message Index

[*] Previous page

Go to full version