*.hpp
private: // User declarations
void __fastcall ListBoxItemApplyStyleLookup(TObject *Sender);
void __fastcall ListBoxItemResize(TObject *Sender);
public: // User declarations
void CalculateItemHeight(TObject *Sender);
*.cpp
//---------------------------------------------------------------------------
void Tdm::CalculateItemHeight(TObject *Sender)
{
TTextLayout* FTextLayout = TTextLayoutManager::TextLayoutForClass(TTextLayoutManager::DefaultTextLayout);
TListBoxItem *ListItem = dynamic_cast(Sender);
FTextLayout->BeginUpdate();
//FTextLayout->Text = ListItem->ItemData->Detail;
FTextLayout->Text = ListItem->Text;
FTextLayout->MaxSize = TPointF(ListItem->Width, 1000);
FTextLayout->WordWrap = ListItem->WordWrap;
FTextLayout->Font = ListItem->Font;
FTextLayout->HorizontalAlign = ListItem->TextAlign;
FTextLayout->VerticalAlign = ListItem->VertTextAlign;
FTextLayout->EndUpdate();
ListItem->Height = FTextLayout->Height;
}
//---------------------------------------------------------------------------
void __fastcall Tdm::ListBoxItemApplyStyleLookup(TObject *Sender)
{
CalculateItemHeight(Sender);
}
//---------------------------------------------------------------------------
void __fastcall Tdm::ListBoxItemResize(TObject *Sender)
{
CalculateItemHeight(Sender);
}
//---------------------------------------------------------------------------
.......
TListBoxItem *listItem = new TListBoxItem(frmMain->ListBoxLog);
listItem->ItemData->Text=DateTimeToStr(Now())+" : " +message;
listItem->OnApplyStyleLookup=ListBoxItemApplyStyleLookup;
listItem->OnResize=ListBoxItemResize;
или же назначить события в статике
Комментариев нет:
Отправить комментарий