Solved

SpinButton with multiple ranges

Posted on 1998-07-30
5
209 Views
Last Modified: 2013-11-19
What would be a good way to have multiple ranges associated to one CSpinButtonCtrl.  For example, say I want the valid value of something to be 1-100 and 150-300 and 305.  So when the user was spinning up the numbers would be 1, 2, 3...98, 99, 100, 150, 151...299, 300, 305
0
Comment
Question by:joeslow
  • 2
  • 2
5 Comments
 
LVL 7

Expert Comment

by:psdavis
ID: 1319985
You should be able to override the OnRotateControl function to customize the spin button to do whatever numbering that you would want.

void CRotationCtrl::OnRotateControl(NMHDR* pNMHDR, LRESULT* pResult)
{
   NM_UPDOWN* pNMUpDown = (NM_UPDOWN*)pNMHDR;

// TODO: Add your control notification handler code here

   m_sRotatedAngle += -( pNMUpDown->iDelta * 10 );
   ... Whatever...

}

0
 
LVL 6

Expert Comment

by:snoegler
ID: 1319986
Hello

psdavis, while i have written this you sent already an answer :(
but i think i'll post it though, don't take this as an affront.
In the dialog or window containing the spin button, invoke ClassWizard. Select your spin-
button control, and create a function for the notification UDN_DELTAPOS(which is sent before
the spin button will display an altered value). Then ClassWizard
will generate a function like CMyDialog::OnDeltaposMySpinButton(...).
ClassWizard will generate a NM_UPDOWN structure from the parameters which makes the
handling easier(for a more detailed info, see UDN_DELTAPOS in the online help).
It has among others the elements iPos and iDelta ( ==> iPos+iDelta= new position). With those
you can check if the next change will result in a range which you do not want to have - all you
have to do now is to set iDelta to a value so that iPos+iDelta jump around the range.

void CMyDialog::OnDeltaposMySpinButton( ... )
{
  NM_UPDOWN* pNMUpDown = (NM_UPDOWN*)pNMHDR;
  // TODO: Add your control notification handler code here

  int proposed=(pNMUpDown->iPos+pNMUpDown->iDelta);
  int shouldbe=proposed;
  BOOL increasing=(pNMUpDown->iDelta>0);
  if(proposed>=20 && proposed<40) {
    if(increasing)
      shouldbe=40;
    else
      shouldbe=20;
  }
  if(proposed>=60 && proposed<80) {
    if(increasing)
      shouldbe=80;
    else
      shouldbe=60;
  }
  pNMUpDown->iDelta=shouldbe-pNMUpDown->iPos;

  *pResult = 0;
}

I hope this one helps you
0
 
LVL 7

Expert Comment

by:psdavis
ID: 1319987
Snoegler,

Definitely a better and more complete answer than I gave.  Don't feel bad about it.  These points are absolutely worthless anyway :).

JoeSlow,

If snoegler's answer gives you everything you need, go ahead and reject my answer and ask him to resend a dummy message for the points.

Phillip

0
 

Author Comment

by:joeslow
ID: 1319988
Snoegler's answer is what I was looking for...
Resend me a dummy message for the points
0
 
LVL 6

Accepted Solution

by:
snoegler earned 100 total points
ID: 1319989
Phillip, many thanks ...
So that's something i can't reject  ;)
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now