Win32, no MFC, and ListBoxes

Started by
1 comment, last by Enix 24 years, 6 months ago

Enix,

Try stepping through the code with a debugger. Verify that List is != NULL and that SendMessage does not return LB_ERR.

However, my guess is that EX1 is a pointer to a character string. If so, you just need to pass EX1.

This indirection of EX1 returns the VALUE stored at the first element of the array character array, not the ADDRESS of the array which is what the function expects.

Anyways, I hope I was able to explain it correctly...hehe..

e.g.


char *test = "test";
//: point to the ADDRESS of "test".
char *t = test;
//: this is the same as
//: t = &test[0];

//: get the VALUE pointed to by test
char value = *test;
//: this is the same as
//: value = test[0]
//:

So, your SendMessage call becomes:

SendMessage(List, LB_ADDSTRING, 0, (LPARAM) EX1);

HTH,

-mordell

__________________________________________

Yeah, sure... we are laughing WITH you ...
Advertisement
Im haveing trouble adding data to a list box, without using MFC. if use the following code with a dialog box named NAME_LIST and a list box with the id of PLAYERS and NameList is a HWND pointer to the dialog box and EX1 is of the char* type.

HWND List = GetDlgItem(*NameList, PLAYERS);
SendMessage(List,LB_ADDSTRING,0,(LPARAM)*EX1);

Does any one know why nothing will be added to the dialog box after going thought this code? Id apreciate the help! Thanks for reading-Enix

Thanks for the help! Its starting to work now!

This topic is closed to new replies.

Advertisement