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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

newbie: MFC simple spin control

Status
Not open for further replies.

soren

Technical User
Jan 26, 2001
7
US
Greetings all,

I have a dialog based MFC app that contains only a edit control and a spin control which are buddies. The spin control does control the edit box, but... the up arrow decrements and the down arrow decrements. This is using the generated code -- I have written nothing... How do I fix this?

Or, where can I find a very simple MFC spin control tutorial -- i need a lot of these things (tutorials AND spin controls).

Any help appreciated; real help really appreciated.

Thanks!

-soren
 
HAve you checked what functionality is getting called when you click on the relevant spin controls?

Trace it through. Put a break point in where the decrement happens - hit the up button and see where the call came from.

M.

Hollingside Technologies, Making Technology work for you.
 
Thanks mrscary,
As you suggested, I put a break point on the only visible (non MS sequestered:) routine called when the up or down buttons are pressed. It is shown, in its entirety, below. I suppose that I should detect whether it is an up/down arrow event (how?) and update the variable accordingly. It surprised me that such an vanilla control would behave so very counter - intuitively.

On a tangentially related subject, is there a way (I'm sure there is) to bind a spin control to an Edit control other than the auto-buddy? I will have several of these on the screen, and don't want to run into a case where the sequence becomes corrupted. Thanks in advance -- I really do appreciate your help!

<snip: code>

void CspinctrlDlg::OnEnChangeEdit1()
{
// TODO: If this is a RICHEDIT control, the control will not
// send this notification unless you override the CDialog::OnInitDialog()
// function and call CRichEditCtrl().SetEventMask()
// with the ENM_CHANGE flag ORed into the mask.

// TODO: Add your control notification handler code here
}
 
What you need to do once you hit the break point is have a look at the call stack. This will show you where the program went to en-route to here.

M.

Hollingside Technologies, Making Technology work for you.
 
>the up arrow decrements and the down arrow decrements

Yes, this is standard behaviour (thank you M$).

Since it is an MFC app I assume you use the CSpinButtonCtrl.
From doc on CSpinButtonCtrl::SetRange :

MSDN said:
The default range for the spin button has the maximum set to zero (0) and the minimum set to 100. Since the maximum value is less than the minimum value, clicking the up arrow will decrease the position and clicking the down arrow will increase it. Use CSpinButtonCtrl::SetRange to adjust these values

/Per

&quot;It was a work of art, flawless, sublime. A triumph equaled only by its monumental failure.&quot;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top