list box

  • Thread starter Thread starter wayne
  • Start date Start date
W

wayne

hi,

how can i read a list box from the first entry to the last? cos i
understand that the cursor will be at the end and hence i wont b able
to use GetCurSel().

thus how can i pick up the content of the list box from the top to the
bottom?

thanks
 
hi,

how can i read a list box from the first entry to the last? cos i
understand that the cursor will be at the end and hence i wont b able
to use GetCurSel().

thus how can i pick up the content of the list box from the top to the
bottom?

In C, Something like:

#include <windows.h>
#include <stdlib.h>
#include <stdio.h>

int SevListBoxList(HWND hlist)
{
TCHAR strval[MAX_LBOX_LEN+1];

int i, c = (int)SendMessage(hlist, LB_GETCOUNT, 0, 0);
for (i=0; i<c; i++) {
if ((int)SendMessage(hlist, LB_GETTEXTLEN, i) <= MAX_LBOX_LEN) {
SendMessage(hlist, LB_GETTEXT, i, strval);
printf("%d: %s\n", i, strval);
} else
printf("%d: (STRING TOO LONG)\n", i);
}
return i;
}

Using MFC/CListBox, I suppose it would be something like

#include <windows.h>
#include <iostream>

int SevCListBoxList(CListBox *plist)
{
CString strval;
int i, c = plist->GetCount();

for (i=0; i<c; i++) {
plist->GetText(i, strval);
cout << i << ": " << strval << endl;
}
return i;
}
 
Back
Top