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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Stubborn ListBox

Status
Not open for further replies.

LyMc

Programmer
Jun 3, 2003
84
US
I've been having the darndest time trying to get a ListBox to fill with data for me. The code looks like this:

Code:
static void BuildSchemeMenu()
{
	InitCommonControls();         // just to make sure this is not a problem.
	SendMessage (schemeControl, LB_RESETCONTENT, 0, 0);
	for (int i = 0; i < schemes->pointer; i++) {
		int j = (int) SendMessage (schemeControl, LB_ADDSTRING, 0, (LPARAM) (schemes->GetScheme (i)->name));
		XBox (MB_OK, "returned value %d, string is '%s'", j, schemes->GetScheme (i)->name);
	}
	int j = (int) SendMessage (schemeControl, LB_GETCOUNT, 0, 0);

The message box call assures me that the strings are being fed as I want them to be, and the return value from the ADDSTRING is always 0. Further, the j variable is also always 0, regardless of the number of strings in schemes->pointer. It's got to be something simple; I've messed with all the hard parts. It started out as a ComboBox with the same results; I switched to a ListBox so I could better see what was happening.
 
Are you sure schemes->pointer > 0?

/Per

&quot;It was a work of art, flawless, sublime. A triumph equaled only by its monumental failure.&quot;
 
Give up? It turns out the window handle, hDlg, was incorrect. I was incorrectly assigning the argument in the callback to the global, and the global was therefore wrong.

Yup, something really simple....
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top