Introduction
In this Exercise, We will use track bars to change the color of a static control. Prerequisites:
Dialog Boxes Colors Static Text Control Slider Control Timer There are various types of objects you can use to preview a color. The static control is convenient because it provides a ready made rectangle although you still have to configure it because it is not natively equip to handle the change of colors. To do this, you can consider it simply as a platform with a client area. When painting this control, you mostly use the properties of the CWnd class. For this reason, you could as well use a list box, a tree view, or a list view, etc. to allow the user to set the variances of a color, you can use sliders, scroll bars, or spin buttons, etc. In this exercise, we will use the sliders simply because we decide to use them. They do not necessarily provide more or less functionality than scroll bars or spin buttons. Giving live and necessary feedback to the user is one of the greatest assets of a friendly application. On this application, we will use static text controls To Show the Red, G Reen, And Blue Values of a Color.
Creating the application
The simplest static control is considered a label. It consists of a simple object that displays text. The user can not directly change this text unless you programmatically allow it. This form of the static control is the simplest control you can use in an MFC application. to add a simple label to a dialog box, you can click the Static Text button on the Controls toolbar and click on the dialog box. The only thing you need to do is to change the Caption property on the Properties window. If you can not add a label to the dialog box when designing it, you can programmatically create one. This is done using the CStatic class and calling the Create () method. By default, you can not change the properties of a static control unless you state this explicitly. This can be done in various ways. For example you can declare a CString variable, set its value using the Format method, then call the SetDlgItemText () function and change the text of the static control using its identifier.