|
리스트박스를 하나 만들고, 그 리스트박스가 화면에 스트링을 나타낼 때에 스트링이 다 한 줄로 나오지 않고 '\n'에서는 다음 줄로 건너가도록 하기 위하여,
다음과 같이 짯습니다.
그런데, 이렇게 짜놓으니까, 리스트박스가 디스플레이되는데 좀 많이 버벅거리는 것 같던데, 즉, 좀더 무겁게 돌아가던데, 이 문제를 어떻게 해결해야될까요?
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
this->Position = poDesktopCenter;
ListBox1->Style = lbOwnerDrawVariable;
ListBox1->MultiSelect = true;
}
void __fastcall TForm1::ListBox1DrawItem(TWinControl *Control, int Index,
TRect &Rect, TOwnerDrawState State)
{
//TODO :
TListBox* Lst = (TListBox*)Control;
DrawText(Lst->Canvas->Handle, Lst->Items->Strings[Index].c_str(),-1,&Rect,DT_WORDBREAK);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::ListBox1MeasureItem(TWinControl *Control,
int Index, int &Height)
{
//TODO :
TListBox* Lst = (TListBox*)Control;
TRect rect = Lst->ItemRect(Index);
DrawText(Lst->Canvas->Handle, Lst->Items->Strings[Index].c_str(),-1,&rect,DT_CALCRECT|DT_WORDBREAK);
Height = rect.Height();
}
|