Comment créer un contrôle ComboBoxEx
Cette rubrique montre comment créer un contrôle ComboBoxEx.
Bon à savoir
Technologies
Prérequis
- C/C++
- Programmation de l’interface utilisateur Windows
Instructions
Pour créer un contrôle ComboBoxEx, appelez la fonction CreateWindowEx en utilisant WC_COMBOBOXEX comme classe de fenêtre. Vous devez d’abord inscrire la classe window en appelant la fonction InitCommonControlsEx , tout en spécifiant le bit ICC_USEREX_CLASSES dans la structure INITCOMMONCONTROLSEX associée.
Exemple complet
La fonction définie par l’application suivante crée un contrôle ComboBoxEx avec le style CBS_DROPDOWN dans la fenêtre main.
// 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);
}
Rubriques connexes
Commentaires
https://aka.ms/ContentUserFeedback.
Bientôt disponible : Tout au long de 2024, nous allons supprimer progressivement GitHub Issues comme mécanisme de commentaires pour le contenu et le remplacer par un nouveau système de commentaires. Pour plus d’informations, consultezEnvoyer et afficher des commentaires pour