1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109
| //Déclarations :
typedef struct st1 INFO;
struct st1
{
int elapsedT;
int totalT;
char allT[25];
char status[256];
int vol;
int playing;
int numberItems;
};
typedef struct st2 LOAD;
struct st2
{
char path[MAXPATH][512];
char name[MAXPATH][128];
char temp[1000];
};
//avec :
INFO infos = {0, 0, "", "", 255, 0, 0};
LOAD load = {"", "", ""};
//...
if(LOWORD(wParam) == ID_BROWSE)
{
OPENFILENAME ofn;
CHAR szFile[5000]={0};
ZeroMemory(&ofn, sizeof(OPENFILENAME));
ofn.lStructSize = sizeof(OPENFILENAME);
ofn.hwndOwner = hDlg;
ofn.lpstrFile = szFile;
ofn.nMaxFile = 2998;
ofn.lpstrFilter =
"Mpeg layer 3\0*.mp3\0";
ofn.nFilterIndex = 1;
ofn.Flags =
OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST | OFN_ALLOWMULTISELECT | OFN_EXPLORER;
if (GetOpenFileName(&ofn)==TRUE)
{ /* Ici que ca commence... */
char *ap[3000] =
{
0
};
size_t n = 0;
ap[n] = szFile;
n++;
{
char *p_beg = szFile;
while (p_beg[0] != 0 || p_beg[ -1] != 0)
{
char *p_end = strchr(p_beg, 0);
if (p_end != NULL)
{
p_beg = p_end + 1;
ap[n] = p_beg;
n++;
}
else
{
break;
}
}
}
fprintf(file, "for(i = %d(numberItems) + 1 ; i < %d(n) + %d(numberItems) - 1; i++)\n\n", infos.numberItems, n, infos.numberItems);
for(i = infos.numberItems + 1 ; i < (n + infos.numberItems) - 1; i++)
{
size_t size = sizeof "\\" + strlen(ap[i]);
fprintf(file, "1 : i is %d\n", i);
fflush(file);
char *p = malloc (size);
strcpy (p, "\\");
strcat (p, ap[i]);
fprintf(file, "2 : p is %s \n", p);
fflush(file);
strcpy(load.temp, ap[0]); // attribue le chemin du dossier
strcat(load.temp, p); // concatène avec le nom de la musique
fprintf(file, "3 : load.temp is %s \n", load.temp);
fflush(file);
free(p), p = NULL;
strcpy(load.path[i], load.temp); // copie le tout dans mon tableau de string
fprintf(file, "4 : load.path[%d] is %s\n", i, load.path[i]);
fflush(file);
strcpy(load.name[i], ap[i]); // récupère le nom de la chanson
fprintf(file, "5 : load.name[%d] is %s\n", i, load.name[i]);
fflush(file);
SendMessage(hList, LB_ADDSTRING, 0, (LONG)load.name[i]); /* affiche dans la listbox */
fprintf(file, "6 : load.name[%d] added to listbox.\n\n", i);
fflush(file);
}
/* else (si c'est un unic-select)(Ne marche pas ... de toute façon ce n'est aps mon principal problème ... je verrai ça après.)
{
strcpy(path[0], szFile);
strcpy(name[0], strrchr(szFile, '\\'));
SendMessage(hList, LB_ADDSTRING, 0, (LONG)name[0]);
}*/
infos.numberItems = SendMessage(hList, LB_GETCOUNT, 0, 0);
fprintf(file, "7 : There are %d items in listbox.", infos.numberItems);
fflush(file);
SendMessage(hList, LB_SETCURSEL, 0, 0);
}
} |
Partager