Re: Scrolling.
Hi Tony,
To add to Ali's suggestion, here is some code you could use to check the
string while adding:
// Set the horizontal scroll
int oldwidth = m_ListBox->GetHorizontalExtent();
CDC* pDC = m_ListBox->GetWindowDC();
if (pDC) {
int newwidth = pDC->GetTextExtent(msg, _tcslen(msg)).cx;
m_ListBox->ReleaseDC(pDC);
if (newwidth > oldwidth) {
m_ListBox->SetHorizontalExtent(newwidth);
}
}
// Delete old entries if the list gets longer than 300 entries
if (m_ListBox->GetCount() >= 300)
m_ListBox->DeleteString(0);
// Add the new one at the end
m_ListBox->AddString(csMsg);
Also, Joe has a listbox already done that you could use for this purpose.
He's off teaching this week or else I'm sure he'd give you the link:
http://www.flounder.com/hscroll.htm
Tom
"TonyG" <TonyG@junk.com> wrote in message
news:W%Cbi.25286$YL5.10549@newssvr29.news.prodigy.net...
I have a simple dialog that I have used in many programs. Most of the
dialog is covered by a giant list box. Whenever I have a bunch of text to
display to the operator, I use this dialog. An example is a bunch of
configuration errors that I detect during program startup. I have a nice
way of passing a title, my text and some other stuff to the dialog's
constructor. There is also some other class methods for other interactions.
My problem is this: The list box does not word wrap. If I submit a text
line wider then the list box, my subclassed list box automatically adjusts
the horizontal scroll bars. But what I would really want is word wrap.
Is there a way to implement word wrap with a list box?
OR
Should I be using some other control?
OR
Is there some other way to accomplish my needs?