views:

77

answers:

1

I'm trying to modify the selection of a particular combobox. I have already retrieved the handle successfully. However, when I call the function as below, I cannot modify the combobox selection properly:

r = SendMessage(cbox, CBN_SELCHANGE, 2, 0);

What would be the easiest method to accomplish what I want to do? Thanks in advance.

+4  A: 

CBN_SELCHANGE is just a notification, it is sent via a WM_COMMAND message to the parent window when selection changes by the user.

CB_SETCURSEL is the message you need to use.

SendMessage(cbox, CB_SETCURSEL, 2, 0);

Should work.

Michael
Also note that you can use the macro `ComboBox_SetCurSel(cbox, index)` defined in `<windowsx.h>`.
Adam Rosenfield
Thanks, it worked very well.
stanigator