Originally Posted by
Brigs76
I am trying to read in the text of all items in a listbox and copy that text to an edit box (text box). However when I do, the string that is suppose to store all the items of the listbox only stores the last item that was read in. Here is my code:
Code:
int i, a;
char etxt[100];
i = SendMessage(hList, LB_GETCOUNT, 0, 0); //gets the number of items in listbox
for (a=0; a<i; a++)
{
SendMessage(hList, LB_GETTEXT, a, etxt); //get all text
}
SetDlgItemText(hwnd, ED_Box, etxt); //set the edit box to contain the string
So the problem is that the string etxt only contains the last item that was read in from the listbox, when it should contain all items.
Any ideas?
instead of copy pasting that code you should try to understand it
had this little line to your better understading...
Code:
int i, a;
char etxt[100];
i = SendMessage(hList, LB_GETCOUNT, 0, 0); //gets the number of items in listbox
for (a=0; a<i; a++)
{
SendMessage(hList, LB_GETTEXT, a, etxt); //get all text
printf("line at %d - %s\n",a,etxt);
}
SetDlgItemText(hwnd, ED_Box, etxt); //set the edit box to contain the string