HeaderPane
Main
Hide
Share Link
Print

Create

Creates a combo box control window and attaches it to the CSftBox object.

C

HWND hwndCtl = CreateWindowEx(dwExStyle,
        TEXT(SFTBOX_CLASS),
        NULL,
        dwStyle,
        x, y, nWidth, nHeight,
        hwndParent,
        (HMENU)(UINT_PTR) nID,
        hInstance,
        NULL);

C++

BOOL CSftBox::Create(DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID);
BOOL CSftBox::CreateEx(DWORD dwExStyle, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID);

Parameters

dwExStyle

Specifies the extended window style of the combo box.

dwStyle

Specifies the window style of the combo box, a combination of Windows window styles (WS_CHILD, WS_VISIBLE, WS_TABSTOP, etc.) and combo box window styles (SFTBOXSTYLE_DROPDOWNLIST, etc.).

rect

Specifies the combo box size and position. Can be either a CRect object or a RECT structure.

pParentWnd

Specifies the combo box's parent window.

nID

Specifies the combo box's control ID.

Returns

The return value is TRUE if the function was successful, otherwise FALSE is returned.

Comments

The Create and CreateEx functions create a combo box control window and attach it to the CSftBox object.

Create and CreateEx are C++ member functions of the CSftBox class. A C application creates a combo box using the Windows functions CreateWindow or CreateWindowEx with the window class SFTBOX_CLASS, as shown above. The window handle returned is used with all SftBox_xxx functions.

A combo box can also be defined in a dialog resource. In this case the combo box is created by Windows when the dialog is created and Create is not used. A C++ application attaches the control to a CSftBox object using CWnd::SubclassDlgItem or DDX_Control.

RegisterApp must be called before a combo box is created.

Examples

C View entire sample code

        GetWindowText(m_hwndSizes, szSize, sizeof(szSize)/sizeof(szSize[0]));
        size = _ttoi(szSize);
        if (size <= 0)
            size = 10;

        // convert the point size to the actual size
        size = MulDiv(size, GetDeviceCaps(hDC, LOGPIXELSY), 72);

        // Create the font and draw the sample
        hFont = CreateFont(-size, 0, 0, 0, weight, (BYTE) fItalic, 0, 0,
                    DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DRAFT_QUALITY, 0x4|DEFAULT_PITCH, szFont);
        hFont = (HFONT)SelectObject(hDC, hFont);
        DrawText(hDC, TEXT("AaBbCcYyZz"), 10, &rect, DT_CENTER|DT_VCENTER|DT_NOPREFIX|DT_SINGLELINE);
        hFont = (HFONT)SelectObject(hDC, hFont);
        DeleteObject(hFont);
    }

C++ View entire sample code

        m_Sizes.GetWindowText(text);
        int size = _ttoi(text);
        if (size <= 0)
            size = 10;

        // convert the point size to the actual size
        size = MulDiv(size, dc.GetDeviceCaps(LOGPIXELSY), 72);

        // Create the font and draw the sample
        CFont sampleFont;
        sampleFont.CreateFont(-size, 0, 0, 0, weight, (BYTE) fItalic, 0, 0,
                    DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DRAFT_QUALITY, 0x4|DEFAULT_PITCH, font);
        CFont* pOldFont = dc.SelectObject(&sampleFont);
        dc.DrawText(_T("AaBbCcYyZz"), 10, &rect, DT_CENTER|DT_VCENTER|DT_NOPREFIX|DT_SINGLELINE);
        dc.SelectObject(pOldFont);
    }

See Also C/C++ API | Categories | Notifications


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