je rencontre un petit probleme dans mon petite code ....

Vous débutez et vous avez besoin d'aide ? N'hésitez pas à poser vos questions
jbernard13
Messages : 1501
Inscription : dim. 18/avr./2004 15:04
Localisation : sud de la france

je rencontre un petit probleme dans mon petite code ....

Message par jbernard13 »

Bonjour et Bonne Année 2005

ce matin j'ai coder un petit programme de repertoire telephonique
il est pas fini
mais je rencontre un probleme :
quand on ajoute un élément a la liste
apres on double clique sur une élément pour le modifier la premiere fois ca marche car on peux modifier dans la petite fenetre qui apparait l'element de la liste
mais quand on veux remodifier l"element , il ya plus rien dans la petite fenetre qui apparait c'est vide

qui peux m'aider a resoudre ce probleme qui tracasse ...

merci et bonne année

Code : Tout sélectionner

;Repertoire telephonie 
; par Jbernard13 écris le 01/01/2005

; contanste des fenetres 

Enumeration
  #main_0
  #fenetre_1
  #fenetre_2 
EndEnumeration

;constante des gadgets
Enumeration
   #liste
  #frame_0
  #text_nom
  #string_nom
  #text_prenom
  #string_prenom
  #text_telephone
  #string_telephone 
  #button_ajoute
  #button_annule
  #button_modifie
EndEnumeration
; barre du menu 
Enumeration
 
  #barre_New
  #barre_Charger
  #barre_Sauver
  #barre_efface
  #barre_info
  EndEnumeration





; Chargement des fonts
Global FontID1
FontID1 =LoadFont(1,"arial",11,#PB_Font_Bold)
Global fontId2
fontId2 =LoadFont(2,"arial",12,#PB_Font_Bold)
Global fontID3
fontID3=LoadFont(3,"arial",11)

; creation d'un élément 

Structure carnet
  Nom.s
  Prenom.s
  Telephone.s
EndStructure
NewList items.carnet()

Procedure.b item_clear()
  ClearList(items ())
EndProcedure
Procedure.b item_add()
  If  AddElement(items())
    items()\Nom=GetGadgetText(#string_nom)
    items()\Prenom=GetGadgetText(#string_prenom)
    items()\Telephone=GetGadgetText(#string_telephone)
    AddGadgetItem(#liste,-1,items()\Nom+Chr(10)+items()\Prenom+Chr(10)+items()\Telephone)
  EndIf
  ProcedureReturn 1
EndProcedure

Procedure item_modifie(index,Nom.s,Prenom.s,Telephone.s)
  indexcourant=ListIndex(items())
  SelectElement(items(),index)
  items()\Nom=Nom
  items()\Prenom=Prenom
  items()\Telephone=Telephone
  SelectElement(items(),indexcourant)
EndProcedure





Procedure remove()
  effacer=0
  If GetGadgetItemState(#liste,effacer)&#PB_ListIcon_Checked 
    MessageRequester("Merlin vous informe que ", "L'élément sera supprimer ", #MB_OK|#MB_ICONINFORMATION)
    RemoveGadgetItem(#liste,effacer)
  EndIf
EndProcedure





;procdeure des fenetres 

Procedure main()
  If OpenWindow(#main_0,0,0,800,600,#PB_Window_SystemMenu|#PB_Window_MinimizeGadget|#PB_Window_ScreenCentered,"Carnet de telephone")
    If CreateToolBar(0, WindowID()) 
       ToolBarStandardButton(#barre_New,#PB_ToolBarIcon_New)
       ToolBarStandardButton(#barre_Charger,#PB_ToolBarIcon_Open )
       ToolBarStandardButton(#barre_Sauver,#PB_ToolBarIcon_Save)
       ToolBarStandardButton(#barre_efface,#PB_ToolBarIcon_Delete)
       ToolBarStandardButton(#barre_info,#PB_ToolBarIcon_Properties)
       ToolBarToolTip(#barre_New,"Creation d'une nouveau élément pour la liste en cours")
       ToolBarToolTip(#barre_Charger,"Charge une liste")
       ToolBarToolTip(#barre_Sauver ,"Sauve une liste")
       ToolBarToolTip(#barre_efface ," Efface un élément de la liste en le cochant ")
       ToolBarToolTip(#barre_info,"Information")
      
   
    EndIf
    If CreateGadgetList(WindowID())
       ListIconGadget(#liste,10,54,780,535,"Nom :",250, #PB_ListIcon_CheckBoxes| #PB_ListIcon_GridLines   )
      AddGadgetColumn(#liste,1,"Prenom :",250)
      AddGadgetColumn(#liste,2,"Téléphone :",276)
      SetGadgetFont(#liste,FontID1)
    
    
    EndIf
    
  EndIf
EndProcedure
Procedure ajouter()
  If OpenWindow(#fenetre_1,0,0,400,300,#PB_Window_ScreenCentered,"Crée une nouvelle entrée dans la liste")
    
    If CreateGadgetList(WindowID())
      Frame3DGadget(#frame_0,10,5,380,280,"")
      TextGadget(#text_nom,130,30,140,30,"Nom : ",#PB_Text_Center)
      SetGadgetFont(#text_nom,fontId2)
      StringGadget(#string_nom,80,55,250,25,"")
      SetGadgetFont(#string_nom,fontID3)    
      TextGadget(#text_prenom,130,90,140,30,"Prénom : ",#PB_Text_Center)
      SetGadgetFont(#text_prenom,fontId2)
      StringGadget(#string_prenom,80,115,250,25,"")
      SetGadgetFont(#string_prenom,fontID3)
      TextGadget(#text_telephone,130,155,140,30,"Téléphone: ",#PB_Text_Center)
      SetGadgetFont(#text_telephone,fontId2)
      StringGadget(#string_telephone,80,180,250,25,"",#PB_String_Numeric)
      SetGadgetFont(#string_telephone,fontID3)
      ButtonGadget(#button_ajoute,50,240,100,30,"Ajouter")
      SetGadgetFont(#button_ajoute,fontId2)
      ButtonGadget(#button_annule,250,240,100,30,"Annuler")
      SetGadgetFont(#button_annule,fontId2)
      
      
      Repeat
        event=WaitWindowEvent()
        Select event
          Case #PB_EventGadget
            Select EventGadgetID()
              Case#button_ajoute:item_add()
                fermer_window_1=1
                
              Case #button_annule: fermer_window_1=1
            EndSelect
        EndSelect
      Until  fermer_window_1=1
      CloseWindow(#fenetre_1)
      While WindowEvent():Wend
      
      
      
      
    EndIf
    
  EndIf
  
EndProcedure
Procedure modifier(index)
  If OpenWindow(#fenetre_2,0,0,400,300,#PB_Window_ScreenCentered,"modification")
    
    If CreateGadgetList(WindowID())
      Frame3DGadget(#frame_0,10,5,380,280,"")
      TextGadget(#text_nom,130,30,140,30,"Nom : ",#PB_Text_Center)
      SetGadgetFont(#text_nom,fontId2)
      StringGadget(#string_nom,80,55,250,25,"")
      SetGadgetFont(#string_nom,fontID3)
      TextGadget(#text_prenom,130,90,140,30,"Prénom : ",#PB_Text_Center)
      SetGadgetFont(#text_prenom,fontId2)
      StringGadget(#string_prenom,80,115,250,25,"")
      SetGadgetFont(#string_prenom,fontID3)
      TextGadget(#text_telephone,130,155,140,30,"Téléphone: ",#PB_Text_Center)
      SetGadgetFont(#text_telephone,fontId2)
      StringGadget(#string_telephone,80,180,250,25,"",#PB_String_Numeric)
      SetGadgetFont(#string_telephone,fontID3)
      ButtonGadget(#button_modifie,50,240,100,30,"Modifier")
      SetGadgetFont(#button_modifie,fontId2)
      ButtonGadget(#button_annule,250,240,100,30,"Annuler")
      SetGadgetFont(#button_annule,fontId2)
      SelectElement(items(),index)
      SetGadgetText(#string_nom,items()\Nom)
      SetGadgetText(#string_prenom,items()\Prenom)
      SetGadgetText(#string_telephone,items()\Telephone)
      Repeat
        event=WaitWindowEvent()
        Select event
          Case #PB_EventGadget
            Select EventGadgetID()
              Case #button_modifie
                a.s=GetGadgetText(#string_nom)
                b.s=GetGadgetText(#string_prenom)
                c.s=GetGadgetText(#string_telephone)
                If a<> "" And b<> "" And c<> ""
                  SetGadgetItemText(#liste,index,a,0)
                  SetGadgetItemText(#liste,index,b,1)
                  SetGadgetItemText(#liste,index,c,2)
                  item_modifie(index,Nom.s,Prenom.s,Telephone.s)
                EndIf
                fermer_window_2=1
                
              Case #button_annule: fermer_window_2=1
            EndSelect
        EndSelect
      Until  fermer_window_2=1
      CloseWindow(#fenetre_2)
      While WindowEvent():Wend
      
      
      
      
    EndIf
    
  EndIf
  
EndProcedure
main()


; boucle du programme 
Repeat
  event=WaitWindowEvent()
  Select event
    Case#PB_EventMenu
      Select EventMenuID()
        Case#barre_New:ajouter()
        Case #barre_efface:remove()
        Case #barre_info:MessageRequester("Information ", "Carnet telephone  version 01 " + Chr(10) + "écris par Jean-Bernard Copyright 2005 ", #MB_OK|#MB_ICONINFORMATION)
          
          EndSelect
    
    
    Case #PB_EventGadget
      Select EventGadgetID()
        
        Case #liste
          Select EventType ()
            
            Case #PB_EventType_LeftDoubleClick
              element=GetGadgetState(#liste)
              If element>-1
                modifier(element)
                
              EndIf
          EndSelect
          
          
          
      EndSelect
      
      
      
      
      
    Case #PB_EventCloseWindow
      fermer_window_0=1
  EndSelect
Until  fermer_window_0=1
End

  

Jbernard13
nico
Messages : 3702
Inscription : ven. 13/févr./2004 0:57

Message par nico »

Il va falloir commencer à utiliser le debugger , tu devrais être capable de debugger un programme qui n'est pas complexe surtout si tu l'as écrit toi même.

tu te rends compte rester bloquer sur un truc pareil c'est pas sérieux.
jbernard13
Messages : 1501
Inscription : dim. 18/avr./2004 15:04
Localisation : sud de la france

Message par jbernard13 »

Bonne année Nico

tu as trouver la solution svp
Jbernard13
Apprenti
Messages : 45
Inscription : mar. 28/déc./2004 23:06

Message par Apprenti »

rajoute dans les enumerations
#MB_OK
#MB_ICONINFORMATION

moi aussi j'ai envie de me développer mon carnet d'adresses

mais un truc à la fois.....
jbernard13
Messages : 1501
Inscription : dim. 18/avr./2004 15:04
Localisation : sud de la france

Message par jbernard13 »


rajoute dans les enumerations
#MB_OK
#MB_ICONINFORMATION
ca sert a rien de rajouter ça

#MB_OK
#MB_ICONINFORMATION
sont des constante propre pour messagerequester
Jbernard13
Apprenti
Messages : 45
Inscription : mar. 28/déc./2004 23:06

Message par Apprenti »

moi j'ai été obligé de faire çà pour que çà tourne
jbernard13
Messages : 1501
Inscription : dim. 18/avr./2004 15:04
Localisation : sud de la france

Message par jbernard13 »

explique moi svp
Jbernard13
Apprenti
Messages : 45
Inscription : mar. 28/déc./2004 23:06

Message par Apprenti »

Image
jbernard13
Messages : 1501
Inscription : dim. 18/avr./2004 15:04
Localisation : sud de la france

Message par jbernard13 »

quel version de xp tu as ?
as tu acheter Purebasic?

moi ca marche tres bien chezmoi
Jbernard13
Apprenti
Messages : 45
Inscription : mar. 28/déc./2004 23:06

Message par Apprenti »

Non, je n'ai que la démo PureBasic puisque je découvre la programmation

C'est là qu'on voit qu'il faudrait pouvoir rajouter sa config dans son profil du forum

PureBasic 3.92 Demo
Windows XP Familiale SP2
AMD 1400 - 512 Mo de Ram - ATI Radeon VE 32Mb
jbernard13
Messages : 1501
Inscription : dim. 18/avr./2004 15:04
Localisation : sud de la france

Message par jbernard13 »

un conseil:
achete purebasic
Jbernard13
Le Soldat Inconnu
Messages : 4312
Inscription : mer. 28/janv./2004 20:58
Localisation : Clermont ferrand OU Olsztyn
Contact :

Message par Le Soldat Inconnu »

Salut,

Code : Tout sélectionner

a.s = GetGadgetText(#string_nom)
                b.s = GetGadgetText(#string_prenom)
                c.s = GetGadgetText(#string_telephone)
                If a <> "" And b <> "" And c <> ""
                  SetGadgetItemText(#liste, index, a, 0)
                  SetGadgetItemText(#liste, index, b, 1)
                  SetGadgetItemText(#liste, index, c, 2)
                  item_modifie(index, Nom.s, Prenom.s, Telephone.s)
regarde dans quoi tu récupère le nom et avec quoi tu l'envoie dans Item_modifie

car a.s << Nom.s
Je ne suis pas à moitié Polonais mais ma moitié est polonaise ... Vous avez suivi ?

[Intel quad core Q9400 2.66mhz, ATI 4870, 4Go Ram, XP (x86) / 7 (x64)]
jbernard13
Messages : 1501
Inscription : dim. 18/avr./2004 15:04
Localisation : sud de la france

Message par jbernard13 »

salut regis bonne année à toi
tu as trouver la solution
Jbernard13
Le Soldat Inconnu
Messages : 4312
Inscription : mer. 28/janv./2004 20:58
Localisation : Clermont ferrand OU Olsztyn
Contact :

Message par Le Soldat Inconnu »

> Apprenti : les 2 constantes ne sont pas reconnu par la version démo

mets ceci au début du code :
#MB_OK = 1
#MB_ICONINFORMATION = 4 * 16

voir ici :
http://purebasic.hmt-forum.com/viewtopic.php?t=57
Je ne suis pas à moitié Polonais mais ma moitié est polonaise ... Vous avez suivi ?

[Intel quad core Q9400 2.66mhz, ATI 4870, 4Go Ram, XP (x86) / 7 (x64)]
bernard13
Messages : 1221
Inscription : mer. 05/janv./2005 21:30

Message par bernard13 »

aidez moiiiiiii
Répondre