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 :

Creer un évènement non-visuel


Sujet :

Delphi

  1. #1
    Membre averti
    Profil pro
    Inscrit en
    Janvier 2009
    Messages
    322
    Détails du profil
    Informations personnelles :
    Localisation : Canada

    Informations forums :
    Inscription : Janvier 2009
    Messages : 322
    Points : 310
    Points
    310
    Par défaut Creer un évènement non-visuel
    Bonjour à tous

    Je n'arrive pas à comprendre comment faire un objet non visuel qui déclenche un évènement afin d'être récupérer par un programme principal.


    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
     
    TGardien=class
        private
            Cible:string;
            fAlarme:Tevent;
        protected
            procedure Verifie(Ceci:string);dynamic;
            procedure LanceAlarme: Tevent;
        public
            constructor create(Sender:Tobject;  ASurveiller:string);
            destructor destroy;
            property Ceci: string read Cible write Verifie;
            property Alarme: tevent read LanceAlarme write LanceAlarme;
     
    end;
    implementation
          constructor create(Sender:Tobject;  ASurveiller:string);
          begin
                Cible:=ASuveiller;
          end;
     
         procedure Verifie(Ceci:string);
         begin
               if Ceci=Cible then begin
                     ????
               end;
         end;
    Ensuite comment arrime-t'on ce composant à la fiche

    Par exemple
    Déclaration d'un event dans la fiche ?
    Affectation de l'event au moment de la création de l'objet?


    Merci d'avance

  2. #2
    Membre actif Avatar de Basile le disciple
    Homme Profil pro
    étudiant Centrale Supélec
    Inscrit en
    Avril 2013
    Messages
    147
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 25
    Localisation : France, Charente Maritime (Poitou Charente)

    Informations professionnelles :
    Activité : étudiant Centrale Supélec

    Informations forums :
    Inscription : Avril 2013
    Messages : 147
    Points : 279
    Points
    279
    Par défaut
    Si j'ai bien compris la question :

    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
     
    TGardien=class
        private
            Cible:string;
            fAlarme:Tevent;
        protected
            procedure Verifie(Ceci:string);dynamic;
         //   procedure LanceAlarme: Tevent;
        public
            constructor create(Sender:Tobject;  ASurveiller:string);
            destructor destroy;
            property Ceci: string read Cible write Verifie;
            property Alarme: tevent read fAlarme write fAlarme;
     
    end;
    implementation
          constructor create(Sender:Tobject;  ASurveiller:string);
          begin
                Cible:=ASuveiller;
          end;
     
      procedure Verifie(Ceci:string);
         begin
               if Ceci=Cible then begin
                     if assigned(fAlarme) then falarme(+ les variables);
               end;
         end;
    et dans la fiche :

    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
     
     
     
    Gardien : TGardien;
    procedure alarme(les variables);
     
    .....
     
    procedure TForm1.FormCreate(Sender: TObject);
    begin
       Gardien:=TGardien.Create(self,'...');
       Gardien.Alarme:=alarme;
    end;
     
    procedure TForm1.Alarme(...);
    begin
     
    end;

  3. #3
    Membre averti
    Profil pro
    Inscrit en
    Janvier 2009
    Messages
    322
    Détails du profil
    Informations personnelles :
    Localisation : Canada

    Informations forums :
    Inscription : Janvier 2009
    Messages : 322
    Points : 310
    Points
    310
    Par défaut
    Merci beaucoup

    J'essaye ça demain

  4. #4
    Expert éminent sénior
    Avatar de Paul TOTH
    Homme Profil pro
    Freelance
    Inscrit en
    Novembre 2002
    Messages
    8 964
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 54
    Localisation : France, Paris (Île de France)

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

    Informations forums :
    Inscription : Novembre 2002
    Messages : 8 964
    Points : 28 445
    Points
    28 445
    Par défaut
    petite précision supplémentaire, si l'objet dériver de TComponent il est possible de l'enregistrer dans la palette de composants comme un composant non-visuel.
    Developpez.com: Mes articles, forum FlashPascal
    Entreprise: Execute SARL
    Le Store Excute Store

  5. #5
    Membre averti
    Profil pro
    Inscrit en
    Janvier 2009
    Messages
    322
    Détails du profil
    Informations personnelles :
    Localisation : Canada

    Informations forums :
    Inscription : Janvier 2009
    Messages : 322
    Points : 310
    Points
    310
    Par défaut
    Bonjour, il y a quelque chose qui m'échappe...

    Citation Envoyé par Basile le disciple Voir le message

    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
    TGardien=class
        private
            Cible:string;
            fAlarme:Tevent;
        protected
            procedure Verifie(Ceci:string);dynamic;
        public
            constructor create(Sender:Tobject;  ASurveiller:string);
            destructor destroy;
            property Ceci: string read Cible write Verifie;
            property Alarme: tevent read fAlarme write fAlarme;
     
    end;
    implementation
    ...
    
      procedure Verifie(Ceci:string);
         begin
               if Ceci=Cible then begin
                     if assigned(fAlarme) then falarme(+ les variables);
               end;
         end;
    Quelles sont les variables?

    J'ai essayer ceci:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
     
        if ASurveiller=Ceci then 
           if assigned(fAlarme) then falarme(self,Ceci);//Message du compilateur : "opérateur ou point virgule manquant"
     
    //ceci
     
        if ASurveiller=Ceci then 
           if assigned(fAlarme) then falarme(Ceci);//idem
     
    //et ceci
     
        if ASurveiller=Ceci then 
           if assigned(fAlarme) then falarme(self);//idem
    Marche pôs

    Merci d'avance

  6. #6
    Membre averti
    Profil pro
    Inscrit en
    Janvier 2009
    Messages
    322
    Détails du profil
    Informations personnelles :
    Localisation : Canada

    Informations forums :
    Inscription : Janvier 2009
    Messages : 322
    Points : 310
    Points
    310
    Par défaut
    On trouve la réponse ici :

    http://www.developpez.net/forums/d50...-tnotifyevent/

    Un événement personnalisé s'écrit donc comme ceci :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    TNewEvent = procedure (Sender: TObject; Param1: string; Param2 : integer;...) of object;
    ou

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    TNewEvent = function (Sender: TObject; Param1: float;...) : String of object;
    Merci à tous

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

Discussions similaires

  1. mouseMoved -> pertes ou événements non déclenchés
    Par karibouk dans le forum Interfaces Graphiques en Java
    Réponses: 7
    Dernier message: 16/10/2006, 15h55
  2. Creer un composant non visuel(Timer) dans une DLL
    Par hugobob dans le forum Composants VCL
    Réponses: 1
    Dernier message: 06/06/2006, 16h20
  3. Gestionnaires d'évènements non déclenchés
    Par Sylvain James dans le forum XMLRAD
    Réponses: 7
    Dernier message: 19/04/2006, 18h14
  4. Je recherche un composant Tree non visuel, structure mémoire
    Par bambino3996 dans le forum Composants VCL
    Réponses: 5
    Dernier message: 05/09/2005, 17h03
  5. Destructeur pour un composant non visuel
    Par sfpx dans le forum Composants VCL
    Réponses: 4
    Dernier message: 27/08/2005, 02h14

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