Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MFC: Why does my spin control work backwards

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?

like image 693
Adam Tegen Avatar asked May 04 '09 20:05

Adam Tegen


2 Answers

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.

like image 95
RichieHindle Avatar answered Jan 03 '23 11:01

RichieHindle


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.

like image 28
Stephen C. Steel Avatar answered Jan 03 '23 12:01

Stephen C. Steel