Sign in to follow this  

SendMessageCallback??

This topic is 4864 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

You would only use that function when you have a need to use it. And since you haven't said anything about why you think you need to use it there really isn't more that I can think to add. For most purposes SendMessage is sufficient.

Share this post


Link to post
Share on other sites
You use this function if and when you want to be notified when processing of your message has been completed at the receiving end.
This notification comes in the form of calling the callback function that you define, possibly with added data.
It is really up to you to understand whether you need this functionality or not.

Share this post


Link to post
Share on other sites
I dont see why. If your unsure, id just use what MSDN tells you to. Unless it specificly says to use the Callback. Just use SendMessage.

You will always get a call back to events (i.e user chose an item in your drop-down, or clicked a button, menu, etc) through your WinProc function.

Share this post


Link to post
Share on other sites
You are pretty vague with your info, but here is what I understand :
You have a combo-box and you want to know which item is currently selected.
One possible way of doing this is sending the control a CB_GETCURSEL message. Use the return value to determine the index of the selected item.

int iSelectionIndex = SendMessage(hwndComboBox, CB_GETCURSEL, 0/*ignored*/, 0/*ignored*/);

Share this post


Link to post
Share on other sites
When you select an item in a dropdown combo box, a notification message, CBN_SELCHANGE, is sent to the control's parent via the WM_COMMAND message. So you can respond to that notification immediately, by sending the message CB_GETCURSEL to get the selected item index. If your control is a sorting style, then you really need to get the parameter of the item by then sending CB_GETITEMDATA to the control to identify which item it really is. This of course assumes you used CB_SETITEMDATA when you added the item to the control, to associate a unique value with each item.

Share this post


Link to post
Share on other sites
ok so lets say that i have so far a sendmessage that has CB_ADDSTRING would that work with setitemdata or not??

so lets say i have something like this

SendMessage(combo, CB_ADDSTRING, 0, (LPARAM) (LPCTSTR)"25");
SendMessage(combo, CB_ADDSTRING, 0, (LPARAM) (LPCTSTR)"45");


how would i check which one is being used??

Share this post


Link to post
Share on other sites
The return value of the CB_ADDSTRING message is the index of the item you just added. So you can then use that index with the CB_SETITEMDATA message to assign that item a unique value. Then if another string is added and causes the list to be reordered, you can use CB_GETITEMDATA to identify each item, since its index can change. Unless you disable the sorting, in which case the index is good enough to use as the identifier.

Share this post


Link to post
Share on other sites

This topic is 4864 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this