• Advertisement

Archived

This topic is now archived and is closed to further replies.

Win32, no MFC, and ListBoxes

This topic is 6666 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites

  • Advertisement