Using Common Controls in a Dialog Box
The Windows common controls can be used in dialog boxes, form views, record views, and any other window based on a dialog template. The following procedure, with minor changes, will work for forms as well.
To use a common control in a dialog box
Place the control on the dialog template using the dialog editor.
Add to the dialog class a member variable that represents the control. In the Add Member Variable dialog box, select Control in the Category drop-down list.
If this common control is providing input to the program, declare additional member variable(s) in the dialog class to handle those input values.
Note ClassWizard will not support adding these member variables. You need to add them using the context menu in ClassView.
In for your dialog class, set the initial conditions for the common control. Using the member variable created in the previous step, use the member functions to set initial value and other settings. See the following descriptions of the controls for details on settings.
You can also use dialog data exchange (DDX) to initialize controls in a dialog box.
In handlers for controls on the dialog box, use the member variable to manipulate the control. See the following descriptions of the controls for details on methods.
Note The member variable will exist only as long as the dialog box itself exists. You will not be able to query the control for input values after the dialog box has been closed. To work with input values from a common control, override OnOK in your dialog class. In your override, query the control for input values and store those values in member variables of the dialog class.
You can also use dialog data exchange to set or retrieve values from the controls in a dialog box.