Great idea. That'sa good visual.
"Joseph M. Newcomer" <newcomer@flounder.com> wrote in message
See below...
On Wed, 19 Nov 2008 22:58:20 -0800, "Tom Serface"
<tom.nospam@camaswood.com> wrote:
I think, with a listbox, you can do something a simple as:
// Set the horizontal scroll width
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 (m_ListBox.GetCount() >= 300)
m_ListBox.DeleteString(0);
// Add the new string at the end
m_ListBox.AddString(msg);
}
****
That's pretty much the code I use. Note that for the case where I keep
the "startup log",
what I do is DeleteString(n) where n is the item that is marked as the
first candidate.
Also, if I delete elements, the first time I actually insert an element at
position n
which tells me how many items I've deleted, and increment n by 1, so it
displays
============Deleted 26 entries================
to show that the log is no longer contiguous. Each time I delete an
element, I increment
the counter (since it is owner-draw, it will display the correct amount;
GetItemRect/InvalidateRect handles this if the element is visible)
*****