Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Controlling a CEdit with CSpinButtonCtrl 1

Status
Not open for further replies.

ASingerMustDie

Programmer
Feb 1, 2001
17
GB
Hi Everyone :)

Now imagine I am wishing to use a CSpinButtonCtrl to change the numeric contents of a CEdit control.

This is simple enough, of course, if I wish to increment/decrement the CEdit value by 1. Now suppose I actually wish to multiply the spin value by 5, i.e. show 5 for 1, 10 for 2, 15, 20, 25, etc...

How would I go about this?

I thought that maybe I could add code to a function that executes each time the spin is updated such as:

ceditvar.SetWindowText(5 * cspinvar.GetPos());

(Let's pretend you can pass a numeric value to SetWindowText, that isnt the problem here)

However, there is no appropraite function to execute each time the spin has been updated. What can be done? :)

Thanks in advance,
ASMD
 
I'm really not sure if this is the best approach, but one potential method is to use the SetAccel member function of the CSpinButtonCtrl class:

UDACCEL accSpinMultiplier;
accSpinMultiplier.nSec = 0; // wait 0 seconds
accSpinMultiplier.nInc = 5; // increment by 5 each time
m_spinWhatever.SetAccel( 1, &accSpinMultiplier );
 
That is indeed a solution, thankyou.

However, I attempted to simply the problem for ease of reading and solution. Rather than increment by 5, I actually want the spin to move to the next or previous power of two, i.e.:

ceditvar.SetWindowText(pow(2, cspinvar.GetPos()));

And I don't immediately see how the solution you gave can be applied to this.

Thanks for your help much the same :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top