SendMessageCallback??

Started by
9 comments, last by kelcharge 19 years, 8 months ago
ok how would i use the above function to the best of its ability cause im finding the help docs i have to be very vague when explainging it??
True God of the TribunalKelchargeMy SiteMy Ugly Forums
Advertisement
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.
.
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.
_________ Evious Ltd.
ok i have a dropdown and i want each seperate item to do a different thing so would i use that function for it or not?
True God of the TribunalKelchargeMy SiteMy Ugly Forums
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.

ok how would i check which item is being used??
True God of the TribunalKelchargeMy SiteMy Ugly Forums
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*/); 
_________ Evious Ltd.
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.
.
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??
True God of the TribunalKelchargeMy SiteMy Ugly Forums
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.
.

This topic is closed to new replies.

Advertisement