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

C++Builder Discussion :

Probl�me de cr�ation de composant FMX


Sujet :

C++Builder

Vue hybride

Message pr�c�dent Message pr�c�dent   Message suivant Message suivant
  1. #1
    Membre �m�rite
    Avatar de Gouyon
    Homme Profil pro
    D�veloppeur informatique
    Inscrit en
    Novembre 2003
    Messages
    1 138
    D�tails du profil
    Informations personnelles :
    Sexe : Homme
    �ge : 61
    Localisation : France, Loiret (Centre)

    Informations professionnelles :
    Activit� : D�veloppeur informatique
    Secteur : A�ronautique - Marine - Espace - Armement

    Informations forums :
    Inscription : Novembre 2003
    Messages : 1 138
    Billets dans le blog
    5
    Par d�faut Probl�me de cr�ation de composant FMX
    Bonjour � tous

    Voil� je suis en train de d�velopper un composant FireMonkey. Il s'agit d'un composant qui affiche une courbe d�filante. J'ai souhait� faire ce composant car j'ai besoin d'un affichage rapide et l'utilisation de TChart ne r�pondait pas au besoin.
    Je me suis inspir� de plusieurs tutoriels (https://sjrd.developpez.com/delphi/tutoriel/composants/ et http://docwiki.embarcadero.com/RADSt...osant_existant )

    Je suis parvenu � faire une premi�re version de mon composant mais quand je le d�pose sur une fiche j'ai syst�matiquement cette erreur qui s'affiche: Verrou d'objet non poss�d�

    Voici l'ent�te
    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
     
    //---------------------------------------------------------------------------
     
    #ifndef GraphicDefilantH
    #define GraphicDefilantH
    //---------------------------------------------------------------------------
    #include <System.SysUtils.hpp>
    #include <System.Classes.hpp>
    #include <FMX.Controls.hpp>
    #include <FMX.Types.hpp>
    //---------------------------------------------------------------------------
    class PACKAGE TGraphicDefilant : public TStyledControl
    {
    private:
    	String FFormatX;
    	String FFormatY;
        void __fastcall SetFormatX(const String Value);
    	void __fastcall SetFormatY(const String Value);
    protected:
    public:
    	__fastcall TGraphicDefilant(TComponent* Owner);
        void __fastcall Paint();
    __published:
    	__property String FormatX = {read = FFormatX, write = SetFormatX};
    	__property String FormatY = {read = FFormatY, write = SetFormatY};
    };
    //---------------------------------------------------------------------------
    #endif
    et le cpp
    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
     
    // ---------------------------------------------------------------------------
     
    #include <fmx.h>
     
    #pragma hdrstop
     
    #include "GraphicDefilant.h"
    #pragma package(smart_init)
    // ---------------------------------------------------------------------------
    // ValidCtrCheck est utilisée pour garantir que les composants créés n'ont pas
    // de fonctions virtuelles pures.
    //
     
    static inline void ValidCtrCheck(TGraphicDefilant *) {
    	new TGraphicDefilant(NULL);
    }
     
    // ---------------------------------------------------------------------------
    __fastcall TGraphicDefilant::TGraphicDefilant(TComponent* Owner)
    	: TStyledControl(Owner) {
    	FFormatX = "%3.2f";
    	FFormatY = "%3.2f";
    }
     
    // ---------------------------------------------------------------------------
    namespace Graphicdefilant {
    	void __fastcall PACKAGE Register() {
    		TComponentClass classes[1] = {__classid(TGraphicDefilant)};
    		RegisterComponents(L"Samples", classes, 0);
    	}
    }
     
    // ---------------------------------------------------------------------------
    void __fastcall TGraphicDefilant::Paint() {
    	TStyledControl::Paint();
     
    	double minY = -1;
    	double maxY = 1;
    	double minX = 0;
    	double maxX = 200;
    	TVarRec arga[1] = {(long double)minY};
    	String stYmin = Format(FormatY, arga, 0);
    	TVarRec argb[1] = {(long double)maxY};
    	String stYmax = Format(FormatY, argb, 0);
    	TVarRec argc[1] = {(long double)minX};
    	String stXmin = Format(FormatX, argc, 0);
    	TVarRec argd[1] = {(long double)minY};
    	String stXmax = Format(FormatX, argd, 0);
     
    	int marge = 4;
     
    	Canvas->Fill->Color = claWhite;
    	Canvas->FillRect(TRectF(0, 0, Width, Height), 0, 0, AllCorners, 100);
     
    	float HXtxt = Canvas->TextHeight(stXmin);
    	if (Canvas->TextHeight(stXmax) > HXtxt)
    		HXtxt = Canvas->TextHeight(stXmax);
     
    	float LYtxt = Canvas->TextWidth(stYmin);
    	if (Canvas->TextWidth(stYmax) > LYtxt)
    		LYtxt = Canvas->TextWidth(stYmax);
     
    	float HYtxt1 = Canvas->TextHeight(stYmax);
    	float HYtxt0 = Canvas->TextHeight(stYmin);
    	float LXtxt1 = Canvas->TextWidth(stXmax);
    	float LXtxt0 = Canvas->TextWidth(stXmin);
     
    	float Ay = marge + HYtxt1 / 2;
    	float Ax = marge + LYtxt + marge;
    	float Ox = Ax;
    	float Oy = Height - marge - HXtxt - marge;
    	float By = Oy;
    	float Bx = Width - marge - LXtxt1 / 2 - marge;
     
    	Canvas->Stroke->Color = claBlack;
    	Canvas->DrawRect(TRectF(Ax, Ay, Bx, By), 0, 0, AllCorners, 100);
     
    	Canvas->Fill->Color = claBlack;
    	Canvas->FillText(TRectF(marge, marge, marge + LYtxt, marge + HYtxt1),
    		stYmax, false, 1, TFillTextFlags() << TFillTextFlag::RightToLeft,
    		TTextAlign::Center, TTextAlign::Center);
    	Canvas->FillText(TRectF(marge, Oy - HYtxt0 / 2, marge + LYtxt,
    		Oy - HYtxt0 / 2 + HYtxt0), stYmin, false, 1,
    		TFillTextFlags() << TFillTextFlag::RightToLeft, TTextAlign::Center,
    		TTextAlign::Center);
    	Canvas->FillText(TRectF(Ox - LXtxt0 / 2, Oy + marge, Ox + LXtxt0 / 2,
    		Oy + marge + HXtxt), stXmin, false, 1,
    		TFillTextFlags() << TFillTextFlag::RightToLeft, TTextAlign::Center,
    		TTextAlign::Center);
    	Canvas->FillText(TRectF(Bx - LXtxt1 / 2, Oy + marge, Bx + LXtxt1 / 2,
    		Oy + marge + HXtxt), stXmax, false, 1,
    		TFillTextFlags() << TFillTextFlag::RightToLeft, TTextAlign::Center,
    		TTextAlign::Center);
    	Canvas->EndScene();
    }
     
    // ---------------------------------------------------------------------------
    void __fastcall TGraphicDefilant::SetFormatX(const String Value) {
    	FFormatX = Value;
    }
     
    // ---------------------------------------------------------------------------
    void __fastcall TGraphicDefilant::SetFormatY(const String Value) {
    	FFormatY = Value;
    }
    // ---------------------------------------------------------------------------
    Une id�e d'o� �a peut venir?

  2. #2
    Membre Expert
    Avatar de Crayon
    Inscrit en
    Avril 2005
    Messages
    1 811
    D�tails du profil
    Informations personnelles :
    Localisation : Autre

    Informations forums :
    Inscription : Avril 2005
    Messages : 1 811
    Par d�faut
    Salut, la solution est simple. Tu as un 'Canvas->EndScene();' et tu n'as jamais de 'Canvas->BeginScene();'

    Je te sugg�re de le mettre avant de d�buter tes manipulations de Canvas:
    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
            Canvas->BeginScene();
    	Canvas->Stroke->Color = claBlack;
    	Canvas->DrawRect(TRectF(Ax, Ay, Bx, By), 0, 0, AllCorners, 100);
     
    	Canvas->Fill->Color = claBlack;
    	Canvas->FillText(TRectF(marge, marge, marge + LYtxt, marge + HYtxt1),
    		stYmax, false, 1, TFillTextFlags() << TFillTextFlag::RightToLeft,
    		TTextAlign::Center, TTextAlign::Center);
    	Canvas->FillText(TRectF(marge, Oy - HYtxt0 / 2, marge + LYtxt,
    		Oy - HYtxt0 / 2 + HYtxt0), stYmin, false, 1,
    		TFillTextFlags() << TFillTextFlag::RightToLeft, TTextAlign::Center,
    		TTextAlign::Center);
    	Canvas->FillText(TRectF(Ox - LXtxt0 / 2, Oy + marge, Ox + LXtxt0 / 2,
    		Oy + marge + HXtxt), stXmin, false, 1,
    		TFillTextFlags() << TFillTextFlag::RightToLeft, TTextAlign::Center,
    		TTextAlign::Center);
    	Canvas->FillText(TRectF(Bx - LXtxt1 / 2, Oy + marge, Bx + LXtxt1 / 2,
    		Oy + marge + HXtxt), stXmax, false, 1,
    		TFillTextFlags() << TFillTextFlag::RightToLeft, TTextAlign::Center,
    		TTextAlign::Center);
    	Canvas->EndScene();
    Pour ceux que sa int�resse le message d'exception EMonitorLockException en anglais est le suivant: Object lock not owned.

  3. #3
    Membre �m�rite
    Avatar de Gouyon
    Homme Profil pro
    D�veloppeur informatique
    Inscrit en
    Novembre 2003
    Messages
    1 138
    D�tails du profil
    Informations personnelles :
    Sexe : Homme
    �ge : 61
    Localisation : France, Loiret (Centre)

    Informations professionnelles :
    Activit� : D�veloppeur informatique
    Secteur : A�ronautique - Marine - Espace - Armement

    Informations forums :
    Inscription : Novembre 2003
    Messages : 1 138
    Billets dans le blog
    5
    Par d�faut
    Arghh je l'avais pas vu en fait il a du �tre effac� lors d'une �dition du code et comme j'avais introduit d'autres �l�ments je pensais que �a venais de l�

+ R�pondre � la discussion
Cette discussion est r�solue.

Discussions similaires

  1. [Lazarus] Cr�ation de composant - Probl�me � la cr�ation dans l'IDE
    Par Jon Shannow dans le forum Lazarus
    R�ponses: 4
    Dernier message: 03/12/2012, 10h34
  2. [Lazarus] Probl�me de cr�ation de composant
    Par Gouyon dans le forum Lazarus
    R�ponses: 24
    Dernier message: 05/11/2011, 23h25
  3. Probl�me : cr�ation de composants
    Par programaniac dans le forum VB.NET
    R�ponses: 18
    Dernier message: 18/02/2008, 08h20
  4. Cr�ation de composants: Probl�me lors du Destroy
    Par fred64 dans le forum Langage
    R�ponses: 17
    Dernier message: 13/12/2007, 22h42
  5. R�ponses: 1
    Dernier message: 29/05/2007, 00h00

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