Création d'une listbox

Résolu
lauremathieu Messages postés 3 Date d'inscription jeudi 30 avril 2009 Statut Membre Dernière intervention 8 février 2010 - 25 mai 2009 à 17:14
lauremathieu Messages postés 3 Date d'inscription jeudi 30 avril 2009 Statut Membre Dernière intervention 8 février 2010 - 31 mai 2009 à 13:22
Bonjour!
Je suis en train de faire un petit programme en C pour un projet et je suis assez nulle en informatique en fait... Il s'agit d'une boite de dialogue, et j'aimerais y intégrer une liste déroulante où l'utilisateur pourrait choisir entre différents items... Le problème c'est que je ne sais pas comment "remplir" ma listbox avec les données d'une table char.
Quelqu'un pourrait-il m'aider?
Voilà un petit bout de mon code: fichier ressources

Carburant DIALOG DISCARDABLE  0, 0, 200, 110
LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
STYLE DS_MODALFRAME | WS_POPUP| WS_VISIBLE | WS_CAPTION | WS_SYSMENU
CAPTION "Espace Particuliers"
FONT 11, "Arial"
BEGIN
    DEFPUSHBUTTON   "OK",IDOK,15,90,50,14
    PUSHBUTTON      "Quitter",IDCANCEL,114,90,50,14
    LTEXT            "Quel type de carburant utilisez-vous actuellement?",-1,5,25,150,30
    LISTBOX            ID_ESSAI,15,45,130,30,WS_VSCROLL
    LTEXT            "Votre choix :",-1,5,75,70,10
    EDITTEXT        IDC_TYPECARBURANT,60,74,45,11,ES_AUTOHSCROLL
END

et la fonction du fichier C correspondante:

BOOL CALLBACK espar (HWND hDlg, UINT iMsg, WPARAM wParam, LPARAM lParam)
     {

     char szBuffer[10];
     static HINSTANCE hInstance ;

     switch (iMsg)
          {
          case WM_INITDIALOG :
                  sprintf(szBuffer,"0");
                  SetDlgItemText(hDlg,IDC_TYPECARBURANT, (LPSTR)szBuffer);
                  return TRUE ;

          case WM_COMMAND :
                switch (LOWORD (wParam))
                    {
                    case IDOK :
                         GetDlgItemText(hDlg, IDC_TYPECARBURANT, (LPSTR)szBuffer, 10);
                         type_carburant = atof(szBuffer);
                         if (type_carburant==1)
                               {EndDialog (hDlg, FALSE) ;
                               if (DialogBox (hInstance, "EspaceParticuliers2", hDlg,
                                        essence))
                              InvalidateRect (hDlg, NULL, TRUE) ;
                              }
                         if (type_carburant==2)
                               {EndDialog (hDlg, FALSE) ;
                               if (DialogBox (hInstance, "Diesel", hDlg,
                                        diesel))
                              InvalidateRect (hDlg, NULL, TRUE) ;
                              }
                         if (type_carburant!=1 && type_carburant!=2)
                               {
                               if (DialogBox (hInstance, "Erreur", hDlg,
                                        erreur))
                              InvalidateRect (hDlg, NULL, TRUE) ;
                              }
                         return 0;

                    case IDCANCEL :
                         EndDialog (hDlg, FALSE) ;
                         return TRUE ;
                    }
               break ;
          }

       return FALSE ;
     }

Merci beaucoup!!

2 réponses

lauremathieu Messages postés 3 Date d'inscription jeudi 30 avril 2009 Statut Membre Dernière intervention 8 février 2010
31 mai 2009 à 13:22
Merci beaucoup!!! Problème résolu
3
BruNews Messages postés 21040 Date d'inscription jeudi 23 janvier 2003 Statut Modérateur Dernière intervention 21 août 2019
25 mai 2009 à 19:24
0
Rejoignez-nous