- case CB_SETCURSEL:
- // Selection was set with SetSelection. Update the value too.
- if ((int)wParam > GetCount())
- m_value = wxEmptyString;
- else
- m_value = GetString(wParam);
- break;
+ case WM_SIZE:
+ // wxStaticBox can generate this message, when modifying the control's style.
+ // This causes the content of the combobox to be selected, for some reason.
+ case WM_STYLECHANGED:
+ {
+ // combobox selection sometimes spontaneously changes when its
+ // size changes, restore it to the old value if necessary
+ long fromOld, toOld;
+ GetSelection(&fromOld, &toOld);
+ WXLRESULT result = wxChoice::MSWWindowProc(nMsg, wParam, lParam);
+
+ long fromNew, toNew;
+ GetSelection(&fromNew, &toNew);
+
+ if ( fromOld != fromNew || toOld != toNew )
+ {
+ SetSelection(fromOld, toOld);
+ }
+
+ return result;
+ }