I have a combobox in a dialog which I populate in the resource editor with this string:
-12;-11;-10;-9;-8;-7;-6;-5;-4;-3;-2;-1;0;1;2;3;4;5;6;7;8;9;10;11;12
If the user chooses a new number from the combobox lots of other things happen in the dialog, then I select the number chosen again, this time programatically. (Some numbers are not allowed and the calculation is not simple.) The combo is a DropList type.
Anyway the problem is that if the user selects "-1", when I use
const int ikCurSel = m_cbInclinePcent.SelectString (-1,szIncline) ;
it all works, the correct string is selected, as long as I do not use szIncline = "-1". If I try to select "-1" the combo selects the first string, ikCurSel becomes 0, and the actual string selected is "-12". So the user selects "-1" then sees his selection change to "-12". If he selects any other value, "-2" for example, or "11" then all works as it should.
The first -1 in the SelectString call is called nStartAfter and means "search for a match from and including the first string". The second parameter is a string, with, in this case "-1" in it, as a string.
Summarising: Why does
SelectString (-1,"-1") ;
not work, selecting the first string in the list rather than the 12th ?