Spin Control Problem!!!
-
I have added a CEdit control and CSpin control to my dialog in the resource editor. So I attached the CSpin control to my CEdit control to inc and dec the value in the edit! But now, I have the problem, that the spin is working the wrong way! When I click the up button of the spin, the value in the edit will dec, and when I click the down button the value will inc! That's not what I am want! How can I change this???? -- Nice greets, Daniel.
-
I have added a CEdit control and CSpin control to my dialog in the resource editor. So I attached the CSpin control to my CEdit control to inc and dec the value in the edit! But now, I have the problem, that the spin is working the wrong way! When I click the up button of the spin, the value in the edit will dec, and when I click the down button the value will inc! That's not what I am want! How can I change this???? -- Nice greets, Daniel.
The "wrong way" is the default way for spin controls. you will have to use a SetRange32( int nLower, int nUpper ); Set nLower to the MAXIMUN set nUpper to the MINIMUM
-
The "wrong way" is the default way for spin controls. you will have to use a SetRange32( int nLower, int nUpper ); Set nLower to the MAXIMUN set nUpper to the MINIMUM
Thanks! -- Nice greets, Daniel.
-
I have added a CEdit control and CSpin control to my dialog in the resource editor. So I attached the CSpin control to my CEdit control to inc and dec the value in the edit! But now, I have the problem, that the spin is working the wrong way! When I click the up button of the spin, the value in the edit will dec, and when I click the down button the value will inc! That's not what I am want! How can I change this???? -- Nice greets, Daniel.
Hi Daniel, use CSpinButtonCtrl::SetRange(MIN_VALUE, MAX_VALUE) - this adjusts in which direction you have to press the arrows in order to de- or increase the value in the buddy CEdit box. Gero
-
I have added a CEdit control and CSpin control to my dialog in the resource editor. So I attached the CSpin control to my CEdit control to inc and dec the value in the edit! But now, I have the problem, that the spin is working the wrong way! When I click the up button of the spin, the value in the edit will dec, and when I click the down button the value will inc! That's not what I am want! How can I change this???? -- Nice greets, Daniel.
Hi Daniel, You can either give the ranges other way round or you can override CWnd's OnNotify method
BOOL YourClass::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult) { LPNMHDR pnmh = (LPNMHDR) lParam; if(pnmh->code == UDN_DELTAPOS ) { NM_UPDOWN* pNMUpDown = (NM_UPDOWN*)pnmh; // Check whether the value should be incremented or decremented if(pNMUpDown->iDelta < 0) { //value should be decremented } else { // value should be incremented } } return true; }
-ve value of delta would suggest decrement and +ve would suggest increment you can reverse the ways if you like. Hope that would be of your help. Nilesh :) -
Hi Daniel, You can either give the ranges other way round or you can override CWnd's OnNotify method
BOOL YourClass::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult) { LPNMHDR pnmh = (LPNMHDR) lParam; if(pnmh->code == UDN_DELTAPOS ) { NM_UPDOWN* pNMUpDown = (NM_UPDOWN*)pnmh; // Check whether the value should be incremented or decremented if(pNMUpDown->iDelta < 0) { //value should be decremented } else { // value should be incremented } } return true; }
-ve value of delta would suggest decrement and +ve would suggest increment you can reverse the ways if you like. Hope that would be of your help. Nilesh :)Thanks! -- Nice greets, Daniel.