Page 1 sur 2

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

Publié : sam. 01/janv./2005 13:35
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

  


Publié : sam. 01/janv./2005 14:30
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.

Publié : sam. 01/janv./2005 14:35
par jbernard13
Bonne année Nico

tu as trouver la solution svp

Publié : sam. 01/janv./2005 14:59
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.....

Publié : sam. 01/janv./2005 15:24
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

Publié : sam. 01/janv./2005 20:17
par Apprenti
moi j'ai été obligé de faire çà pour que çà tourne

Publié : sam. 01/janv./2005 23:11
par jbernard13
explique moi svp

Publié : dim. 02/janv./2005 7:14
par Apprenti
Image

Publié : dim. 02/janv./2005 8:33
par jbernard13
quel version de xp tu as ?
as tu acheter Purebasic?

moi ca marche tres bien chezmoi

Publié : dim. 02/janv./2005 11:30
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

Publié : dim. 02/janv./2005 13:46
par jbernard13
un conseil:
achete purebasic

Publié : dim. 02/janv./2005 15:53
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

Publié : dim. 02/janv./2005 20:33
par jbernard13
salut regis bonne année à toi
tu as trouver la solution

Publié : dim. 02/janv./2005 23:51
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

Publié : mar. 11/janv./2005 22:51
par bernard13
aidez moiiiiiii