Вниз
Скачать: CL | DM;

How to make TKOlLabel really autosized ?   Найти похожие ветки 

← →
Boguslaw   (2005-01-23 18:24) [0]

TKOLLabel behaviour is different then oridanary VCL Label with AutoSize.If I put some multiline string (with #13#10) I wish to have TKOLabel properly sized to show all text with proper word breaks.Instead I have only first line visible. Please,help me fix this, I must use this autosized label to create replacement for balloon window (when not available IE6). The problem is that this label is not autosized and I can"t fix form size based on this label size. In VCL it"s working good
:-(


← →
ECM ©   (2005-01-23 20:52) [1]

Я делал это так (без переделки КОЛ). Можно и встроить, но руки пока не доходят попробовать...:(
Принцип такой - ширину считаем уже установленной и вычисляем высоту многострочного текста и меняем Height у Label

procedure TMainForm.Label2Paint(Sender: PControl; DC: HDC);
var
 OldFnt: HFONT;
 R: TRect;
 H: Integer;
begin
 OldFnt := SelectObject(DC,Sender.Font.Handle);
 SetBkMode(DC,TRANSPARENT);
 R := Sender.ClientRect;
 SetTextColor(DC,Sender.Font.Color);
 H := DrawText(DC,@Sender.Caption[1],Length(Sender.Caption),R,DT_CENTER or DT_WORDBREAK or DT_CALCRECT);
 if H <> (Sender.Height+3) then Sender.Height := H+3; //
 DrawText(DC,@Sender.Caption[1],Length(Sender.Caption),R,DT_CENTER or DT_WORDBREAK);
 SelectObject(DC,OldFnt);
end;

Возможно текст не точен (я повыбрасывал лишнее из своего
кода) - но у меня работает... Во всяком случае Label
с caTop при изменении размеров панели, на которую он помещен
отображается нормально. Если надпись не влазит в одну строку
она "заворачивается" в несколько :)



Страницы: 1 вся ветка

Скачать: CL | DM;



Память: 0.45 MB
Время: 0.021 c
3-1122021010
hursand
2005-07-22 12:30
2005.09.04
Check box в ячеках DBGrid


5-1097640774
3fc
2004-10-13 08:12
2005.09.04
Проблема с ActiveX-контролом: "control ... has no parent window"


8-1114008866
Katy
2005-04-20 18:54
2005.09.04
Контрастность и яркость картинки


14-1123820410
Black_phoenix
2005-08-12 08:20
2005.09.04
Переход с Delphi на VIsual C++ Net 2002


1-1123739219
webpauk
2005-08-11 09:46
2005.09.04
Завершение процесса




   Наверх