Solved

SpinButton with multiple ranges

Posted on 1998-07-30
5
214 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

Suggested Solutions

Title # Comments Views Activity
Different colored text in ComboBox without Subclassing 8 65
Windows Drag & Drop Location 2 108
while loop over for loop 7 115
sum13 challenge 24 121
In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
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 …
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.
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

840 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