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 :

Composant enregistrant les propriétés des composants


Sujet :

Delphi

  1. #1
    Membre à l'essai
    Profil pro
    Developpeur
    Inscrit en
    Août 2005
    Messages
    22
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations professionnelles :
    Activité : Developpeur

    Informations forums :
    Inscription : Août 2005
    Messages : 22
    Points : 16
    Points
    16
    Par défaut Composant enregistrant les propriétés des composants
    bonjour
    je cherche un composant permettant d'enregistrer les propriétés des composants dans un fichier ini ou dans le registre. J'ai déja trouvé ca dans la rxlib (TformStorage), mais impossible de l'installer sous D2005 PE (j'avais ca sous D6). Si vous conaissez un composant comme ca (ou si vous savez comment installer celui de la rxlib sous D2005, ca me va aussi)

    Merci davance

  2. #2
    Expert éminent sénior
    Avatar de ShaiLeTroll
    Homme Profil pro
    Développeur C++\Delphi
    Inscrit en
    Juillet 2006
    Messages
    13 584
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 43
    Localisation : France, Seine Saint Denis (Île de France)

    Informations professionnelles :
    Activité : Développeur C++\Delphi
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Juillet 2006
    Messages : 13 584
    Points : 25 251
    Points
    25 251
    Par défaut
    Regarde l'unité TypInfo (pas de e), et le fonction genre GetPropValue, ... tu pourras toi même récupérer les valeurs publiées et les écrires dans un fichier ini !

    Sinon, tu peux bidouillé ce code issu de l'aide de Delphi, cela renvoie une DFM, tu peux facilement transformer le contenu pour le mettre dans un fichier ini, tu vires les valeurs qui ne t'intéresse pas ... je l'ai fait pour la couche de persistance que j'ai pondu au boulot, qui fonctionne soit orienté DB (donc passe par les RTTI) soit via du XML qui l'on transfome via XSL en DFM, pour remplir via Flux les Objets ... je voudrais bien te passer du code, mais c'est réparti dans 3 unités d'envion 2000 lignes chacune ...

    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
    function ComponentToString(Component: TComponent): string;
     
    var
      BinStream:TMemoryStream;
      StrStream: TStringStream;
      s: string;
    begin
      BinStream := TMemoryStream.Create;
      try
        StrStream := TStringStream.Create(s);
        try
          BinStream.WriteComponent(Component);
          BinStream.Seek(0, soFromBeginning);
          ObjectBinaryToText(BinStream, StrStream);
          StrStream.Seek(0, soFromBeginning);
          Result:= StrStream.DataString;
        finally
          StrStream.Free;
     
        end;
      finally
        BinStream.Free
      end;
    end;
     
    // -----------------------------------------------------------
    function StringToComponent(Value: string): TComponent;
    var
      StrStream:TStringStream;
      BinStream: TMemoryStream;
    begin
      StrStream := TStringStream.Create(Value);
      try
        BinStream := TMemoryStream.Create;
        try
          ObjectTextToBinary(StrStream, BinStream);
          BinStream.Seek(0, soFromBeginning);
          Result := BinStream.ReadComponent(nil);
     
        finally
          BinStream.Free;
        end;
      finally
        StrStream.Free;
      end;
    end;

  3. #3
    Membre habitué
    Profil pro
    Inscrit en
    Janvier 2007
    Messages
    160
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Janvier 2007
    Messages : 160
    Points : 167
    Points
    167
    Par défaut
    hoooo... mais c'est excellent cela!

  4. #4
    Membre émérite Avatar de edam
    Homme Profil pro
    Développeur Delphi/c++/Omnis
    Inscrit en
    Décembre 2003
    Messages
    1 894
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Maroc

    Informations professionnelles :
    Activité : Développeur Delphi/c++/Omnis
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Décembre 2003
    Messages : 1 894
    Points : 2 770
    Points
    2 770
    Par défaut
    voir rxlib il ya un composant:
    TFormStorage
    Description
    In 32-bit version, when UseRegistry is True, TFormStorage uses standard TRegIniFile class. So the IniFileName passed to a TFormStorage component becomes a subkey under the system registry’s root key (HKEY_CURRENT_USER by default).

    TFormStorage will work with any component or control you might have. Even 3rd party controls or controls you have designed yourself.

    Using class TFormStorage

    At design-time use component editor to add published properties of any other components to list of stored properties of TFormStorage component.

    To save and restore the position of TRxSplitter component add to stored properties the Width or Height (according to Align property) of one of splitted controls (ControlFirst or ControlSecond).

    To save and restore active page of tabbed controls (TNotebook, TTabbedNotebook or TPageControl) store ActivePage or PageIndex property.

    You can save and restore text of edit controls by adding to stored properties the Text property for TEdit or Lines property for TMemo.

    Use TFormStorage to save and restore state of windowed controls such as TCheckBox, TRadioGroup etc.

    Link the TFormStorage (or TFormPlacement) component to IniStorage property of some another components to save and load information specific for these components (TRxCheckListBox, TRxDrawGrid, TSpeedbar, TMRUManager, TRxDBGrid) with no additional code.

    TFormStorage component allows you to read and write virtually any component published property to an INI file or the system Registry with virtually no code.

  5. #5
    Membre à l'essai
    Profil pro
    Developpeur
    Inscrit en
    Août 2005
    Messages
    22
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations professionnelles :
    Activité : Developpeur

    Informations forums :
    Inscription : Août 2005
    Messages : 22
    Points : 16
    Points
    16
    Par défaut
    merci pour le code c'est pas mal mais je recherche un composant qui fait ca tout seul (même si ton code pourrait m'être utile)

    Citation Envoyé par edam
    voir rxlib il ya un composant:
    j'ai déja essayé la rxlib mais je n'arrive pas à l'installer sous delphi 2005 personnal, si vous savez comment l'installer...

  6. #6
    Membre à l'essai
    Profil pro
    Inscrit en
    Avril 2002
    Messages
    19
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2002
    Messages : 19
    Points : 12
    Points
    12
    Par défaut
    Moi aussi, j'aimerai bien utiliser RxLib sous D2005, j'ai beau avoir installé JVCL qui normalement inclus RxLib, je ne vois toujours pas ces composants.
    J'ai des projets qui contiennent des compo Rx mais impossible de les recompiler...

Discussions similaires

  1. Les styles des composants asp.net !
    Par rad_hass dans le forum ASP.NET
    Réponses: 7
    Dernier message: 26/09/2008, 10h12
  2. Modifier les propriétés des composants d'une autre form
    Par souminet dans le forum Débuter
    Réponses: 3
    Dernier message: 20/08/2008, 09h09
  3. Réponses: 2
    Dernier message: 06/04/2007, 10h26
  4. Sauvegarder les propriétés de composant
    Par yoshï dans le forum Interfaces Graphiques en Java
    Réponses: 3
    Dernier message: 24/05/2006, 10h49

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