IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Delphi Discussion :

Notification d'une exception du débogueur


Sujet :

Delphi

  1. #1
    Candidat au Club
    Profil pro
    Inscrit en
    Janvier 2007
    Messages
    3
    Détails du profil
    Informations personnelles :
    Âge : 64
    Localisation : France

    Informations forums :
    Inscription : Janvier 2007
    Messages : 3
    Points : 4
    Points
    4
    Par défaut Notification d'une exception du débogueur
    Bonjour à tous

    J'ai un petit problème que je n'arive pas a résoudre, Lors de la fermeture de mon programme je recois un erreur

    Le projet PEditStrGrd.exe a provoqué une classe d'exception EAccessViolation avec le message 'Violation d'accès à l'adresse 00000000. Lecture de l'adresse 00000000'. Processus stoppé. Utilisez Pas-à-pas ou Exécuter pour continuer.
    et je ne voie pas d'où cela vient.
    voici mon code sous delphi 6

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
     
    unit UEditStrGrd;
     
    interface
     
    uses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, StdCtrls, Grids, ComCtrls;
     
    type
      TForm1 = class(TForm)
        StringGrid1: TStringGrid;
        procedure StringGrid1SelectCell(Sender: TObject; Col, Row: Integer;
          var CanSelect: Boolean);
        procedure FormShow(Sender: TObject);
        procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
      private
        { Déclarations privées }
      public
        { Déclarations publiques }
        procedure ComboBox1Exit(Sender: TObject);
        procedure EditCelluleExit(Sender: TObject);
        procedure FenPluieExit(Sender: TObject);
     
      end;
     
    var
      Form1: TForm1;
      FenPluie: TForm;
      ComboBox1:TComboBox;
      EditCellule, EditPluie:TEdit;
      UpDownPluie : TUpDown;
     
     
    implementation
     
    {$R *.dfm}
     
    procedure TForm1.ComboBox1Exit(Sender: TObject);
    begin
         StringGrid1.Cells[StringGrid1.Col,StringGrid1.Row]:=ComboBox1.Text;
         ComboBox1.Visible := False;
         StringGrid1.SetFocus;
    end;
     
    procedure TForm1.EditCelluleExit(Sender: TObject);
    begin
         StringGrid1.Cells[StringGrid1.Col,StringGrid1.Row]:=EditCellule.Text;
         EditCellule.Visible := False;
         StringGrid1.SetFocus;
    end;
     
    procedure TForm1.FenPluieExit(Sender : TObject);
    begin
         StringGrid1.Cells[StringGrid1.Col,StringGrid1.Row]:=EditPluie.Text;
         FenPluie.ModalResult := mrNone;
         StringGrid1.SetFocus;
    end;
     
    procedure TForm1.FormShow(Sender: TObject);
    Var
       X:Integer;
    begin              // création de la comboBox
         StringGrid1.Options:=StringGrid1.Options+[goColSizing,goThumbTracking]-[goEditing];
         ComboBox1:=TComboBox.Create(Self);
         ComboBox1.Parent:=Form1;
         ComboBox1.Visible:=False;
         ComboBox1.OnExit:=ComboBox1Exit;
                       // Initialisation de la comboBox
         ComboBox1.Clear;
         For X:=1 to 10
         do ComboBox1.Items.Add(IntToStr(X));
                      // Création du tEdit
         EditCellule := TEdit.Create(Self);
         EditCellule.Parent := Form1;
         EditCellule.Visible := False;
         EditCellule.OnExit := EditCelluleExit;
                     // cr&ation de la fenetre pluie
         FenPluie := TForm.Create(self);
           With FenPluie do
             begin
               Height := Form1.Height div 2;
               Width := Form1.Width div 3;
               Left := ((Form1.Width - Width) div 2 )+Form1.Left;
               Top := ((Form1.Height - Height) div 2 )+ Form1.Top;
               caption := 'Cumul de pluie';
               BorderIcons := [biSystemMenu];
               Visible := False;
               OnExit := FenPluieExit;
               Parent := Form1;
             end;
     
                    // Création des controls de la fenetre de pluie
                      // la zone d'édition
         EditPluie := TEdit.Create(FenPluie);
           With EditPluie do
             begin
               Parent := FenPluie;
               Width := 90;
               ReadOnly := true;
               Left := ((FenPluie.ClientWidth Div 2) - 10)-45;
               Top := 30;
             end;
                      // Le bouton +-
         UpDownPluie := TUpDown.Create(FenPluie);
           With UpDownPluie  do
             begin
               Parent := FenPluie;
               Left := ((FenPluie.ClientWidth Div 2) - 10) + 60;
               Top := 10;
               Width := 30;
               Height := 60;
               min := 0;
               Max := 500;
               increment := 1;
               Position := 0;
               //OnChangingEx := ChangeCumul;  futur dévelopement
              end;
     
    end;
     
    procedure TForm1.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
    begin
         ComboBox1.Free;
         EditCellule.Free;
         FenPluie.Free;
         EditPluie.Free;
         UpDownPluie.Free;
    end;
     
     
    procedure TForm1.StringGrid1SelectCell(Sender: TObject;Col,Row: Integer; var CanSelect: Boolean);
    var
       R: TRect;
    begin
         if (Col = 10)
         and (Row <> 0)
         then begin           // initalisation de la comboBox
              R := StringGrid1.CellRect(Col, Row);
              R.Left := R.Left + StringGrid1.Left;
              R.Right := R.Right + StringGrid1.Left;
              R.Top := R.Top + StringGrid1.Top;
              R.Bottom := R.Bottom + StringGrid1.Top;
              ComboBox1.Left := R.Left + 1;
              ComboBox1.Top := R.Top + 1;
              ComboBox1.Width := (R.Right + 1) - R.Left;
              ComboBox1.Height := (R.Bottom + 1) - R.Top;
              ComboBox1.Visible := True;
              if StringGrid1.Cells[Col,Row]<>''
              then ComboBox1.Text:=StringGrid1.Cells[Col,Row]
              else ComboBox1.Text:='';
              ComboBox1.SetFocus;
         end;
         if (Col in [1,2,3,4,5,6,7,9])
         and (Row <> 0)
         then begin             // initialisation du TEdit
              R := StringGrid1.CellRect(Col, Row);
              R.Left := R.Left + StringGrid1.Left;
              R.Right := R.Right + StringGrid1.Left;
              R.Top := R.Top + StringGrid1.Top;
              R.Bottom := R.Bottom + StringGrid1.Top;
              EditCellule.Left := R.Left + 1;
              EditCellule.Top := R.Top + 1;
              EditCellule.Width := (R.Right + 1) - R.Left;
              EditCellule.Height := (R.Bottom + 1) - R.Top;
              EditCellule.Visible := True;
              if StringGrid1.Cells[Col,Row]<>''
              then EditCellule.Text:=StringGrid1.Cells[Col,Row]
              else EditCellule.Text:='';
              EditCellule.SetFocus;
         end;
         if (Col =8)
         and (Row <> 0)
         then begin             // initialisation de la fenetre cumul de pluie
              if StringGrid1.Cells[Col,Row]<>''
              then EditCellule.Text:=StringGrid1.Cells[Col,Row]
              else EditCellule.Text:='';
              FenPluie.ShowModal;
         end;
    end;
    end.
    si quelqu'un avait une idée

    merci
    Fichiers attachés Fichiers attachés

  2. #2
    Expert éminent sénior
    Avatar de Jipété
    Profil pro
    Inscrit en
    Juillet 2006
    Messages
    10 874
    Détails du profil
    Informations personnelles :
    Localisation : France, Hérault (Languedoc Roussillon)

    Informations forums :
    Inscription : Juillet 2006
    Messages : 10 874
    Points : 15 293
    Points
    15 293
    Par défaut
    Peut-être comme ça ? :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    procedure TForm1.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
    begin
       ComboBox1.Free;
       EditCellule.Free;
       EditPluie.Free;
       UpDownPluie.Free;
       FenPluie.Free; // à détruire en dernier puisque Parent des 2 précédents
    end;
    Je n'ai pas regardé le code attaché, je n'ai rien testé.
    Mes 2 cts,
    --
    jp

  3. #3
    Candidat au Club
    Profil pro
    Inscrit en
    Janvier 2007
    Messages
    3
    Détails du profil
    Informations personnelles :
    Âge : 64
    Localisation : France

    Informations forums :
    Inscription : Janvier 2007
    Messages : 3
    Points : 4
    Points
    4
    Par défaut
    Citation Envoyé par Jipété
    Peut-être comme ça ? :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    procedure TForm1.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
    begin
       ComboBox1.Free;
       EditCellule.Free;
       EditPluie.Free;
       UpDownPluie.Free;
       FenPluie.Free; // à détruire en dernier puisque Parent des 2 précédents
    end;
    Je n'ai pas regardé le code attaché, je n'ai rien testé.
    Mes 2 cts,
    --
    jp

    Bonjour et merci Jipépé

    Une erreur de débutant, Impardonnable
    Merci encore et à +

  4. #4
    Membre averti
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Octobre 2005
    Messages
    218
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Loire Atlantique (Pays de la Loire)

    Informations professionnelles :
    Activité : Ingénieur développement logiciels
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Octobre 2005
    Messages : 218
    Points : 311
    Points
    311
    Par défaut
    Normalement tu n'as rien à mettre dans le formdestroy puisque la fenêtre propriétaire de ta fenêtre est la form sur laquelle tu te trouves et les composants que tu crées dynamiquement appartiennent à cette même forme. Lorsque tu détruiras ta fenêtre Form1 tu détruiras en même temps la fenetre FEnpluie, et en détruisant la fenêtre Fenpluie tu détruiras ses composants.

    Il aurait fallu effectivement détruire la fenêtre FEnpluie si tu avais spécifié
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    FenPluie := TForm.Create(Application);
    au lieu de
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    FenPluie := TForm.Create(self);
    Tu peux vérifier avec l'unité Memcheck pour t'aider à savoir si ton application ne libère pas certains blocs de la mémoire. fais une recherche sur cette unité sur le forum ou sur internet.

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Notification d'une exception du debogueur
    Par mahzongo dans le forum Langage
    Réponses: 1
    Dernier message: 10/02/2011, 09h01
  2. Notification d'une exception du débogueur
    Par fermat dans le forum Débuter
    Réponses: 3
    Dernier message: 24/11/2010, 22h07
  3. Probleme de notification d'une exception du débogueur
    Par faniette dans le forum C++Builder
    Réponses: 1
    Dernier message: 04/10/2010, 13h34
  4. Réponses: 2
    Dernier message: 28/08/2003, 00h00
  5. Réponses: 3
    Dernier message: 01/11/2002, 14h30

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo