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

Composants VCL Delphi Discussion :

[D2010] Utilisation propriété TStringList d'un composant dans inspecteur d'objet


Sujet :

Composants VCL Delphi

  1. #1
    Expert éminent
    Avatar de Lung
    Profil pro
    Analyste-programmeur
    Inscrit en
    Mai 2002
    Messages
    2 665
    Détails du profil
    Informations personnelles :
    Âge : 44
    Localisation : France, Haute Savoie (Rhône Alpes)

    Informations professionnelles :
    Activité : Analyste-programmeur
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Mai 2002
    Messages : 2 665
    Points : 6 977
    Points
    6 977
    Par défaut [D2010] Utilisation propriété TStringList d'un composant dans inspecteur d'objet
    Je suis en train de faire un composant qui a (entre autres) une propriété publiée de type TStringList (plus précisément, un descendant).

    - Quand j'utilise cette propriété dans un projet test, tout fonctionne bien.
    - Quand j'initialise cette propriété (en conception) depuis l'inspecteur d'objet, la propriété n'a pas reçu la valeur que j'y ai renseigné.
    Et si j'y retourne (toujours avec l'inspecteur d'objet), Delphi 2010 se ferme brutalement (sans erreur).

    Voici un extrait de mon composant :
    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
       TMaiaQuery = class(TSimpleDataSet)
          private
             FSQL: TSQLStringList;
     
             procedure SetSQL(const Valeur: TSQLStringList);
    ...
          published
             property SQL: TSQLStringList read FSQL write SetSQL;
    ...
     
    constructor TMaiaQuery.Create;
    begin
       inherited;
       DataSet.CommandType := ctQuery;
       PacketRecords := 20;
     
       FSQL := TSQLStringList.Create;
       FSQL.OnClear := ClearReq;
       FSQL.OnAdd := AddReq;
    end;
     
    procedure TMaiaQuery.SetSQL(const Valeur: TSQLStringList);
    begin
       FSQL.Assign(Valeur);
    end;
    Je me suis inspiré de cette discution pour le set : http://www.developpez.net/forums/d85...ants-tstrings/

    La définition de TSQLStringList :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
       TSQLStringList = class(Classes.TStringList)
          private
             fOnClear, fOnAdd: TNotifyEvent;
     
          public
             property OnClear: TNotifyEvent read fOnClear write fOnClear;
             property OnAdd: TNotifyEvent read fOnAdd write fOnAdd;
     
             procedure Clear;   override;
             function Add(const S: String): Integer;   override;
       end;
    Quelle est la marche à suivre pour faire un composant avec une propriété publiée de type TStringList, en bonne et due forme ?

    L'urgent est fait, l'impossible est en cours, pour les miracles prévoir un délai. ___ Écrivez dans un français correct !!

    C++Builder 5 - Delphi 6#2 Entreprise - Delphi 2007 Entreprise - Delphi 2010 Architecte - Delphi XE Entreprise - Delphi XE7 Entreprise - Delphi 10 Entreprise - Delphi 10.3.2 Entreprise - Delphi 10.4.2 Entreprise - Delphi 11.1 Entreprise
    OpenGL 2.1 - Oracle 10g - Paradox - Interbase (XE) - PostgreSQL (15.4)

  2. #2
    Expert éminent sénior
    Avatar de Cl@udius
    Homme Profil pro
    Développeur Web
    Inscrit en
    Février 2006
    Messages
    4 878
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 61
    Localisation : France, Haute Garonne (Midi Pyrénées)

    Informations professionnelles :
    Activité : Développeur Web
    Secteur : High Tech - Matériel informatique

    Informations forums :
    Inscription : Février 2006
    Messages : 4 878
    Points : 10 008
    Points
    10 008
    Par défaut
    Salut

    Ta propriété publiée doit être de type TStrings.

    Bien sûr tu l'instance en TStringList ou comme dans ton exemple TSQLStringList.

    @+ Claudius.

  3. #3
    Expert éminent
    Avatar de Lung
    Profil pro
    Analyste-programmeur
    Inscrit en
    Mai 2002
    Messages
    2 665
    Détails du profil
    Informations personnelles :
    Âge : 44
    Localisation : France, Haute Savoie (Rhône Alpes)

    Informations professionnelles :
    Activité : Analyste-programmeur
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Mai 2002
    Messages : 2 665
    Points : 6 977
    Points
    6 977
    Par défaut
    Citation Envoyé par Cl@udius Voir le message
    Ta propriété publiée doit être de type TStrings.

    Bien sûr tu l'instance en TStringList ou comme dans ton exemple TSQLStringList.
    Heu ...
    Je ne vois pas comment faire.
    Quoi que je fasse, j'ai une erreur comme quoi, TStrings et TSQLStringList sont incompatibles.
    L'urgent est fait, l'impossible est en cours, pour les miracles prévoir un délai. ___ Écrivez dans un français correct !!

    C++Builder 5 - Delphi 6#2 Entreprise - Delphi 2007 Entreprise - Delphi 2010 Architecte - Delphi XE Entreprise - Delphi XE7 Entreprise - Delphi 10 Entreprise - Delphi 10.3.2 Entreprise - Delphi 10.4.2 Entreprise - Delphi 11.1 Entreprise
    OpenGL 2.1 - Oracle 10g - Paradox - Interbase (XE) - PostgreSQL (15.4)

  4. #4
    Expert éminent sénior
    Avatar de Cl@udius
    Homme Profil pro
    Développeur Web
    Inscrit en
    Février 2006
    Messages
    4 878
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 61
    Localisation : France, Haute Garonne (Midi Pyrénées)

    Informations professionnelles :
    Activité : Développeur Web
    Secteur : High Tech - Matériel informatique

    Informations forums :
    Inscription : Février 2006
    Messages : 4 878
    Points : 10 008
    Points
    10 008
    Par défaut
    Re,

    Pas à la création de la variable FSQL ? si ?

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    constructor TMaiaQuery.Create;
    begin
       inherited;
       DataSet.CommandType := ctQuery;
       PacketRecords := 20;
     
       FSQL := TSQLStringList.Create;
       with TSQLStringList(FSQL) do
       begin
        OnClear := ClearReq;
        OnAdd := AddReq;
       end;
    end;
    @+

  5. #5
    Expert éminent
    Avatar de Lung
    Profil pro
    Analyste-programmeur
    Inscrit en
    Mai 2002
    Messages
    2 665
    Détails du profil
    Informations personnelles :
    Âge : 44
    Localisation : France, Haute Savoie (Rhône Alpes)

    Informations professionnelles :
    Activité : Analyste-programmeur
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Mai 2002
    Messages : 2 665
    Points : 6 977
    Points
    6 977
    Par défaut
    En fait l'erreur est sur cette ligne :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
             property SQL: TStrings read FSQL write SetSQL;
    Sachant que :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     private
             FSQL: TSQLStringList;
    Ca doit être tout bête, mais je ne trouve pas.
    L'urgent est fait, l'impossible est en cours, pour les miracles prévoir un délai. ___ Écrivez dans un français correct !!

    C++Builder 5 - Delphi 6#2 Entreprise - Delphi 2007 Entreprise - Delphi 2010 Architecte - Delphi XE Entreprise - Delphi XE7 Entreprise - Delphi 10 Entreprise - Delphi 10.3.2 Entreprise - Delphi 10.4.2 Entreprise - Delphi 11.1 Entreprise
    OpenGL 2.1 - Oracle 10g - Paradox - Interbase (XE) - PostgreSQL (15.4)

  6. #6
    Expert éminent sénior
    Avatar de Cl@udius
    Homme Profil pro
    Développeur Web
    Inscrit en
    Février 2006
    Messages
    4 878
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 61
    Localisation : France, Haute Garonne (Midi Pyrénées)

    Informations professionnelles :
    Activité : Développeur Web
    Secteur : High Tech - Matériel informatique

    Informations forums :
    Inscription : Février 2006
    Messages : 4 878
    Points : 10 008
    Points
    10 008
    Par défaut
    FSQL doit également être un TStrings pour rester en accord avec la propriété.

    Schématiquement:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
      TMaiaQuery = class(TSimpleDataSet)
      private
        FSQL: TStrings;
     
        procedure SetSQL(const Valeur: TStrings);
      protected
      public
        constructor Create; override;
      published
        property SQL: TStrings read FSQL write SetSQL;
      end;
    Ensuite dans la classe tu castes FSQL en TSQLStringList pour le manipuler comme tu le souhaites, comme dans l'exemple du constructeur de mon précédent message.

    @+

  7. #7
    Expert éminent
    Avatar de Lung
    Profil pro
    Analyste-programmeur
    Inscrit en
    Mai 2002
    Messages
    2 665
    Détails du profil
    Informations personnelles :
    Âge : 44
    Localisation : France, Haute Savoie (Rhône Alpes)

    Informations professionnelles :
    Activité : Analyste-programmeur
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Mai 2002
    Messages : 2 665
    Points : 6 977
    Points
    6 977
    Par défaut
    Bon, j'en suis là :
    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
    type
       TMaiaQuery = class(TSimpleDataSet)
          private
             FSQL: TStrings;
     
             procedure SetSQL(const Valeur: TStrings);
     
          protected
    ...
          published
             property SQL: TStrings read FSQL write SetSQL;
       end;
    ...
     
    constructor TMaiaQuery.Create;
    begin
       inherited;
       DataSet.CommandType := ctQuery;
       PacketRecords := 20;
     
       FSQL := TSQLStringList.Create;
       TSQLStringList(FSQL).OnClear := ClearReq;
       TSQLStringList(FSQL).OnAdd := AddReq;
    end;
     
    procedure TMaiaQuery.SetSQL(const Valeur: TStrings);
    begin
       TSQLStringList(FSQL).Assign(Valeur);
    end;
     
    procedure TMaiaQuery.ClearReq(Sender: TObject);
    begin
       DataSet.CommandText := '';
    end;
     
    procedure TMaiaQuery.AddReq(Sender: TObject);
    begin
       DataSet.CommandText := FSQL.Text;
    end;
    ...
    Et j'ai obtenu une violation d'accès cette fois, avant que Delphi ne se ferme tout seul.

    L'urgent est fait, l'impossible est en cours, pour les miracles prévoir un délai. ___ Écrivez dans un français correct !!

    C++Builder 5 - Delphi 6#2 Entreprise - Delphi 2007 Entreprise - Delphi 2010 Architecte - Delphi XE Entreprise - Delphi XE7 Entreprise - Delphi 10 Entreprise - Delphi 10.3.2 Entreprise - Delphi 10.4.2 Entreprise - Delphi 11.1 Entreprise
    OpenGL 2.1 - Oracle 10g - Paradox - Interbase (XE) - PostgreSQL (15.4)

  8. #8
    Membre expérimenté Avatar de guillemouze
    Profil pro
    Inscrit en
    Novembre 2004
    Messages
    876
    Détails du profil
    Informations personnelles :
    Âge : 41
    Localisation : France, Loire Atlantique (Pays de la Loire)

    Informations forums :
    Inscription : Novembre 2004
    Messages : 876
    Points : 1 448
    Points
    1 448
    Par défaut
    essaye de mettre le create avant le inherited :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
     
    constructor TMaiaQuery.Create;
    begin
       FSQL := TSQLStringList.Create;
       TSQLStringList(FSQL).OnClear := ClearReq;
       TSQLStringList(FSQL).OnAdd := AddReq;
     
       inherited;
     
       DataSet.CommandType := ctQuery;
       PacketRecords := 20;
    end;

  9. #9
    Expert éminent sénior
    Avatar de Cl@udius
    Homme Profil pro
    Développeur Web
    Inscrit en
    Février 2006
    Messages
    4 878
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 61
    Localisation : France, Haute Garonne (Midi Pyrénées)

    Informations professionnelles :
    Activité : Développeur Web
    Secteur : High Tech - Matériel informatique

    Informations forums :
    Inscription : Février 2006
    Messages : 4 878
    Points : 10 008
    Points
    10 008
    Par défaut
    Bon. J'ai l'impression que tu te compliques la tâche avec cette classe TSQLStringList.
    Si le but est uniquement d'actualiser le CommandText du DataSet, tu peux simplement procéder ainsi:

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
      TMaiaQuery = class(TSimpleDataSet)
      private
        FSQL: TStrings;
     
        procedure DoSQLChange(Sender: TObject);
        procedure SetSQL(const Value: TStrings);
      public
        constructor Create(AOwner: TComponent); override;
        destructor Destroy; override;
      published
        property SQL: TStrings read FSQL write SetSQL;
      end;
    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
    implementation
     
    {$R *.dfm}
     
    { TMaiaQuery }
     
    constructor TMaiaQuery.Create(AOwner: TComponent);
    begin
      inherited;
      DataSet.CommandType := ctQuery;
      PacketRecords := 20;
      FSQL := TStringList.Create;
      TStringList(FSQL).OnChange := DoSQLChange;
    end;
     
    destructor TMaiaQuery.Destroy;
    begin
      FSQL.Free;
      inherited;
    end;
     
    procedure TMaiaQuery.DoSQLChange(Sender: TObject);
    begin
      DataSet.CommandText := SQL.Text;
    end;
     
    procedure TMaiaQuery.SetSQL(const Value: TStrings);
    begin
      FSQL.Assign(Value);
    end;
    Autant utiliser l'évènement OnChange de la classe TStringList puisqu'il existe.

    @+

  10. #10
    Membre éprouvé
    Avatar de Dr.Who
    Inscrit en
    Septembre 2009
    Messages
    980
    Détails du profil
    Informations personnelles :
    Âge : 45

    Informations forums :
    Inscription : Septembre 2009
    Messages : 980
    Points : 1 294
    Points
    1 294
    Par défaut
    non non non, pourquoi déclarer en TStrings, c'est inutile ce genre de code.
    TListBox par exemple utilise bien TListBoxStringList et a propriété Items est bien une TListBoxStringList et tout les autres composants utilisant un TStrings dérivé déclares les classes dérivé et non l'ancêtre.
    La procedure Assign/AssignTo des classes dérivé, si elle n'est pas modifiée, reste compatible avec un TStrings en paramètre, si l'on fait :

    MaiaQuery.SQL.Assign(ListBox1.Items);
    ou
    MaiaQuery.SQL.Assign(Memo1.Lines);

    ça fonctionne.


    voici un exemple correctif :

    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
     
    unit MaiaSQL;
     
    interface
     
    uses SysUtils, Classes, SimpleDS;
     
    type
      TSQLAddEvent = procedure(Sender: TObject; index: integer) of object;
     
      TSQLStringList = class(Classes.TStringList)
      private
        fOnClear : TNotifyEvent;
        fOnAdd   : TSQLAddEvent;
      published
        property OnClear : TNotifyEvent read fOnClear write fOnClear;
        property OnAdd   : TSQLAddEvent read fOnAdd   write fOnAdd;
      public
        procedure Clear; override;
        function Add(const S: String): Integer; override;
      end;
     
      TMaiaQuery = class(SimpleDS.TSimpleDataSet)
      private
        fSQL         : TSQLStringList;
        fOnSQLAdd    : TSQLAddEvent;
        fOnSQLChange : TNotifyEvent;
        fOnSQLClear  : TNotifyEvent;
        procedure SetSQL(Value: TSQLStringList);
      protected
        procedure DoSQLChange(Sender: TObject);
        procedure DoSQLAdd(Sender: TObject; index: integer);
        procedure DoSQLClear(Sender: TObject);
      published
        property SQL         : TSQLStringList read fSQL write SetSQL;
        property OnSQLChange : TNotifyEvent read fOnSQLChange write fOnSQLChange;
        property OnSQLAdd    : TSQLAddEvent read fOnSQLAdd    write fOnSQLAdd;
        property OnSQLClear  : TNotifyEvent read fOnSQLClear  write fOnSQLClear;
      public
        constructor Create(AOwner: TComponent); override;
        destructor Destroy; override;
      end;
     
    implementation
     
    { TSQLStringList }
     
    function TSQLStringList.Add(const S: String): Integer;
    begin
      result := inherited Add(S);
      if Assigned(fOnAdd) and (UpdateCount = 0) then
        fOnAdd(Self, result);
    end;
     
    procedure TSQLStringList.Clear;
    begin
      inherited;
      if Assigned(fOnClear) and (UpdateCount = 0) then
        fOnClear(Self);
    end;
     
    { TMaiaQuery }
     
    constructor TMaiaQuery.Create(AOwner: TComponent);
    begin
      inherited;
      fSQL := TSQLStringList.Create;
      fSQL.OnClear := DoSQLClear;
      fSQL.OnAdd   := DoSQLAdd;
      fSQL.OnChange:= DoSQLChange;
    end;
     
    destructor TMaiaQuery.Destroy;
    begin
      fSQL.Free;
      inherited;
    end;
     
    procedure TMaiaQuery.DoSQLAdd(Sender: TObject);
    begin
      if Assigned(fOnSQLAdd) then
        fOnSQLAdd(Self);
    end;
     
    procedure TMaiaQuery.DoSQLChange(Sender: TObject);
    begin
      if Assigned(fOnSQLChange) then
        fOnSQLChange(Self);
    end;
     
    procedure TMaiaQuery.DoSQLClear(Sender: TObject);
    begin
      if Assigned(fOnSQLClear) then
        fOnSQLClear(Self);
    end;
     
    procedure TMaiaQuery.SetSQL(Value: TSQLStringList);
    begin
      fSQL.Assign(Value);
    end;
     
    end.
    [ Sources et programmes de Dr.Who | FAQ Delphi | FAQ Pascal | Règlement | Contactez l'équipe ]
    Ma messagerie n'est pas la succursale du forum... merci!

  11. #11
    Expert éminent sénior
    Avatar de Cl@udius
    Homme Profil pro
    Développeur Web
    Inscrit en
    Février 2006
    Messages
    4 878
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 61
    Localisation : France, Haute Garonne (Midi Pyrénées)

    Informations professionnelles :
    Activité : Développeur Web
    Secteur : High Tech - Matériel informatique

    Informations forums :
    Inscription : Février 2006
    Messages : 4 878
    Points : 10 008
    Points
    10 008
    Par défaut
    Citation Envoyé par Dr.Who Voir le message
    TListBox par exemple utilise bien TListBoxStringList et a propriété Items est bien une TListBoxStringList et tout les autres composants utilisant un TStrings dérivé déclares les classes dérivé et non l'ancêtre.
    Non. La propriété Items de la TListBox est bien un TStrings.

    Choisir ce type permet de disposer via l'inspecteur d'objet de l'éditeur standard utilisé pour gérer les listes.

  12. #12
    Expert éminent
    Avatar de Lung
    Profil pro
    Analyste-programmeur
    Inscrit en
    Mai 2002
    Messages
    2 665
    Détails du profil
    Informations personnelles :
    Âge : 44
    Localisation : France, Haute Savoie (Rhône Alpes)

    Informations professionnelles :
    Activité : Analyste-programmeur
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Mai 2002
    Messages : 2 665
    Points : 6 977
    Points
    6 977
    Par défaut
    Bon, j'ai testé chacune de vos propositions.
    Le composant fonctionne toujours quand je le remplis et l'utilise dans mon code.
    Mais, si je renseigne la propriété publiée SQL dans l'inspecteur d'objet, il suffit que j'y retourne, pour que Delphi se ferme immédiatement (et sans message).
    (Bon moyen pour le fermer rapidement d'ailleur )

    Voilà où j'en suis :
    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
    unit MaiaQuery;
     
    interface
     
    uses
       SysUtils, Classes, DB, DBClient, SimpleDS, WSDLIntf;
     
    type
       TSQLAddEvent = procedure(Sender: TObject; nIndex: Integer) of object;
     
       TSQLStringList = class(Classes.TStringList)
          private
             fOnClear: TNotifyEvent;
             fOnAdd: TSQLAddEvent;
     
          public
             property OnClear: TNotifyEvent read fOnClear write fOnClear;
             property OnAdd: TSQLAddEvent read fOnAdd write fOnAdd;
     
             procedure Clear;   override;
             function Add(const S: String): Integer;   override;
       end;
     
       TMaiaQuery = class(SimpleDS.TSimpleDataSet)
          private
             fSQL: TSQLStringList;
    //         fSQL: TStrings;
             fOnSQLAdd: TSQLAddEvent;
             fOnSQLChange: TNotifyEvent;
             fOnSQLClear: TNotifyEvent;
     
             procedure SetSQL(Valeur: TSQLStringList);
    //         procedure SetSQL(Valeur: TStrings);
     
          protected
             procedure DoSQLChange(Sender: TObject);
             procedure DoSQLAdd(Sender: TObject; nIndex: Integer);
             procedure DoSQLClear(Sender: TObject);
    //         function GetParams: TParams;   virtual;
    //         procedure SetParams(Valeur: TParams);   virtual;
     
          public
             constructor Create(Aowner: TComponent);   override;
             function ParamByName(const szNomParametre: String): TParam;
             destructor Destroy;   override;
     
          published
             property SQL: TSQLStringList read fSQL write SetSQL;
    //         property SQL: TStrings read fSQL write SetSQL;
             property OnSQLChange: TNotifyEvent read fOnSQLChange write fOnSQLChange;
             property OnSQLAdd: TSQLAddEvent read fOnSQLAdd write fOnSQLAdd;
             property OnSQLClear: TNotifyEvent read fOnSQLClear write fOnSQLClear;
    //         property Params: TParams read GetParams write SetParams;
       end;
     
       procedure Register;
     
    implementation
     
    {$R ..\Maia.dcr}
     
    { TSQLStringList }
     
    procedure TSQLStringList.Clear;
    begin
       inherited;
       if(Assigned(fOnClear)) and (UpdateCount = 0) then
       begin
          //.Exécution de la procédure associée à l'évènement.
          fOnClear(Self);
       end;
    end;
     
    function TSQLStringList.Add(const S: String): Integer;
    begin
       Result := inherited Add(S);
       if(Assigned(fOnAdd)) and (UpdateCount = 0) then
       begin
          //.Exécution de la procédure associée à l'évènement.
          fOnAdd(Self, Result);
       end;
    end;
     
    { TMaiaQuery }
     
    constructor TMaiaQuery.Create;
    begin
       inherited;
       DataSet.CommandType := ctQuery;
       PacketRecords := 20;
     
       fSQL := TSQLStringList.Create;
       fSQL.OnClear := DoSQLClear;
       fSQL.OnAdd := DoSQLAdd;
       fSQL.OnChange:= DoSQLChange;
    //   TSQLStringList(fSQL).OnClear := DoSQLClear;
    //   TSQLStringList(fSQL).OnAdd := DoSQLAdd;
    //   TSQLStringList(fSQL).OnChange:= DoSQLChange;
    end;
     
    procedure TMaiaQuery.DoSQLClear(Sender: TObject);
    begin
       if Assigned(fOnSQLClear) then
          fOnSQLClear(Self);
    end;
     
    procedure TMaiaQuery.DoSQLAdd(Sender: TObject; nIndex: Integer);
    begin
       if Assigned(fOnSQLAdd) then
          fOnSQLAdd(Self, nIndex);
    end;
     
    procedure TMaiaQuery.DoSQLChange(Sender: TObject);
    begin
       if Assigned(fOnSQLChange) then
          fOnSQLChange(Self);
       DataSet.CommandText := SQL.Text;
    end;
     
    procedure TMaiaQuery.SetSQL(Valeur: TSQLStringList);
    //procedure TMaiaQuery.SetSQL(Valeur: TStrings);
    begin
       fSQL.Assign(Valeur);
    end;
     
    function TMaiaQuery.ParamByName(const szNomParametre: String): TParam;
    begin
       Result := DataSet.Params.ParamByName(szNomParametre);
    end;
     
    //function TMaiaQuery.GetParams: TParams;
    //begin
    //   Result := DataSet.Params;
    //end;
     
    //procedure TMaiaQuery.SetParams(Valeur: TParams);
    //begin
    //   DataSet.Params := Valeur;
    //end;
     
    destructor TMaiaQuery.Destroy;
    begin
       fSQL.Free;
       inherited;
    end;
     
    procedure Register;
    begin
       RegisterComponents('Maia', [TMaiaQuery]);
    end;
     
    end.
    Je ne vois vraiment pas ce qui peut le géner (surtout qu'il n'y a même pas un petit message d'erreur pour dire ce qui ne va pas).
    L'urgent est fait, l'impossible est en cours, pour les miracles prévoir un délai. ___ Écrivez dans un français correct !!

    C++Builder 5 - Delphi 6#2 Entreprise - Delphi 2007 Entreprise - Delphi 2010 Architecte - Delphi XE Entreprise - Delphi XE7 Entreprise - Delphi 10 Entreprise - Delphi 10.3.2 Entreprise - Delphi 10.4.2 Entreprise - Delphi 11.1 Entreprise
    OpenGL 2.1 - Oracle 10g - Paradox - Interbase (XE) - PostgreSQL (15.4)

  13. #13
    Expert éminent
    Avatar de Lung
    Profil pro
    Analyste-programmeur
    Inscrit en
    Mai 2002
    Messages
    2 665
    Détails du profil
    Informations personnelles :
    Âge : 44
    Localisation : France, Haute Savoie (Rhône Alpes)

    Informations professionnelles :
    Activité : Analyste-programmeur
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Mai 2002
    Messages : 2 665
    Points : 6 977
    Points
    6 977
    Par défaut
    Je suis toujours bloqué, mais cette fois Delphi me donne une violation d'accès :
    Violation d'accès à l'adresse 50050E96 dans le module 'rtl140.bpl'. Lecture de l'adresse 00000001.
    ---------------------------
    [50050E96]{rtl140.bpl } TypInfo.GetTypeData (Line 1058, "TypInfo.pas" + 1) + $0
    [5001127C]{rtl140.bpl } System.UTF8EncodeToShortString (Line 22401, "System.pas" + 1) + $3B
    [5001129A]{rtl140.bpl } System.UTF8EncodeToShortString (Line 22402, "System.pas" + 2) + $10
    [5000814D]{rtl140.bpl } System.@PStrCpy (Line 5451, "System.pas" + 0) + $5
    [2090FE11]{coreide140.bpl} CodeMgr.EventInfoToTypeData (Line 1590, "CodeMgr.pas" + 19) + $F
    [2090FE55]{coreide140.bpl} CodeMgr.EventInfoToTypeData (Line 1595, "CodeMgr.pas" + 24) + $1C
    [500515D9]{rtl140.bpl } TypInfo.GetPropList (Line 1580, "TypInfo.pas" + 1) + $2
    [50051541]{rtl140.bpl } TypInfo.GetPropList (Line 1558, "TypInfo.pas" + 2) + $3
    [20DD4B04]{designide140.bpl} ComponentDesigner.TCompInfo.Create (Line 6449, "ComponentDesigner.pas" + 4) + $11
    [20DD4E7E]{designide140.bpl} ComponentDesigner.TCompInfo.GetSubInfo (Line 6556, "ComponentDesigner.pas" + 13) + $B
    [21928BFA]{delphicoreide140.bpl} DelphiModule.CheckSubProps (Line 1640, "DelphiModule.pas" + 4) + $A
    [21928CD5]{delphicoreide140.bpl} DelphiModule.TPascalCodeMgrModHandler.ValidateMethods (Line 1661, "DelphiModule.pas" + 8) + $6
    [219283C4]{delphicoreide140.bpl} DelphiModule.TPascalCodeMgrModHandler.Update (Line 1469, "DelphiModule.pas" + 7) + $11
    [2087214E]{coreide140.bpl} SourceModule.TCodeISourceModule.Update (Line 1497, "SourceModule.pas" + 4) + $13
    [20870410]{coreide140.bpl} SourceModule.TSourceModule.Update (Line 919, "SourceModule.pas" + 1) + $28
    [208DB553]{coreide140.bpl} DocModul.UpdateModules (Line 3558, "DocModul.pas" + 3) + $12
    [2081478A]{coreide140.bpl} BuildHost.TBuildHost.Prepare (Line 436, "BuildHost.pas" + 6) + $4
    [20813CEC]{coreide140.bpl} BuildHost.TBuildHost.Build (Line 187, "BuildHost.pas" + 8) + $7
    [20813A8B]{coreide140.bpl} BuildHost.Build (Line 141, "BuildHost.pas" + 6) + $C
    [207367FE]{coreide140.bpl} ProjectGroupBuilder.BuildProjects (Line 152, "ProjectGroupBuilder.pas" + 1) + $25
    [207A3ED7]{coreide140.bpl} ProjectGroup.TProjectGroup.CompileProjects (Line 802, "ProjectGroup.pas" + 1) + $16
    [207A3401]{coreide140.bpl} ProjectGroup.TProjectGroup.CompileActive (Line 659, "ProjectGroup.pas" + 4) + $14
    [207AA419]{coreide140.bpl} ProjectGroup.TProjectGroupWrapper.CompileActive (Line 2597, "ProjectGroup.pas" + 0) + $9
    [0041B9CA]{bds.exe } SanctuaryChecker.TLicenseManager.InternalValidateLicense (Line 1536, "ui\SanctuaryChecker.pas" + 62) + $C
    [00416315]{bds.exe } AppMain.TIDEVCLApplication.AppDataFolder (Line 6947, "ui\AppMain.pas" + 0) + $1
    [208AD5CF]{coreide140.bpl} DebuggerMgr.TDebuggerMgr.MakeCurrentProject (Line 1298, "DebuggerMgr.pas" + 75) + $11
    [208AEB91]{coreide140.bpl} DebuggerMgr.TDebuggerMgr.Run (Line 1761, "DebuggerMgr.pas" + 2) + $6
    [5007570B]{rtl140.bpl } Classes.TBasicAction.Execute (Line 12513, "Classes.pas" + 3) + $7
    [502B1915]{vcl140.bpl } ActnList.TContainedAction.Execute (Line 448, "ActnList.pas" + 8) + $2C
    [502B26F0]{vcl140.bpl } ActnList.TCustomAction.Execute (Line 1094, "ActnList.pas" + 7) + $8
    [500755CF]{rtl140.bpl } Classes.TBasicActionLink.Execute (Line 12442, "Classes.pas" + 2) + $7
    [502963C4]{vcl140.bpl } Controls.TControl.Click (Line 7176, "Controls.pas" + 7) + $7
    [5025595C]{vcl140.bpl } ComCtrls.TToolButton.Click (Line 20556, "ComCtrls.pas" + 0) + $0
    [50296881]{vcl140.bpl } Controls.TControl.WMLButtonUp (Line 7317, "Controls.pas" + 7) + $6
    [50295E70]{vcl140.bpl } Controls.TControl.WndProc (Line 7062, "Controls.pas" + 91) + $6
    [502C7C06]{vcl140.bpl } Forms.TApplication.WndProc (Line 9347, "Forms.pas" + 97) + $E
    [50295A94]{vcl140.bpl } Controls.TControl.Perform (Line 6840, "Controls.pas" + 10) + $8
    [50299ED0]{vcl140.bpl } Controls.GetControlAtPos (Line 9563, "Controls.pas" + 4) + $76
    [50299F9A]{vcl140.bpl } Controls.TWinControl.ControlAtPos (Line 9586, "Controls.pas" + 13) + $E
    [50295A94]{vcl140.bpl } Controls.TControl.Perform (Line 6840, "Controls.pas" + 10) + $8
    [5029A064]{vcl140.bpl } Controls.TWinControl.IsControlMouseMsg (Line 9610, "Controls.pas" + 15) + $2A
    [5029A5B4]{vcl140.bpl } Controls.TWinControl.WndProc (Line 9770, "Controls.pas" + 95) + $6
    [50257A41]{vcl140.bpl } ComCtrls.TToolBar.UpdateButtonState (Line 21809, "ComCtrls.pas" + 11) + $27
    [50257A82]{vcl140.bpl } ComCtrls.TToolBar.UpdateButtonStates (Line 21820, "ComCtrls.pas" + 3) + $4
    [5025A3F0]{vcl140.bpl } ComCtrls.TToolBar.WndProc (Line 23385, "ComCtrls.pas" + 104) + $6
    [50299DD8]{vcl140.bpl } Controls.TWinControl.MainWndProc (Line 9540, "Controls.pas" + 3) + $6
    [50076408]{rtl140.bpl } Classes.StdWndProc (Line 13015, "Classes.pas" + 8) + $0
    [502C8775]{vcl140.bpl } Forms.TApplication.ProcessMessage (Line 9760, "Forms.pas" + 30) + $1
    [502C87BA]{vcl140.bpl } Forms.TApplication.HandleMessage (Line 9790, "Forms.pas" + 1) + $4
    [502C8AE5]{vcl140.bpl } Forms.TApplication.Run (Line 9927, "Forms.pas" + 26) + $3
    [004369AE]{bds.exe } bds.bds (Line 200, "" + 8) + $FFFB
    L'urgent est fait, l'impossible est en cours, pour les miracles prévoir un délai. ___ Écrivez dans un français correct !!

    C++Builder 5 - Delphi 6#2 Entreprise - Delphi 2007 Entreprise - Delphi 2010 Architecte - Delphi XE Entreprise - Delphi XE7 Entreprise - Delphi 10 Entreprise - Delphi 10.3.2 Entreprise - Delphi 10.4.2 Entreprise - Delphi 11.1 Entreprise
    OpenGL 2.1 - Oracle 10g - Paradox - Interbase (XE) - PostgreSQL (15.4)

Discussions similaires

  1. Réponses: 5
    Dernier message: 20/03/2015, 09h12
  2. [D2010] Ajout dynamique de composant dans un TGridPanel
    Par Djelangelo dans le forum Composants VCL
    Réponses: 2
    Dernier message: 07/12/2010, 16h49
  3. Réponses: 13
    Dernier message: 21/05/2010, 16h54
  4. Réponses: 5
    Dernier message: 05/11/2009, 00h01
  5. Réponses: 3
    Dernier message: 26/10/2005, 10h24

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