Salut @ tous,
Dans le cadre d'un projet en cours, je doit gérer des enregistrements et chargement de fichier et je n'arrive pas à changer le répertoire courant, voici le morceau de code concerné:
void gestionMenuFichier(int selection) {
char szFileName[MAX_PATH] = "";
char repertoireCourant[MAX_PATH];
ostringstream msg, title;
OPENFILENAME ofn;
GetCurrentDirectory(MAX_PATH,repertoireCourant);
strcat(repertoireCourant,"\\nuages\");
ofn.lpstrInitialDir = repertoireCourant;
MessageBox(NULL,ofn.lpstrInitialDir,"ofn.lpstrInitialDir",MB_OK|MB_ICONEXCLAMATION);
switch (selection) {
// Ouvrir
case 11 :
ZeroMemory(&ofn, sizeof(ofn));
ofn.lStructSize = sizeof(ofn); // SEE NOTE BELOW
ofn.hwndOwner = NULL;
ofn.lpstrFilter = "Text Files (*.txt)\0*.txt\0All Files (*.*)\0*.*\0";
ofn.lpstrFile = szFileName;
ofn.nMaxFile = MAX_PATH;
ofn.Flags = OFN_EXPLORER | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY;
ofn.lpstrDefExt = "txt";
if(GetOpenFileName(&ofn))
{
// Pour l'instant simplement affichier le nom du fichier
msg << "Fichier à charger: " << szFileName;
title << "Charger";
MessageBox(NULL,msg.str().c_str(),title.str().c_str(),MB_OK|MB_ICONEXCLAMATION);
}
break;
// Enregistrer
case 12 :
ZeroMemory(&ofn, sizeof(ofn));
ofn.lStructSize = sizeof(ofn); // SEE NOTE BELOW
ofn.hwndOwner = NULL;
ofn.lpstrFilter = "Text Files (*.txt)\0*.txt\0All Files (*.*)\0*.*\0";
ofn.lpstrFile = szFileName;
ofn.nMaxFile = MAX_PATH;
ofn.Flags = OFN_EXPLORER | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY |OFN_OVERWRITEPROMPT;
ofn.lpstrDefExt = "txt";
if(GetSaveFileName(&ofn))
{
// Pour l'instant simplement affichier le nom du fichier
msg << "Fichier ouvert: " << szFileName;
title << "Fichier ouvert";
MessageBox(NULL,msg.str().c_str(),title.str().c_str(),MB_OK|MB_ICONEXCLAMATION);
}
}
glutPostRedisplay();
}
Voici ce qu'affiche la première MessageBox (avec la chaine de caractère repertoireCourant):
ce qui est bien celui que je veux.
Et voici le dialogue OPENFILENAME (qui n'est pas dans le bon repertoire):
Est-ce que quelqu'un aurait une idée svp.
Merci.
Afficher la suite