Erstellen eines ComboBoxEx-Steuerelements

In diesem Thema wird das Erstellen eines ComboBoxEx-Steuerelements veranschaulicht.

Wichtige Informationen

Technologien

Voraussetzungen

  • C/C++
  • Windows Benutzeroberfläche-Programmierung

Anweisungen

Um ein ComboBoxEx-Steuerelement zu erstellen, rufen Sie die CreateWindowEx-Funktion auf, indem Sie WC _ COMBOBOXEX als Fensterklasse verwenden. Sie müssen zuerst die Window-Klasse registrieren, indem Sie die InitCommonControlsEx-Funktion aufrufen, während Sie das BIT FÜR DIE BENUTZEREX-KLASSEN des BENUTZERS INITCOMMONCONTROLSEX in der zugehörigen _ _ INITCOMMONCONTROLSEX-Struktur angeben.

Vollständiges Beispiel

Die folgende anwendungsdefinierte Funktion erstellt ein ComboBoxEx-Steuerelement mit dem _ CBS-DROPDOWN-Stil im Hauptfenster.

// CreateComboEx - Registers the ComboBoxEx window class and creates
// a ComboBoxEx control in the client area of the main window.
//
// g_hwndMain - A handle to the main window.
// g_hinst    - A handle to the program instance.
HWND WINAPI CreateComboEx(void)
{
    HWND hwnd;
    INITCOMMONCONTROLSEX icex;

    icex.dwSize = sizeof(INITCOMMONCONTROLSEX);
    icex.dwICC = ICC_USEREX_CLASSES;

    InitCommonControlsEx(&icex);

    hwnd = CreateWindowEx(0, WC_COMBOBOXEX, NULL,
                    WS_BORDER | WS_VISIBLE |
                    WS_CHILD | CBS_DROPDOWN,
                    // No size yet--resize after setting image list.
                    0,      // Vertical position of Combobox
                    0,      // Horizontal position of Combobox
                    0,      // Sets the width of Combobox
                    100,    // Sets the height of Combobox
                    g_hwndMain,
                    NULL,
                    g_hinst,
                    NULL);

    return (hwnd);
}

Informationen zu ComboBoxEx-Steuerelementen

ComboBoxEx-Steuerelementreferenz

Verwenden von ComboBoxEx-Steuerelementen

ComboBoxEx