Главная страница
Top.Mail.Ru    Яндекс.Метрика
Текущий архив: 2005.09.04;
Скачать: 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 вся ветка

Текущий архив: 2005.09.04;
Скачать: CL | DM;

Наверх




Память: 0.46 MB
Время: 0.074 c
2-1123283495
dimona
2005-08-06 03:11
2005.09.04
cordinati Button-a


14-1123830712
Hawk2
2005-08-12 11:11
2005.09.04
ATI RADEON 9550


4-1121536776
nosochek
2005-07-16 21:59
2005.09.04
CreateProcess , неверный дескриптор


1-1123661183
Andry
2005-08-10 12:06
2005.09.04
Размер шрифта


3-1122273709
Talan
2005-07-25 10:41
2005.09.04
"Глючит" Filter