Remplir un combobox win32 api

Résolu
cs_ssefyou Messages postés 119 Date d'inscription samedi 3 mai 2008 Statut Membre Dernière intervention 18 juillet 2013 - 24 déc. 2011 à 23:09
cs_ssefyou Messages postés 119 Date d'inscription samedi 3 mai 2008 Statut Membre Dernière intervention 18 juillet 2013 - 25 déc. 2011 à 19:17
Bonsoir ,

comment remplir un combobox sous winapi en c ?
j'ai cree un combo en utilisant la fonction createWindowEx()
mais je n'arrive pas à le remplir avec des chaines de caratères
j'ai utilisé la fonction SendMessage mais ça ne fonctionne pas
voilà mon code :


LRESULT CALLBACK WindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{

    switch (message)                  /* handle the messages */
    {
        case WM_CREATE:
            {

 //creation d'une label
 HWND  hlbl1=CreateWindowEx(0,"STATIC","Taille :",WS_CHILD| WS_VISIBLE ,15,20,50,20,hwnd,(HMENU)1,GetModuleHandle(NULL),NULL);

//creation de la zone de texte
HWND  hEdit=CreateWindowEx(WS_EX_CLIENTEDGE,
"EDIT","",WS_CHILD|WS_VISIBLE | ES_NUMBER,80,20,100,20,hwnd,(HMENU)2,GetModuleHandle(NULL),NULL);

//limiter le nbr des caracteres
SendMessage(hEdit,EM_SETLIMITTEXT,(WPARAM)6,0);

//creation d'une label
HWND  hlbl2=CreateWindowEx(0,"STATIC","Methode de Tri :",WS_CHILD| WS_VISIBLE ,230,20,120,20,hwnd,(HMENU)3,GetModuleHandle(NULL),NULL);

//creation du combobox
HWND hCombo = CreateWindowEx(WS_EX_CLIENTEDGE, "COMBOBOX",NULL, CBS_DROPDOWNLIST | WS_CHILD | CBS_SIMPLE | WS_VISIBLE,360, 20, 150, 20, hwnd, (HMENU)4,0,0);

// ajout des items au combo
SendMessage(hCombo,CB_ADDSTRING,0,(LPARAM)"azerty");
SendMessage(hCombo,CB_ADDSTRING,0,(LPARAM)"qwerty");



Merci d'avance

2 réponses

BruNews Messages postés 21040 Date d'inscription jeudi 23 janvier 2003 Statut Modérateur Dernière intervention 21 août 2019
25 déc. 2011 à 10:01
HWND hCombo = CreateWindowEx(WS_EX_CLIENTEDGE, "COMBOBOX", 0,
CBS_DROPDOWNLIST | WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_VSCROLL | CBS_HASSTRINGS,
360, 20, 150, 120, hwnd, (HMENU)4,0,0);
SendMessage(hCombo, CB_ADDSTRING, 0,(LPARAM) "azerty");
SendMessage(hCombo, CB_ADDSTRING, 0,(LPARAM) "qwerty");
SendMessage(hCombo, CB_SETCURSEL, 0, 0);

Ne pas perdre de vue qu'une dialog affichée par DialogBoxParam() arrivera à l'écran énormément plus vite qu'avec une série de CreateWindowEx().

ciao...
BruNews, MVP VC++
3
cs_ssefyou Messages postés 119 Date d'inscription samedi 3 mai 2008 Statut Membre Dernière intervention 18 juillet 2013 1
25 déc. 2011 à 19:17
Bonsoir,

Merci infiniment pour votre aide BruNews
le problème était au niveau de la largeur de mon combo

Merci
0
Rejoignez-nous