HeaderPane
Main
Hide
Share Link
Print

Creating a Dialog Resource

This section describes how to add a combo box control to a dialog using Visual Studio.

Adding a Combo Box to a Dialog

To add a SftBox/DLL control to a dialog, use the "Custom Control" item of the Toolbox in the dialog editor. Click on the item and then the dialog being designed to add a control.

Custom Control

Once a custom control has been added to a dialog, you can edit the control properties by using the View, Properties Window menu command.

To define a SftBox/DLL control, enter the class SftBoxControl60 in the edit field labeled Class. A window caption is not necessary, so the edit field marked Caption can be left blank.

Properties

The resulting entry in the resource script (*.rc file) of the application looks as follows (a dropdown list combo box, taken from the Colors sample):

CONTROL         "",IDC_BACKGROUND,"SftBoxControl60",WS_BORDER | WS_VSCROLL | WS_HSCROLL | WS_TABSTOP | 0x200,64,32,110,14

A dropdown or dropdown list combo box adjusts its height to the height of an item (and its column headers, if shown in the static portion), so the height defined in the dialog resource is only an approximation. By default, the top edge of the control remains in position; the SFTBOXSTYLE_ALIGNBOTTOM and SFTBOXSTYLE_ALIGNCENTER window styles change this. The height of the dropdown portion is defined at run-time using SetDroppedHeight. For a simple combo box, the height defined in the dialog resource includes the always visible item list.

SftBox/DLL Control Styles

To enter a SftBox/DLL window style in the User Control Properties dialog, use the following list to add the desired style values and enter the resulting hexadecimal value in the field marked Style. For detailed information, see "Window Styles".

The SftBox/DLL Wizard displays the style value as part of the generated source code so it can be copied.

One of the following basic combo box styles is used:

StyleValueDescription
SFTBOXSTYLE_SIMPLE0x00000000Creates a simple combo box, with an edit control portion and an item list that is always visible.
SFTBOXSTYLE_DROPDOWN0x00000100Creates a dropdown combo box, with an edit control portion, a dropdown button and a dropdown portion.
SFTBOXSTYLE_DROPDOWNLIST0x00000200Creates a dropdown list combo box, with a static portion, a dropdown button and a dropdown portion.

The following styles can be added:

StyleValueDescription
SFTBOXSTYLE_DISABLENOSCROLL0x00000001Prevents the scroll bars from being hidden when scrolling is not possible. The scroll bars are disabled instead.
SFTBOXSTYLE_LEFTBUTTONONLY0x00000020The combo box only responds to the left mouse button.
SFTBOXSTYLE_VARIABLE0x00000080Defines a combo box with variable height items. Without this style, all items have the same height.
SFTBOXSTYLE_ALIGNBOTTOM0x00000400The bottom edge of the control remains in position when the control adjusts its height.
SFTBOXSTYLE_ALIGNCENTER0x00000800The center of the control remains in position when the control adjusts its height.
SFTBOXSTYLE_AUTOHSCROLL0x00001000The edit control portion scrolls horizontally when text is entered that doesn't fit.
WS_BORDER0x00800000Creates a combo box with a border.
WS_CHILD0x40000000Creates a child window. Required.
WS_DISABLED0x08000000Creates a combo box that is initially disabled.
WS_GROUP0x00020000Specifies the first control of a group of controls.
WS_HSCROLL0x00100000The dropdown portion has a horizontal scroll bar when needed.
WS_TABSTOP0x00010000Specifies a control that can receive the keyboard focus when the user presses the TAB key.
WS_VISIBLE0x10000000Creates a combo box that is initially visible. Usually required.
WS_VSCROLL0x00200000The dropdown portion has a vertical scroll bar when needed.

The samples included with SftBox/DLL use the following style values in their dialog resources (in addition to WS_BORDER, WS_VSCROLL and WS_TABSTOP, and WS_HSCROLL for all combo boxes except the DragDrop lists and the DataInput city list):

ValueStylesSample
0x200SFTBOXSTYLE_DROPDOWNLISTColors, ItemImages
0x220SFTBOXSTYLE_DROPDOWNLIST | SFTBOXSTYLE_LEFTBUTTONONLYFonts (font names)
0x100SFTBOXSTYLE_DROPDOWNFonts (font styles, font sizes)
0x1100SFTBOXSTYLE_DROPDOWN | SFTBOXSTYLE_AUTOHSCROLLDataInput
0x1000SFTBOXSTYLE_SIMPLE | SFTBOXSTYLE_AUTOHSCROLLDragDrop

The combo box is customized at run-time, by defining its columns using SetColumns, adding items using AddString and setting other attributes. See Using C and Using C++/MFC.


Last Updated 11/22/2026 - (email)
© 2026 Softel vdm, Inc.