Solved

SpinButton with multiple ranges

Posted on 1998-07-30
5
216 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
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.
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

724 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