Microsoft KB Archive/66365

{|
 * width="100%"|

HOWTO: Process a CBN_SELCHANGE Notification Message

 * }

Q66365

-

The information in this article applies to:


 * Microsoft Win32 Software Development Kit (SDK)
 * Microsoft Windows Software Development Kit (SDK) versions 3.0, 3.1

-

SUMMARY
When a combo box receives a CBN_SELCHANGE notification message, GetDlgItemText will give the text of the previous selection and not the text of the new selection.

To get the text of the new selection, send the CB_GETCURSEL message to retrieve the index of the new selection and then send a CB_GETLBTEXT message to obtain the text of that item.

MORE INFORMATION
When an application receives the CBN_SELCHANGE notification message, the edit/static portion of the combo box has not been updated. To obtain the new selection, send a CB_GETLBTEXT message to the combo box control. This message places the text of the new selection in a specified buffer. The following is a brief code fragment:

  ...  /* Other code. */

case CBN_SELCHANGE: hCombo = LOWORD(lParam); /* Get combo box window handle. */

/* Get index of current selection and the text of that selection. */

index = SendMessage(hCombo, CB_GETCURSEL, (WORD)0, 0L); SendMessage(hCombo, CB_GETLBTEXT, (WORD)index, (LONG)buffer); break;

... /* Other code. */ NOTE: For Win32 applications, change the WORD and LONG casts to WPARAM and LPARAM, respectively.

Additional query words: combobox win16sdk

Keywords : kbComboBox kbCtrl kbOSWinNT kbOSWin2000 kbSDKWin32 kbGrpDSUser kbOSWin

Issue type : kbhowto

Technology : kbWin32SDKSearch kbAudDeveloper kbWin3xSearch kbSDKSearch kbWin32sSearch kbWinSDKSearch kbWinSDK300 kbWinSDK310