Jump to content

  • Log In with Google      Sign In   
  • Create Account

win32 list box doesn't add strings


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
6 replies to this topic

#1 noatom   Members   -  Reputation: 785

Like
0Likes
Like

Posted 22 February 2014 - 04:53 AM

So I created a win32 dialog with a list box in it, that has the id IDC_LIST1.

 

Then I just tried to add a string to it with:

SendDlgItemMessage(hDlg, IDC_LIST1, LB_ADDSTRING, 0, (LPARAM)L"test");

 

but nothing appears!

 

So I later added an edit box,and changed it's text,that,indicates that there is no hwnd problem or something like that. What could the problem be?



Sponsor:

#2 Endurion   Crossbones+   -  Reputation: 3685

Like
0Likes
Like

Posted 22 February 2014 - 05:49 AM

Could be a few things. Show the creation of the list box (is ID set properly?),

 

Which value is returned?

 

From MSDN:

 

The return value is the zero-based index of the string in the list box. If an error occurs, the return value is LB_ERR. If there is insufficient space to store the new string, the return value is LB_ERRSPACE.


Fruny: Ftagn! Ia! Ia! std::time_put_byname! Mglui naflftagn std::codecvt eY'ha-nthlei!,char,mbstate_t>

#3 noatom   Members   -  Reputation: 785

Like
0Likes
Like

Posted 22 February 2014 - 08:04 AM

I don't think it was the id,i checked it many times, and i even added other listboxes and tried with them too. I just restarted visual studio,deleted all the listboxes and just added a new one and it just worked...not sure what was wrong...



#4 Eliad Moshe   Members   -  Reputation: 813

Like
0Likes
Like

Posted 23 February 2014 - 09:01 PM

Maybe your project by default is set to MultiByte instead of unicode, try SendDlgItemMessageW.


Edited by Eliad Moshe, 24 February 2014 - 08:00 AM.


#5 Aardvajk   Crossbones+   -  Reputation: 6216

Like
0Likes
Like

Posted 24 February 2014 - 09:13 AM

Maybe your project by default is set to MultiByte instead of unicode, try SendDlgItemMessageW.

 

If SendDlgItemMessageA was being called, the code wouldn't compile with the L prefix on the test string.



#6 Eliad Moshe   Members   -  Reputation: 813

Like
1Likes
Like

Posted 24 February 2014 - 10:13 AM

 

Maybe your project by default is set to MultiByte instead of unicode, try SendDlgItemMessageW.

 

If SendDlgItemMessageA was being called, the code wouldn't compile with the L prefix on the test string.

 

See the function def at MSDN : http://msdn.microsoft.com/en-us/library/windows/desktop/ms645515%28v=vs.85%29.aspx
You need to cast the last parameter to LPARAM.
 



#7 Aardvajk   Crossbones+   -  Reputation: 6216

Like
0Likes
Like

Posted 24 February 2014 - 11:28 AM

 

 

Maybe your project by default is set to MultiByte instead of unicode, try SendDlgItemMessageW.

 

If SendDlgItemMessageA was being called, the code wouldn't compile with the L prefix on the test string.

 

See the function def at MSDN : http://msdn.microsoft.com/en-us/library/windows/desktop/ms645515%28v=vs.85%29.aspx
You need to cast the last parameter to LPARAM.
 

 

 

Oh yeah, sorry. My mistake. Potential nastiness with UNICODE vs multibyte there with the cast, you're quite correct.






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS