I am trying to populate a Listbox, but the text does not get placed into the box.
I am using Pelles c 7.00.355 64bit
Win7 OS
I have used the Wizard to create a Dialog-based app.
I have used the drag-and-drop interface to place a Listbox icon in my app.
The ID of my Listbox is 4015
I have successfully used:
ShowWindow(GetDlgItem(hwndDlg,4015),SW_HIDE);
and
ShowWindow(GetDlgItem(hwndDlg,4015),SW_SHOW);
to hide and show the dialog, under user control, when app is running.
Here is the code I am using to populate the Listbox - that does not work.
I have included the declarations below.
int pos;
int ii;
HWND hwndList;
char buf22[300];
strcpy(buf22, "some listbox text");
hwndList = GetDlgItem(hwndDlg, 4015);
ii = 1;
pos = (int)SendMessage(hwndList, LB_ADDSTRING, 0, (LPARAM) buf22);
SendMessage(hwndList, LB_SETITEMDATA, pos, (LPARAM) ii);
// Set input focus to the list box.
SetFocus(hwndList);
Any help is much appreciated.
Thank-you.
It would be better if you posted a small project.
John
Try this:
Thank-you all for replies.
I have czerny's code running.
I am studying it to see how it is different from mine.
It appears that you simply inserted my code into a small project.
Your code works.
Mine does not work.
I execute my code (to populate the list box) from a WM_COMMAND when the User presses a Button.
Your code runs at WM_INITDIALOG.
So far that is the only difference I see and I don't know why that is significant.
Back when I developed with MS Vis Studio (MFC), you had to call UpdateDialog() to either read from or write to a control. But I thought that was only specific to MFC.
Is there something equivalent in Pelles c ?
Thanks again.
P.S. yes in the future I will post a small project .... didn't think of that this time.
I have created my own small project and it works just like czerny's.
I have created a comparison on the properties of the 2 Listboxes to try to understand why one works and one does not work.
the comparison is a screenshot jpg.
Any ideas on why the Listbox won't accept input is much appreciated.
Thank-you.
Your List box is probably a List-view control ,"ListBox" vs "SysListView32".
Laur
Thank-you Laur :)