Forum |  HardWare.fr | News | Articles | PC | S'identifier | S'inscrire | Shop Recherche
1231 connectés 

  FORUM HardWare.fr
  Programmation

  [Visual C++] boite dlg Sauvegarde ferme l'application...

 


 Mot :   Pseudo :  
 
Bas de page
Auteur Sujet :

[Visual C++] boite dlg Sauvegarde ferme l'application...

n°35064
Moustaaki
.: ILITCH :. ésprit sibérie
Posté le 29-05-2001 à 10:07:58  profilanswer
 

Dans mon prog, j'utilise une boite de dialogue appelée par getSaveFileName(..)
 
Le pb, c'est que quand le programme appelle cette fonction, il se ferme...
 
 
Voilà le code, si quelqu'un pouvait regarder si il y des erreurs ou si quelqu'un pouvait le tester sur une autre machine, ça pourrait être sympatique...
 
char * returnChar = 0;
 
 OPENFILENAME * structSauvegarde = new OPENFILENAME();
 structSauvegarde->lStructSize = sizeof (OPENFILENAME) ;
 structSauvegarde->hwndOwner = hwnd ;
 structSauvegarde->lpstrFilter = filter ;
 structSauvegarde->nFilterIndex = 1 ;  
 structSauvegarde->lpstrFile = returnChar ;  
 structSauvegarde->nMaxFile = sizeof(returnChar) ;  
 structSauvegarde->lpstrFileTitle = NULL ;
 structSauvegarde->lpstrInitialDir = NULL ;
 structSauvegarde->lpstrTitle = "Sauvegarder le fichier" ;
 structSauvegarde->Flags = OFN_CREATEPROMPT | OFN_OVERWRITEPROMPT ;  
// view more : http://msdn.microsoft.com/library/ [...] 3_1hma.htm
 
 
 if (GetSaveFileName(structSauvegarde))
 {
  MessageBox(NULL, returnChar,
      NULL, MB_OK | MB_ICONINFORMATION | MB_SYSTEMMODAL | MB_DEFBUTTON2) ;
  return returnChar ;  
 }
 else
 {
  return NULL ;
 }
 
merci d'avance !  :jap:
 
 
 
 
(Visual C++, win98)

 

[edit]--Message édité par Moustaaki--[/edit]

mood
Publicité
Posté le 29-05-2001 à 10:07:58  profilanswer
 

n°35122
Moustaaki
.: ILITCH :. ésprit sibérie
Posté le 29-05-2001 à 11:19:03  profilanswer
 

les erreurs générées par le debugger :
 
Loaded 'C:\WINDOWS\SYSTEM\SHELL32.DLL', no matching symbolic information found.
Loaded 'C:\WINDOWS\SYSTEM\COMCTL32.DLL', no matching symbolic information found.
Loaded 'C:\WINDOWS\SYSTEM\SHLWAPI.DLL', no matching symbolic information found.
Loaded 'C:\WINDOWS\SYSTEM\COMDLG32.DLL', no matching symbolic information found.
Loaded 'C:\WINDOWS\SYSTEM\ADVAPI32.DLL', no matching symbolic information found.
Loaded 'C:\WINDOWS\SYSTEM\GDI32.DLL', no matching symbolic information found.
Loaded 'C:\WINDOWS\SYSTEM\USER32.DLL', no matching symbolic information found.
Loaded 'C:\WINDOWS\SYSTEM\KERNEL32.DLL', no matching symbolic information found.
Loaded 'C:\WINDOWS\SYSTEM\VERSION.DLL', no matching symbolic information found.
Loaded 'C:\WINDOWS\SYSTEM\OLEAUT32.DLL', no matching symbolic information found.
Loaded 'C:\WINDOWS\SYSTEM\OLE32.DLL', no matching symbolic information found.
Loaded 'C:\Program Files\Caere\OmniPagePro90\OPHOOK32.dll', no matching symbolic information found.
First-chance exception in tradNSP.exe (KERNEL32.DLL): 0xC0000005: Access Violation.
First-chance exception in tradNSP.exe (KERNEL32.DLL): 0xC0000005: Access Violation.
First-chance exception in tradNSP.exe (COMDLG32.DLL): 0xC0000005: Access Violation.
First-chance exception in tradNSP.exe (COMDLG32.DLL): 0xC0000005: Access Violation.
First-chance exception in tradNSP.exe (COMDLG32.DLL): 0xC0000005: Access Violation.
First-chance exception in tradNSP.exe (COMDLG32.DLL): 0xC0000005: Access Violation.
The program 'E:\hugo\MesDoc\Visual\tradNSP\Debug\tradNSP.exe' has exited with code 0 (0x0).

n°35123
Moustaaki
.: ILITCH :. ésprit sibérie
Posté le 29-05-2001 à 11:19:16  profilanswer
 

argl

n°35166
Amadeus
Posté le 29-05-2001 à 12:26:20  profilanswer
 

Il ya 2 err :
1) tu definit un ptr char que tu initialises a null (char * returnChar = 0), t'etonnes pas apres que ca merde.
2) tu utilse un new alors que ten a pas besoin
Essaies plutot ca :
 
char returnChar[MAX_PATH];  
 
OPENFILENAME structSauvegarde:
structSauvegarde.lStructSize = sizeof (OPENFILENAME) ;  
structSauvegarde.hwndOwner = hwnd ;  
structSauvegarde.lpstrFilter = filter ;  
structSauvegarde.nFilterIndex = 1 ;  
structSauvegarde.lpstrFile = returnChar ;  
structSauvegarde.nMaxFile = sizeof(returnChar) ;  
structSauvegarde.lpstrFileTitle = NULL ;  
structSauvegarde.lpstrInitialDir = NULL ;  
structSauvegarde.lpstrTitle = "Sauvegarder le fichier" ;  
structSauvegarde.Flags = OFN_CREATEPROMPT | OFN_OVERWRITEPROMPT ;  
// ...  la suite idem sauf kil faut passer l'addr de la struct :
GetSaveFileName(&structSauvegarde) au lieu de GetSaveFileName(structSauvegarde)

 

[edit]--Message édité par Amadeus--[/edit]

n°35214
Moustaaki
.: ILITCH :. ésprit sibérie
Posté le 29-05-2001 à 14:22:31  profilanswer
 

j'ai déclaré la variable char comme tu m'as dit, en global...
ensuite j'ai changé ça dans le code :
 
 // définition des paramètres pour la boite de dialogue de sauvegarde.
 OPENFILENAME structSauvegarde ;
 structSauvegarde.lStructSize = sizeof (OPENFILENAME) ;
 structSauvegarde.hwndOwner = hwnd ;
 structSauvegarde.lpstrFilter = filter ;
 structSauvegarde.nFilterIndex = 1 ;  
 structSauvegarde.lpstrFile = fileName ;  
 structSauvegarde.nMaxFile = sizeof(fileName) ;  
 structSauvegarde.lpstrFileTitle = NULL ;
 structSauvegarde.lpstrInitialDir = "C:\\Mes documents\\" ;
 structSauvegarde.lpstrTitle = "Sauvegarder le fichier" ;
 structSauvegarde.Flags = OFN_CREATEPROMPT | OFN_OVERWRITEPROMPT ;
// view more : http://msdn.microsoft.com/library/ [...] 3_1hma.htm
 
 
 if (GetSaveFileName(&structSauvegarde))
 {
  MessageBox(NULL, fileName,
      NULL, MB_OK | MB_ICONINFORMATION | MB_SYSTEMMODAL | MB_DEFBUTTON2) ;
  return fileName ;  
 }
 else
 {
  return NULL ;
 }
 
 
 
ET ça me fait toujours la même chose . violation d'accès.
Si j'ouvre le debugger, le context est : Comdlg32.dll, je suppose vue le nom et le contexte que c'est la dll "s'occupant" des boites de dialogues.  
 
Sans le debugger, je n'ai aucune erreur mais ça quite quand même.
 
ARGL
 
 
 
Petite info sup ; le debugger liste les erreurs suivantes pendant l'execution :
 
Loaded 'C:\WINDOWS\SYSTEM\SHELL32.DLL', no matching symbolic information found.
Loaded 'C:\WINDOWS\SYSTEM\COMCTL32.DLL', no matching symbolic information found.
Loaded 'C:\WINDOWS\SYSTEM\SHLWAPI.DLL', no matching symbolic information found.
Loaded 'C:\WINDOWS\SYSTEM\COMDLG32.DLL', no matching symbolic information found.
Loaded 'C:\WINDOWS\SYSTEM\ADVAPI32.DLL', no matching symbolic information found.
Loaded 'C:\WINDOWS\SYSTEM\GDI32.DLL', no matching symbolic information found.
Loaded 'C:\WINDOWS\SYSTEM\USER32.DLL', no matching symbolic information found.
Loaded 'C:\WINDOWS\SYSTEM\KERNEL32.DLL', no matching symbolic information found.
Loaded 'C:\WINDOWS\SYSTEM\VERSION.DLL', no matching symbolic information found.
Loaded 'C:\WINDOWS\SYSTEM\OLEAUT32.DLL', no matching symbolic information found.
Loaded 'C:\WINDOWS\SYSTEM\OLE32.DLL', no matching symbolic information found.
Loaded 'C:\Program Files\Caere\OmniPagePro90\OPHOOK32.dll', no matching symbolic information found.
First-chance exception in tradNSP.exe (KERNEL32.DLL): 0xC0000005: Access Violation.
First-chance exception in tradNSP.exe (KERNEL32.DLL): 0xC0000005: Access Violation.
First-chance exception in tradNSP.exe (COMDLG32.DLL): 0xC0000005: Access Violation.
The program 'E:\hugo\MesDoc\Visual\tradNSP\Debug\tradNSP.exe' has exited with code 0 (0x0).

 

[edit]--Message édité par Moustaaki--[/edit]

n°35234
Amadeus
Posté le 29-05-2001 à 14:45:20  profilanswer
 

// voila ta fonction retouche :
// elle marche : g fait un test vite fait donc ya pas de raison  
// kel marche pas chez toi
 
int Test(char* nomdefichier)
{
 
 OPENFILENAME structSauvegarde;
 char szNom[MAX_PATH];
 
 ZeroMemory(&structSauvegarde, sizeof(structSauvegarde));
 szNom[0] = '\0'; // n oublies surtout pas cette ligne
 structSauvegarde.lStructSize = sizeof (OPENFILENAME) ;
 structSauvegarde.hwndOwner = 0 ;
 structSauvegarde.lpstrFilter = "hfr (*.hfr)\0*.hfr\0" ;
 structSauvegarde.nFilterIndex = 1 ;  
 structSauvegarde.lpstrFile = szNom ;  
 structSauvegarde.nMaxFile = sizeof(szNom) ;  
 structSauvegarde.lpstrFileTitle = NULL ;
 structSauvegarde.lpstrInitialDir = "C:\\" ;
 structSauvegarde.lpstrTitle = "Sauvegarder le fichier" ;
 structSauvegarde.Flags = OFN_CREATEPROMPT | OFN_OVERWRITEPROMPT ;
 
 if (GetSaveFileName(&structSauvegarde))
 {
   MessageBox(NULL, (LPCTSTR)szNom,
   NULL, MB_OK | MB_ICONINFORMATION | MB_SYSTEMMODAL | MB_DEFBUTTON2) ;
   strcpy(nomdefichier,  (const char*)szNom);
   return 0; // retourne juste un int et la chaine nomdefichier contiendra... le nom de fichier    :)
 }
 // le else est superflu ici
 return -1; // erreur
 
 // et ca marche! teste et approuve!
}

n°35243
Moustaaki
.: ILITCH :. ésprit sibérie
Posté le 29-05-2001 à 15:00:58  profilanswer
 

merci beaucoup !
c'est vraiment sympa de ta part !
 
 
ça marche nikel...

 

[edit]--Message édité par Moustaaki--[/edit]

n°35249
Amadeus
Posté le 29-05-2001 à 15:07:12  profilanswer
 

de rien ;)
 

Moustaaki a écrit a écrit :

merci beaucoup !
c'est vraiment sympa de ta part !




Aller à :
Ajouter une réponse
  FORUM HardWare.fr
  Programmation

  [Visual C++] boite dlg Sauvegarde ferme l'application...

 

Sujets relatifs
[ Visual C++ ] créer une console (style dos) dans une interface ?modifier des libelles de boite de dialogue en javascript
Application DOS en mode VGAVisual Studio 6
Visual Studio 7.0Visual C++ comment faut faire ????
Communication entre un lobby directx et son applicationDocumentation Visual C++
[VB6] rafraichir une fenetre iexplore a partir de visual basic !!![Visual C++] pourquoi mon appli ne se termine pas ?
Plus de sujets relatifs à : [Visual C++] boite dlg Sauvegarde ferme l'application...


Copyright © 1997-2022 Hardware.fr SARL (Signaler un contenu illicite / Données personnelles) / Groupe LDLC / Shop HFR