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

  FORUM HardWare.fr
  Programmation
  C

  Win Api : L'utilisation du menu fait planter le programme

 


 Mot :   Pseudo :  
 
Bas de page
Auteur Sujet :

Win Api : L'utilisation du menu fait planter le programme

n°1441977
acryline
Posté le 13-09-2006 à 17:22:27  profilanswer
 

Bonjour,
 
          dernier recours avant de tout recommencer mon programme depuis le début... :(  
Je vais essayer d'exposer le problème mais ça ne va pas être simple. Tout d'abord j'ai un code assez long,
et ne sachant pas du tout d'où vient le bogue je ne vais pas recopier tout le code ici.
 
J'ai créer une fenêtre principale avec un menu que je définis dans une fonction.
Le programme s'ouvre correctement, aucune erreur n'est signalée.
Mais lorsque j'utilise certaines commandes du menu le programme plante. Par exemple le passage d'un affichage à un autre en passant pas le menu fait planter le programme et cela ne se produit pas si j'utilise un bouton "fermer" qui utilise pourtant exactement le même processus (même fonction de fermeture).
 
J'ai déjà tout regardé tout discéqué, je ne trouve pas ... help !   :??:  
 
ALors pour les plus courageux j'ai mis mon code (programme pas terminé) ici
Merci !

Message cité 1 fois
Message édité par acryline le 13-09-2006 à 17:33:13
mood
Publicité
Posté le 13-09-2006 à 17:22:27  profilanswer
 

n°1442057
Emmanuel D​elahaye
C is a sharp tool
Posté le 13-09-2006 à 20:21:58  profilanswer
 

acryline a écrit :

ALors pour les plus courageux j'ai mis mon code (programme pas terminé) ici
Merci !


Ne compile pas. 111 warnings, c'est pas sérieux...


Project   : Acryline
Compiler  : GNU GCC Compiler (called directly)
Directory : C:\dev\acryline\
--------------------------------------------------------------------------------
Switching to target: default
Compiling: main.c
main.c: In function `WinMain':
main.c:68: warning: assignment makes integer from pointer without a cast
main.c: At top level:
main.c:21: warning: unused parameter 'hPrevInstance'
main.c:21: warning: unused parameter 'lpCmdLine'
main.c:21: warning: unused parameter 'nCmdShow'
Compiling: procedures.c
procedures.c: In function `Procedure':
procedures.c:18: warning: missing braces around initializer
procedures.c:18: warning: (near initialization for `lettre1[0]')
procedures.c:75: warning: passing arg 1 of `SelectObject' makes pointer from integer without a cast
procedures.c:77: warning: passing arg 1 of `SetTextColor' makes pointer from integer without a cast
procedures.c:78: warning: passing arg 1 of `SetBkMode' makes pointer from integer without a cast
procedures.c:81: warning: passing arg 1 of `SetClassLongA' makes pointer from integer without a cast
procedures.c:83: warning: passing arg 1 of `SelectObject' makes pointer from integer without a cast
procedures.c:15: warning: unused variable `texte'
procedures.c:22: warning: unused variable `texte2'
procedures.c:23: warning: unused variable `wc'
Compiling: ressources.rc
Compiling: fonction.c
fonction.c: In function `ecrireTexte':
fonction.c:73: warning: passing arg 2 of `lstrcpyA' from incompatible pointer type
fonction.c:79: warning: passing arg 1 of `lstrlenA' from incompatible pointer type
fonction.c:79: warning: passing arg 4 of `TextOutA' from incompatible pointer type
fonction.c: At top level:
fonction.c:120: warning: return type defaults to `int'
fonction.c:120: warning: conflicting types for 'chargerFichier'
fonction.h:73: warning: previous declaration of 'chargerFichier' was here
fonction.c: In function `changerImage':
fonction.c:153: warning: passing arg 1 of `lstrlenA' from incompatible pointer type
fonction.c: In function `dessinerCouverture':
fonction.c:186: warning: unused variable `i'
fonction.c: In function `dessinerBouton':
fonction.c:274: warning: unused variable `largeur'
fonction.c: In function `redessinerBouton':
fonction.c:317: warning: missing initializer
fonction.c:317: warning: (near initialization for `taille.top')
fonction.c: In function `messagesBoutonsCouv':
fonction.c:454: warning: missing braces around initializer
fonction.c:454: warning: (near initialization for `ficheCherchee.nomFiche')
fonction.c:454: warning: missing initializer
fonction.c:454: warning: (near initialization for `ficheCherchee.prenomFiche')
fonction.c:454: warning: unused variable `ficheCherchee'
fonction.c: In function `ecrireNomsListe':
fonction.c:558: warning: passing arg 9 of `ecrireTexte' makes integer from pointer without a cast
fonction.c:558: warning: passing arg 14 of `ecrireTexte' makes integer from pointer without a cast
fonction.c:570: warning: passing arg 9 of `ecrireTexte' makes integer from pointer without a cast
fonction.c:570: warning: passing arg 14 of `ecrireTexte' makes integer from pointer without a cast
fonction.c:580: warning: passing arg 9 of `ecrireTexte' makes integer from pointer without a cast
fonction.c:580: warning: passing arg 14 of `ecrireTexte' makes integer from pointer without a cast
fonction.c:587: warning: int format, long int arg (arg 3)
fonction.c: In function `faireListe':
fonction.c:624: warning: unused variable `j'
fonction.c: In function `nouvelleFiche':
fonction.c:698: warning: missing braces around initializer
fonction.c:698: warning: (near initialization for `coorT[0]')
fonction.c:698: warning: missing initializer
fonction.c:698: warning: (near initialization for `coorT[0].cy')
fonction.c:733: warning: passing arg 9 of `dessinerImage' from incompatible pointer type
fonction.c: In function `dessinerEdit':
fonction.c:739: warning: missing initializer
fonction.c:739: warning: (near initialization for `taille.top')
fonction.c:742: warning: missing braces around initializer
fonction.c:742: warning: (near initialization for `coorE[0]')
fonction.c:742: warning: missing braces around initializer
fonction.c:742: warning: (near initialization for `coorB[0]')
fonction.c:745: warning: missing braces around initializer
fonction.c:745: warning: (near initialization for `elem[0]')
fonction.c:782: warning: passing arg 1 of `CreateWindowExA' makes integer from pointer without a cast
fonction.c:812: error: `LBS_COMBOBOX' undeclared (first use in this function)
fonction.c:812: error: (Each undeclared identifier is reported only once
fonction.c:812: error: for each function it appears in.)
fonction.c:814: warning: passing arg 1 of `CreateWindowExA' makes integer from pointer without a cast
fonction.c:822: warning: passing arg 1 of `CreateWindowExA' makes integer from pointer without a cast
fonction.c:830: warning: passing arg 1 of `CreateWindowExA' makes integer from pointer without a cast
fonction.c:739: warning: unused variable `taille'
fonction.c:740: warning: unused variable `hdc'
fonction.c:743: warning: unused variable `styleEx'
fonction.c: In function `messagesFiche':
fonction.c:841: warning: missing braces around initializer
fonction.c:841: warning: (near initialization for `fiche.nomFiche')
fonction.c:841: warning: missing initializer
fonction.c:841: warning: (near initialization for `fiche.prenomFiche')
fonction.c:840: warning: unused variable `i'
fonction.c:840: warning: unused variable `j'
fonction.c:842: warning: unused variable `enregistrer'
fonction.c:843: warning: unused variable `texte'
fonction.c:920:9: warning: unknown escape sequence: '\040'
fonction.c:927:9: warning: unknown escape sequence: '\040'
fonction.c:936:9: warning: unknown escape sequence: '\040'
fonction.c: In function `testNombre':
fonction.c:953: warning: int format, long int arg (arg 3)
fonction.c: In function `testFiche':
fonction.c:960: warning: missing braces around initializer
fonction.c:960: warning: (near initialization for `bout[0]')
fonction.c: In function `enregistrerFiche':
fonction.c:995: warning: missing braces around initializer
fonction.c:995: warning: (near initialization for `ficheChargees[0]')
fonction.c:995: warning: missing initializer
fonction.c:995: warning: (near initialization for `ficheChargees[0].prenomFiche')
fonction.c:992: warning: unused variable `FileSize'
fonction.c: In function `ordreAlpha':
fonction.c:1102: warning: missing braces around initializer
fonction.c:1102: warning: (near initialization for `ficheTest.nomFiche')
fonction.c:1102: warning: missing initializer
fonction.c:1102: warning: (near initialization for `ficheTest.prenomFiche')
fonction.c:1103: warning: missing braces around initializer
fonction.c:1103: warning: (near initialization for `mot[0]')
fonction.c:1119: warning: implicit declaration of function `toupper'
fonction.c:1119: warning: passing arg 1 of `strncmp' makes pointer from integer without a cast
fonction.c:1119: warning: passing arg 2 of `strncmp' makes pointer from integer without a cast
fonction.c: At top level:
fonction.c:888: warning: unused parameter 'hwnd'
fonction.c:888: warning: unused parameter 'hBouton'
fonction.c:888: warning: unused parameter 'hEdit'
fonction.c:888: warning: unused parameter 'uMsg'
fonction.c:888: warning: unused parameter 'wParam'
fonction.c:889: warning: unused parameter 'lParam'
fonction.c:889: warning: unused parameter 'temoins'
fonction.c:889: warning: unused parameter 'photo'
fonction.c:837: warning: unused parameter 'uMsg'
fonction.c:737: warning: unused parameter 'temoins'
fonction.c:737: warning: unused parameter 'nombre'
fonction.c:695: warning: unused parameter 'hwnd'
fonction.c:622: warning: unused parameter 'hwnd'
fonction.c:547: warning: unused parameter 'hwnd'
fonction.c:449: warning: unused parameter 'uMsg'
fonction.c:377: warning: unused parameter 'uMsg'
fonction.c:378: warning: unused parameter 'lParam'
fonction.c:272: warning: unused parameter 'y'
fonction.c:214: warning: unused parameter 'ps'
fonction.c:214: warning: unused parameter 'texte'
fonction.c:214: warning: unused parameter 'hBouton'
fonction.c:184: warning: unused parameter 'hwnd'
fonction.c:184: warning: unused parameter 'ps'
fonction.c:59: warning: unused parameter 'famillePolice'
fonction.c: In function `ecrireTexte':
fonction.c:71: warning: statement with no effect
Process terminated with status 1 (0 minutes, 17 seconds)
3 errors, 111 warnings


J'ai ajouté ça :  


#define LBS_COMBOBOX 0x8000


et ça compile. Trop cool le petit serpent !


Message édité par Emmanuel Delahaye le 13-09-2006 à 20:27:35

---------------
Des infos sur la programmation et le langage C: http://www.bien-programmer.fr Pas de Wi-Fi à la maison : http://www.cpl-france.org/
n°1442060
acryline
Posté le 13-09-2006 à 20:31:22  profilanswer
 

Mais avec code::Blocks je n'ai pas de warning .

n°1442062
acryline
Posté le 13-09-2006 à 20:35:13  profilanswer
 

Oui  
 
#define LBS_COMBOBOX 0x8000
 
je l'avais aussi ajouté... mais ça bogue toujours
 
Je vais voir les warning avec Visual déjà... T'as pas tort  :)


Message édité par acryline le 13-09-2006 à 20:36:31
n°1442063
Emmanuel D​elahaye
C is a sharp tool
Posté le 13-09-2006 à 20:44:14  profilanswer
 

acryline a écrit :

Mais avec code::Blocks je n'ai pas de warning .


Essaye avec -Wall -Wextra -O2
 


---------------
Des infos sur la programmation et le langage C: http://www.bien-programmer.fr Pas de Wi-Fi à la maison : http://www.cpl-france.org/
n°1442351
acryline
Posté le 14-09-2006 à 12:10:40  profilanswer
 

Emmanuel Delahaye a écrit :

Essaye avec -Wall -Wextra -O2


 
Je viens d'essayer ces options dans code::blocks et j'ai toujours :
 

Citation :


Checking for existence: D:\Programmation\Carnet\Carnet.exe
Executing: "D:\Programmation\Carnet\Carnet.exe"  (in .)
Process terminated with status 0 (0 minutes, 3 seconds)
0 errors, 0 warnings


 
Dans Visual en revanche c'est comme tu dis... plus de 130 warnings !
 
Edité :
Je viens d'enlever les warnings hormis  les warnings qui n'acceptent pas strncpy à la place de strncpy_s et strncat à la place de strncat_s.  
Le bogue reste et j'obtiens le message suivant dans code::Blocks

Citation :


Exception non gérée à 0x00402632 dans Carnet.exe : 0xC0000005:  
Violation d'accès lors de l'écriture à l'emplacement 0x0040793c.


 
Adresse du code avec les warnings en moins : ici


Message édité par acryline le 14-09-2006 à 12:51:04
n°1442523
anordem
Posté le 14-09-2006 à 15:57:57  profilanswer
 

Salut!
 
Serait il possible d'avoir l'exécutable?

n°1442544
acryline
Posté le 14-09-2006 à 16:26:49  profilanswer
 

anordem a écrit :

Salut!
 
Serait il possible d'avoir l'exécutable?


Voilà j'ai inclu l'exécutable dans le fichier rar mis en lien dans mon message précédent. :)

n°1442651
anordem
Posté le 14-09-2006 à 18:45:09  profilanswer
 

Merci. :)
 
Bon, après quelques rapides tests, je pense que le problème se trouve au niveau de cette fonction:

Code :
  1. void dessinerImage(..., BOOL*test) {
  2. ...
  3. if (!hBitmap)*test=FALSE;
  4. ...
  5. }


Plus précisèment, le paramètre test provoque une violation d'accès qui vient, je pense, d'un problème de manipulation du pointeur.
 
C'est la seule erreur que j'ai eu, et en corrigeant les droits en écriture, le programme fonctionne.
Ceci dit, il y a quand même quelques problèmes d'affichage et de rafraichissement. :)

n°1442655
acryline
Posté le 14-09-2006 à 18:55:22  profilanswer
 

anordem a écrit :

Merci. :)
 
Bon, après quelques rapides tests, je pense que le problème se trouve au niveau de cette fonction:

Code :
  1. void dessinerImage(..., BOOL*test) {
  2. ...
  3. if (!hBitmap)*test=FALSE;
  4. ...
  5. }


Plus précisèment, le paramètre test provoque une violation d'accès qui vient, je pense, d'un problème de manipulation du pointeur.
 
C'est la seule erreur que j'ai eu, et en corrigeant les droits en écriture, le programme fonctionne.
Ceci dit, il y a quand même quelques problèmes d'affichage et de rafraichissement. :)


 
 
 
Merci c'est très sympa d'avoir cherché le problème, j'essaie de corriger demain et je donne des nouvelles, là j'arrête. En fait je n'avais pas corrigé tous les avertissements.Ce bogue m'a obligée à le faire et  ce n'est pas plus mal. :)


Message édité par acryline le 15-09-2006 à 07:26:44
mood
Publicité
Posté le 14-09-2006 à 18:55:22  profilanswer
 

n°1442802
acryline
Posté le 15-09-2006 à 07:24:23  profilanswer
 

Voilà maintenant j'ai nettoyé tous les warnings (sauf ceux qui me signalent une variable inutilisée dans quelques fonctions).
 
J'ai également remplacé le pointeur sur la variable "test" par la variable elle-même qui est, cette fois, retournée. Mais le problème reste.  :??:  
 
Voici le code tout propre ici avec l'exécutable correspondant.
 
La personne qui m'a conseillée de venir exposer mon problème ici m'a parlé de la pile mais ne savait pas trop comment faire. Qu'en pensez-vous ? Que dois-je faire ?
 
 Merci

n°1442809
Emmanuel D​elahaye
C is a sharp tool
Posté le 15-09-2006 à 08:23:44  profilanswer
 

acryline a écrit :

Voici le code tout propre ici avec l'exécutable correspondant.


J'appelle pas ça propre. Je te conseille de travailler sous Code::Blocks avec les options -Wall -Wextra -O2. (je l'ai déjà dit ou je deviens gateux ?)
 
Je mets en gras les bugs graves à corriger proprement et en connaissance de cause.

Citation :

Project   : Acryline
Compiler  : GNU GCC Compiler (called directly)
Directory : C:\dev\acryline\
--------------------------------------------------------------------------------
Switching to target: default
Compiling: main.c
main.c:22: warning: unused parameter 'hPrevInstance'
main.c:22: warning: unused parameter 'lpCmdLine'
main.c:22: warning: unused parameter 'nCmdShow'
Compiling: procedures.c
procedures.c: In function `Procedure':
procedures.c:17: warning: missing braces around initializer
procedures.c:17: warning: (near initialization for `lettre1[0]')
procedures.c:22: warning: missing braces around initializer
procedures.c:22: warning: (near initialization for `fiche[0]')
procedures.c:22: warning: missing initializer
procedures.c:22: warning: (near initialization for `fiche[0].prenomFiche')
procedures.c:53: warning: passing arg 1 of `LoadCursorFromFileA' from incompatible pointer type
procedures.c:63: warning: passing arg 1 of `LoadCursorFromFileA' from incompatible pointer type
procedures.c:72: warning: passing arg 1 of `SelectObject' makes pointer from integer without a cast
procedures.c:74: warning: passing arg 1 of `SetTextColor' makes pointer from integer without a cast
procedures.c:75: warning: passing arg 1 of `SetBkMode' makes pointer from integer without a cast
procedures.c:78: warning: passing arg 1 of `SetClassLongA' makes pointer from integer without a cast
procedures.c:80: warning: passing arg 1 of `SelectObject' makes pointer from integer without a cast
Compiling: ressources.rc
In file included from ressources.rc:9:
ressources.h:3:1: warning: "IDM_QUIT" redefined
In file included from ressources.rc:7:
fonction.h:19:1: warning: this is the location of the previous definition
In file included from ressources.rc:9:
ressources.h:4:1: warning: "IDM_NEW" redefined
In file included from ressources.rc:7:
fonction.h:20:1: warning: this is the location of the previous definition
In file included from ressources.rc:9:
ressources.h:5:1: warning: "IDM_OUVRIR" redefined
In file included from ressources.rc:7:
fonction.h:21:1: warning: this is the location of the previous definition
In file included from ressources.rc:9:
ressources.h:6:1: warning: "IDM_RELIURECOULEUR" redefined
In file included from ressources.rc:7:
fonction.h:22:1: warning: this is the location of the previous definition
In file included from ressources.rc:9:
ressources.h:7:1: warning: "IDM_RELIUREIMAGE" redefined
In file included from ressources.rc:7:
fonction.h:23:1: warning: this is the location of the previous definition
In file included from ressources.rc:9:
ressources.h:8:1: warning: "IDM_COUVCOULEUR" redefined
In file included from ressources.rc:7:
fonction.h:24:1: warning: this is the location of the previous definition
In file included from ressources.rc:9:
ressources.h:9:1: warning: "IDM_COUVIMAGE" redefined
In file included from ressources.rc:7:
fonction.h:25:1: warning: this is the location of the previous definition
In file included from ressources.rc:9:
ressources.h:10:1: warning: "IDM_ABOUT" redefined
In file included from ressources.rc:7:
fonction.h:26:1: warning: this is the location of the previous definition
In file included from ressources.rc:9:
ressources.h:11:1: warning: "IDM_ETIQOCTO" redefined
In file included from ressources.rc:7:
fonction.h:27:1: warning: this is the location of the previous definition
In file included from ressources.rc:9:
ressources.h:12:1: warning: "IDM_ETIQRONDE" redefined
In file included from ressources.rc:7:
fonction.h:28:1: warning: this is the location of the previous definition
In file included from ressources.rc:9:
ressources.h:13:1: warning: "IDM_ETIQETOILE" redefined
In file included from ressources.rc:7:
fonction.h:29:1: warning: this is the location of the previous definition
In file included from ressources.rc:9:
ressources.h:14:1: warning: "IDM_BOUTONAFF" redefined
In file included from ressources.rc:7:
fonction.h:30:1: warning: this is the location of the previous definition
In file included from ressources.rc:9:
ressources.h:15:1: warning: "IDM_BOUTONACT" redefined
In file included from ressources.rc:7:
fonction.h:31:1: warning: this is the location of the previous definition
In file included from ressources.rc:9:
ressources.h:16:1: warning: "IDM_BOUTONTEXTE" redefined
In file included from ressources.rc:7:
fonction.h:32:1: warning: this is the location of the previous definition
In file included from ressources.rc:9:
ressources.h:17:1: warning: "IDM_BOUTONTEXTEOFF" redefined
In file included from ressources.rc:7:
fonction.h:33:1: warning: this is the location of the previous definition
In file included from ressources.rc:9:
ressources.h:18:1: warning: "IDM_NOUVELLEFICHE" redefined
In file included from ressources.rc:7:
fonction.h:34:1: warning: this is the location of the previous definition
In file included from ressources.rc:9:
ressources.h:19:1: warning: "IDM_CURSEURS" redefined
In file included from ressources.rc:7:
fonction.h:35:1: warning: this is the location of the previous definition
In file included from ressources.rc:9:
ressources.h:20:1: warning: "IDM_RETOUR" redefined
In file included from ressources.rc:7:
fonction.h:36:1: warning: this is the location of the previous definition
Compiling: fonction.c
fonction.c: In function `dessinerEdit':
fonction.c:810: error: `LBS_COMBOBOX' undeclared (first use in this function)
fonction.c:810: error: (Each undeclared identifier is reported only once
fonction.c:810: error: for each function it appears in.)
fonction.c: At top level:
fonction.c:883: warning: unused parameter 'hwnd'
fonction.c:883: warning: unused parameter 'hBouton'
fonction.c:883: warning: unused parameter 'hEdit'
fonction.c:883: warning: unused parameter 'uMsg'
fonction.c:883: warning: unused parameter 'wParam'
fonction.c:884: warning: unused parameter 'lParam'
fonction.c:884: warning: unused parameter 'temoins'
fonction.c:884: warning: unused parameter 'photo'
fonction.c:835: warning: unused parameter 'uMsg'
fonction.c:737: warning: unused parameter 'temoins'
fonction.c:737: warning: unused parameter 'nombre'
fonction.c:695: warning: unused parameter 'hwnd'
fonction.c:622: warning: unused parameter 'hwnd'
fonction.c:547: warning: unused parameter 'hwnd'
fonction.c:450: warning: unused parameter 'uMsg'
fonction.c:378: warning: unused parameter 'uMsg'
fonction.c:379: warning: unused parameter 'lParam'
fonction.c:273: warning: unused parameter 'y'
fonction.c:215: warning: unused parameter 'ps'
fonction.c:215: warning: unused parameter 'texte'
fonction.c:215: warning: unused parameter 'hBouton'
fonction.c:187: warning: unused parameter 'hwnd'
fonction.c:187: warning: unused parameter 'ps'
fonction.c:60: warning: unused parameter 'famillePolice'
Process terminated with status 1 (0 minutes, 14 seconds)
3 errors, 76 warnings
 


Message édité par Emmanuel Delahaye le 15-09-2006 à 08:24:30

---------------
Des infos sur la programmation et le langage C: http://www.bien-programmer.fr Pas de Wi-Fi à la maison : http://www.cpl-france.org/
n°1442814
acryline
Posté le 15-09-2006 à 08:50:25  profilanswer
 

J'ai mis les option -Wall -Wextra (pour mon code::Blocks c'est -W) et -02 et la liste des warnings qui restent est :
 

Code :
  1. Project   : Win32 Application
  2. Compiler  : GNU GCC Compiler (called directly)
  3. Directory : D:\Programmation\carnet\
  4. --------------------------------------------------------------------------------
  5. Switching to target: default
  6. Compiling: fonction.c
  7. fonction.c:883: warning: unused parameter 'hwnd'
  8. fonction.c:883: warning: unused parameter 'hBouton'
  9. fonction.c:883: warning: unused parameter 'hEdit'
  10. fonction.c:883: warning: unused parameter 'uMsg'
  11. fonction.c:883: warning: unused parameter 'wParam'
  12. fonction.c:884: warning: unused parameter 'lParam'
  13. fonction.c:884: warning: unused parameter 'temoins'
  14. fonction.c:884: warning: unused parameter 'photo'
  15. fonction.c:835: warning: unused parameter 'uMsg'
  16. fonction.c:737: warning: unused parameter 'temoins'
  17. fonction.c:737: warning: unused parameter 'nombre'
  18. fonction.c:695: warning: unused parameter 'hwnd'
  19. fonction.c:622: warning: unused parameter 'hwnd'
  20. fonction.c:547: warning: unused parameter 'hwnd'
  21. fonction.c:450: warning: unused parameter 'uMsg'
  22. fonction.c:378: warning: unused parameter 'uMsg'
  23. fonction.c:379: warning: unused parameter 'lParam'
  24. fonction.c:273: warning: unused parameter 'y'
  25. fonction.c:215: warning: unused parameter 'ps'
  26. fonction.c:215: warning: unused parameter 'texte'
  27. fonction.c:215: warning: unused parameter 'hBouton'
  28. fonction.c:187: warning: unused parameter 'hwnd'
  29. fonction.c:187: warning: unused parameter 'ps'
  30. fonction.c:60: warning: unused parameter 'famillePolice'
  31. Process terminated with status 1 (0 minutes, 0 seconds)


 
Pour ce qui est de  

Code :
  1. fonction.c:810: error: `LBS_COMBOBOX' undeclared (first use in this function)


 
J'ai ajouté  

Code :
  1. #define LBS_COMBOBOX 0x8000

Message cité 1 fois
Message édité par acryline le 15-09-2006 à 08:51:44
n°1442849
Emmanuel D​elahaye
C is a sharp tool
Posté le 15-09-2006 à 10:02:01  profilanswer
 

acryline a écrit :

J'ai mis les option -Wall -Wextra (pour mon code::Blocks c'est -W) et -02 et la liste des warnings qui restent est :


Attention, c'est pas 02, mais O2 ('O' comme Optimizer).


---------------
Des infos sur la programmation et le langage C: http://www.bien-programmer.fr Pas de Wi-Fi à la maison : http://www.cpl-france.org/
n°1442857
acryline
Posté le 15-09-2006 à 10:11:26  profilanswer
 

Emmanuel Delahaye a écrit :

Attention, c'est pas 02, mais O2 ('O' comme Optimizer).


 
J'ai fait comme ça :
http://mapage.noos.fr/site1/options.jpg

n°1442864
Emmanuel D​elahaye
C is a sharp tool
Posté le 15-09-2006 à 10:27:17  profilanswer
 


OK.


---------------
Des infos sur la programmation et le langage C: http://www.bien-programmer.fr Pas de Wi-Fi à la maison : http://www.cpl-france.org/
n°1443005
anordem
Posté le 15-09-2006 à 13:41:51  profilanswer
 

Bon, c'est sûr que si tes modifications génèrent de nouvelles erreurs, on n'a pas fini! :p
 
Le problème vient de cette fonction :
 

Code :
  1. void nouvelleFiche(HWND hwnd,HDC hdc, char *photo)
  2. {
  3.    long i=0;
  4.    ECRIRE * coorT=NULL;
  5.    i=0,coorT.cx=10,coorT[i].cy=65, strncat(coorT[i].texte,"NOM : ",MAX_PATH);
  6. ...


 
Tu affectes des valeurs ([i]coorT[i].cx=10) à une structure qui n'existe pas (ECRIRE * coorT=NULL;).
Alors que dans le précédent code, tu l'avais déclaré comme ça :
 

Code :
  1. ECRIRE coorT[30]={0};


 
 
Donc, fait attention quand tu corriges ton code, prend ton temps. :)

n°1443029
acryline
Posté le 15-09-2006 à 14:19:38  profilanswer
 

anordem a écrit :

Bon, c'est sûr que si tes modifications génèrent de nouvelles erreurs, on n'a pas fini! :p
 
Le problème vient de cette fonction :
 

Code :
  1. void nouvelleFiche(HWND hwnd,HDC hdc, char *photo)
  2. {
  3.    long i=0;
  4.    ECRIRE * coorT=NULL;
  5.    i=0,coorT.cx=10,coorT[i].cy=65, strncat(coorT[i].texte,"NOM : ",MAX_PATH);
  6. ...


 
Tu affectes des valeurs ([i]coorT[i].cx=10) à une structure qui n'existe pas (ECRIRE * coorT=NULL;).
Alors que dans le précédent code, tu l'avais déclaré comme ça :
 

Code :
  1. ECRIRE coorT[30]={0};


 
 
Donc, fait attention quand tu corriges ton code, prend ton temps. :)


 
 
Oui c'est pas faux !!  
 
Quand j'ai écrit ça je n'y croyais pas du tout, en fait  c'est complètement NULL  :pt1cable: (et il y en a d'autres je crois??) Bon,  pour ma défense, il y a pas mal de temps que je trime pour trouver  l'erreur alors à force je disjoncte .
 
Mais, cette déclaration n'est pas l'origine du mal.
J'ai donc décidé de reprendre tout depuis le début en laissant de côté la décoration. Je fais d'abord la trame du programme et après je mettrai les rideaux, les fleurs, les coussins...  
 
En revanche si quelqu'un trouve le couac ça serait bien !  :p  
 
Merci pour vos réponses Emmanuel Delahaye et Anordem !

n°1443082
anordem
Posté le 15-09-2006 à 15:03:14  profilanswer
 

acryline a écrit :


Mais, cette déclaration n'est pas l'origine du mal.


 
Qu'est ce qui te permet d'affirmer ça?
 
Cette fonction est appelée à chaque fois que la fenêtre principale doit être redessinée. Donc, entre autre à chaque fois qu'on utilise le menu.
 
Le code compilé de la ligne donne ça :
 


MOV     EAX, 10
MOV     DWORD PTR [0], EAX        ; coorT[i].cx=10
 
MOV     EAX, 65
MOV     DWORD PTR [4], EAX        ; coorT[i].cy=65


 
Si tu ne comprends pas l'asm, je t'explique.
Le code signifie qu'on veut placer la valeur 10 à l'adresse 0. Hors l'adresse 0 est inaccessible au programme. Cela génère donc une violation d'accès.
Ensuite, on veut placer la valeur 65 à l'adresse 4 et là aussi, ça provoque une violation d'accès.
 
Tout simplement parce que le compilateur a compris que le tableau de structure coort se trouve à l'adresse 0x00000000 suite à ta déclaration

Code :
  1. ECRIRE * coorT=NULL;


 
Donc selon la déclaration de ta structure

Code :
  1. struct ECRIRE
  2.     {
  3.     long cx;
  4.     long cy;
  5.     char texte[50];
  6.     };


 
Pour coort[0] :
cx se trouve à l'adresse 0, cy à l'adresse 4 et texte à l'adresse 8.
Pour coort[1] :
cx se trouve à l'adresse 60, cy à l'adresse 64 et texte à l'adresse 68.
60 = taille de cx + taille de cy + taille de texte + alignement sur 32 bits = 4 + 4 +50 + 2
 
 
Il est fort possible qu'il y ait d'autres erreurs, mais comme je ne peux pas continuer l'exécution du programme après celle-ci, j'ai du mal à comprendre comment tu peux être sûr que ton problème est ailleurs...
 

acryline a écrit :


En revanche si quelqu'un trouve le couac ça serait bien !  :p  


 
Donc de quel couac parles tu ?
 
Dans tous les cas, je pense que c'est une bonne idée de reprendre ton code dans son ensemble. :)
Et n'hésite pas à prendre des notes et mettre tes idées au clair avant de coder.
 
Bon courage! :)


Message édité par anordem le 15-09-2006 à 15:05:10
n°1443098
acryline
Posté le 15-09-2006 à 15:16:07  profilanswer
 

Ok ! j'envoie le code  en lien avec ECRIRE  coorT[30]  correctement déclaré.
Je l'affirmais parce que je crois l'avoir déjà corrigé ce matin et ça n'avait rien changé. Je vais revoir ça maintenant.
 
Edité : ça a  l'air de marcher ... :) je reviens.
Edité : Bon ça ne plante plus mais le programme se ferme après chaque commande via le menu... je regarde ce qui se passe et si je n'y arrive pas je remets le code ici  :) (à++)


Message édité par acryline le 15-09-2006 à 15:36:03
n°1443538
acryline
Posté le 17-09-2006 à 07:44:49  profilanswer
 

Vite un petit mot pour terminer le sujet : je ne suis pas arrivée à  faire en sorte que le programme ne se ferme  après chaque commande. Il faut dire que je n'ai pas beaucoup essayé.
Tous ça a eu au moins le mérite de me faire chercher, j'ai vu des options de compilation, je sais maintenant qu'il faut corriger TOUS les warnings et surtout je me suis mise à remanier mon code de façon bcp plus propre !
Donc au final c'est très positif. :)  
 
Merci encore à Anordem et à Emmanuel Delahaye. J'aurai sans doute encore besoin de vos connaissances  :jap:  
...et qui sait un jour, à force de me tromper, donc d'apprendre, je pourrais aider un débutant ?  ;)

Message cité 1 fois
Message édité par acryline le 17-09-2006 à 07:45:46
n°1443569
Bad_Day
Posté le 17-09-2006 à 12:16:36  profilanswer
 

acryline a écrit :


...et qui sait un jour, à force de me tromper, donc d'apprendre, je pourrais aider un débutant ?  ;)


 
Mais, tu là déja fait plusieur fois  ;)  
 
 

mood
Publicité
Posté le   profilanswer
 


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

  Win Api : L'utilisation du menu fait planter le programme

 

Sujets relatifs
Probleme dans un menu...Place d'un menu déroulant
Question fondamentale: le menu d'un site.menu dynamique ksh
MenuComment ajouter une nouvelle API comme JCC à J2SE déjà installé?
Programme VB + ombres WindowFXgérer du hardware avec un programme en C
batch emplacement programme[HTML] Problème de retour au menu
Plus de sujets relatifs à : Win Api : L'utilisation du menu fait planter le programme


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