![]() |
MFC ActiveX Controls - UpDown |
|
Overview |
|
Besides the spin
button, Visual C++ ships with an ActiveX control that provides the same functionality. To use this object, you can
right-click the form or dialog box and click Insert ActiveX Control. Then, on the Insert ActiveX Control dialog box,
click Microsoft UpDown Control. If there are two versions provided, you should select the latest, which usually has a higher version number. |
|
![]() The application we are about to develop is for a CD publishing small business. This company manufactures compact discs for self-promoting musicians and small business that want to sell their own CDs. When taking an order of a new CD, the company charges:
|
|
Using an UpDown Control |
|
To provide an updown control to your application, display the Insert ActiveX Control dialo box, select Microsoft UpDown Control 6.0 and click OK. If you plan to refer to the control in your code, you can add a variable for it. When you do this, Visual C++ would create and even implement its class, giving all of its code (its header and source files). You can then find out that the updown control is based on the CUpDown class which itself is based on CWnd, making it convinient to use CWnd properties and methods. void CDlgSpin::OnConfigureUpDown()
{
// TODO: Add your control notification handler code here
m_UpDown.SetMin(12);
m_UpDown.SetMax(250);
}
To get the minimum value of an updown control, call the GetMin() method. To get the maximum value of an updown control, call the GetMax() method. void CDlgSpin:: OnConfigureUpDown()
{
// TODO: Add your control notification handler code here
m_UpDown.SetMin(12);
m_UpDown.SetMax(250);
m_UpDown.SetValue(88);
}
To get the value of an updown control, call its GetValue() method.
![]() To programmatically set an incremental value, call the SetIncrement() method. Here is an example: void CDlgSpin:: OnConfigureUpDown()
{
// TODO: Add your control notification handler code here
m_UpDown.SetMin(12);
m_UpDown.SetMax(250);
m_UpDown.SetValue(88);
m_UpDown.SetIncrement(5);
}
|
|
|
The UpDown Control Events |
|
The updown control makes an object distinction between its button components. For example, when the user clicks the up pointing arrow button, the control fires the UpClick() event. On the other hand, when the user clicks the down pointing arrow button, the control sends a DownClick() event. These allow you to treat each event separately if you want.
|
|
|
| Copyright © 2003-2007 FunctionX, Inc. |
|
|