Visual C++ and MFC Programming 2nd Edition

(Martin Jones) #1

Chapter 17: Track-Based Controls Visual C++ and MFC Fundamentals


17.1 Spin Button...................................................................................................


17.1.1..Overview...............................................................................................


A spin button is a Windows control equipped with two opposite arrows. The user
clicks one of the arrows at one time to increase or decrease the current values of the
control. The value held by the control is also called its position. The values of a spin
button range from a minimum to a maximum. When the up arrow is clicked the value of
the control increases. If the user clicks and holds the mouse on the up pointing arrow. The
value of the control keeps increasing until it reaches its maximum and stops. The
opposite behavior applies when the user clicks or holds the mouse on the down-pointing
arrow.

Because a spin button is only equipped with arrows, it does not inherently show its
current value. Therefore, this control is usually accompanied by another, text-based,

control, usually an edit box, that indicates its position.

We are going the create a dialog box equipped with a large static control and three spin
buttons. The background color will change when the spin buttons change values:

Practical Learning: Introducing a Spin Button



  1. Create a new Dialog-Based application with no About Box and name it
    ColorPreview

  2. Set the Dialog Title to Color Preview and click Finish

  3. Delete the TODO line and the OK button

  4. Change the Caption of the Cancel button to Close

Free download pdf