Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

List box

Status
Not open for further replies.

lilou

Programmer
Apr 12, 2001
3
FR
My application writes a lot of information in a list box.
When the list box is full, the scrool bar get smaller but i can not see the new information because the list box doesn't follow the new display.
I can only see the old displayed information.





 
I usually create my own listbox control be inherting
from MFC's CListBox.

i.e.,

class CMyListBox : public CListBox

and then add member called something like "LogLine", which
adds a string the end of the listbox scrolls to bottom of
the list box using SendMessage(WM_VSCROLL, SB_BOTTOM, 0).

NB: Make sure the listbox doesn't have the "Sort" property
enabled.

The code also includes a cleanup loop, that deletes from
the top of the listbox when it gets too full.

i.e.,

#define _MYLISTBOX_MAX_SIZE (500)

...

void CMyListBox::LogLine(LPCTSTR lpLog)
{
// Make sure list box never grows too big

while(GetCount() > _MYLISTBOX_MAX_SIZE)
DeleteString(0);

// Append the new string to the list box

AddString(lpLog);

// Scroll to the bottom of the list box

SendMessage(WM_VSCROLL, SB_BOTTOM, 0);
}

I hope this is useful. I think this is what you were
asking about?


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top