views:

532

answers:

2

Using MS Visual Studio, I have attached a spin control to an edit control using the "auto buddy" property.

The spin control alters the edit box, but the up button decrements the value and the down button increments the value.

How do you fix this?

+3  A: 

Because that's how it is. 8-) You work around it using SetRange.

The documentation says "The default range for the spin button has the maximum set to zero (0) and the minimum set to 100. Because the maximum value is less than the minimum value, clicking the up arrow will decrease the position and clicking the down arrow will increase it. Use CSpinButtonCtrl::SetRange to adjust these values." ...without any decent explanation.

RichieHindle
+3  A: 

The reason it works this way is because a spin control is just a thinly veiled scroll bar, and windows use a coordinate system where rows increase as you move down (so the down arrow increases the value).

To fix it, just interchange the min and max values you are currently useing when you call SetRange.

Stephen C. Steel