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!!