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 :

CheckBox in Shape ( modifié en checkBox in Panel )


Sujet :

Composants VCL Delphi

  1. #1
    Membre éprouvé Avatar de BuzzLeclaire
    Homme Profil pro
    Dev/For/Vte/Ass
    Inscrit en
    Août 2008
    Messages
    1 606
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Dev/For/Vte/Ass

    Informations forums :
    Inscription : Août 2008
    Messages : 1 606
    Points : 1 113
    Points
    1 113
    Par défaut CheckBox in Shape ( modifié en checkBox in Panel )
    Bonjour à toutes et à tous,

    Comment peut-on ajouter un CheckBox sur un shape ? Sachant que le Shape est personnalisé avec un dégarder.

    Vois mon ShapeRu :

    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
    unit ShapeRu;
     
    interface
     
    uses
      Windows, SysUtils, Classes, Controls, ExtCtrls, Graphics, Math, Grids,
      StrUtils, dialogs, Messages;
     
    type
      TShapeRu = class(TShape)
      private
        { Déclarations }
        FStartColor    : Tcolor;
        FEndColor      : Tcolor ;
        fCaption1      : String;
        fCaption2      : String;
      protected
        { Déclarations protégées }
        procedure Paint; override;
      public
        { Déclarations publiques }
        constructor Create(AOwner : TComponent); override;
        destructor Destroy; override;
      published
        { Déclarations publiées }
        property Caption;
        property StartColor    : Tcolor read fStartColor write fStartColor ;
        property EndColor      : Tcolor read FEndColor write FEndColor ;
        property Caption1      : String read fCaption1 write fCaption1;
        property Caption2      : String read fCaption2 write fCaption2;
     
        property PopupMenu;
      end;
     
    procedure Register;
     
    implementation
     
    constructor TShapeRu.Create(AOwner : TComponent);
    begin
      inherited Create(AOwner);
    end;
     
    destructor TShapeRu.Destroy;
    begin
      inherited Destroy;
    end;
     
    procedure TShapeRu.Paint;
      Procedure Degrader;
      Var
        TailleDuTexte : Integer;
        aBand : TRect;    { Bande rectangulaire de couleur courante }
        i : Integer;  { Compteur pour parcourir la hauteur de la fiche }
        FStartRGB  : Array[0..2] of Byte;    { RGB de la couleur de départ }
        FCurrentRGB : Array[0..2] of Byte;    { RGB de la couleur courante  }
        FDeltaRGB  : Array[0..2] of Integer; { RGB à ajouter à la couleur de départ pour atteindre la couleur de fin }
        nbtranches: integer;
        Rect:TRect;
      Begin
        Rect.Left := 2;
        Rect.Top := 2;
        Rect.Right := Self.Width-2;
        Rect.Bottom := Self.Height-2;
        self.ParentColor := false;
        { Calcul des valeurs RGB pour la couleur courante }
        FStartRGB[0] := GetRValue( ColorToRGB( StartColor ) );
        FStartRGB[1] := GetGValue( ColorToRGB( StartColor ) );
        FStartRGB[2] := GetBValue( ColorToRGB( StartColor ) );
        { Calcul des valeurs à ajouter pour atteindre la couleur de fin }
        FDeltaRGB[0] := GetRValue( ColorToRGB( EndColor )) - FStartRGB[0] ;
        FDeltaRGB[1] := GetgValue( ColorToRGB( EndColor )) - FStartRGB[1] ;
        FDeltaRGB[2] := GetbValue( ColorToRGB( EndColor )) - FStartRGB[2] ;
     
        { Initialisation des dimensions de la bande de couleur }
        aBand.Left :=Rect.Left;
        aBand.Right:=Rect.Right;
        nbtranches:=min(256, Rect.Bottom-Rect.Top);
        { Boucle pour remplir la fiche courante en dégradé }
        With Canvas Do
        Begin
          Pen.Style:=psSolid;
          Pen.Mode:=pmCopy;
          For i:= 0 To nbtranches-1 Do
          Begin
              { Dimensions verticales de la bande }
              aBand.Left :=Rect.Left;
              aBand.Right:=Rect.Right;
              aBand.Top := Rect.Top+Round((Rect.Bottom-Rect.Top)/nbtranches*i);
              aBand.Bottom := Rect.Top+Round((Rect.Bottom-Rect.Top)/nbtranches*(i+1));
     
              { Calcul de la couleur courante }
              FCurrentRGB[0] := (FStartRGB[0] + MulDiv( i , FDeltaRGB[0] , nbtranches )) mod 256;
              FCurrentRGB[1] := (FStartRGB[1] + MulDiv( i , FDeltaRGB[1] , nbtranches )) mod 256;
              FCurrentRGB[2] := (FStartRGB[2] + MulDiv( i , FDeltaRGB[2] , nbtranches )) mod 256;
              { Affichage sur la fiche }
              Brush.color:=RGB(FCurrentRGB[0],FCurrentRGB[1],FCurrentRGB[2]);
              FillRect(aBand);
          End;
          Font.Name := Self.Font.Name;
          Font.Size   := self.Font.Size;
          Brush.Style := bsClear;
          if Self.Caption1 = '' then DrawText(Canvas.Handle, PChar(Self.Caption) , -1, Rect, DT_NOPREFIX or DT_VCENTER or DT_SINGLELINE)
          else
          Begin
            DrawText(Canvas.Handle, PChar(Self.Caption1) , -1, Rect, DT_CENTER or DT_NOPREFIX or DT_WORDBREAK);
            TailleDuTexte := DrawText(Canvas.Handle, PChar(Self.Caption1) , -1, Rect, DT_CENTER or DT_NOPREFIX or DT_WORDBREAK);
            Rect.Top := Rect.Top + TailleDuTexte + 2;
            Pen.Color := clBlack;
            MoveTo(Rect.Left+2,Rect.Top);
            LineTo(Rect.Right-2,Rect.top);
            Rect.Top := Rect.Top + 2;
            DrawText(Canvas.Handle, PChar(Self.Caption2) , -1, Rect, DT_NOPREFIX or DT_WORDBREAK);
          end;
        End;
      End;
    begin
      inherited Paint;
      Degrader;
    end;
     
    procedure Register;
    begin
      RegisterComponents('RuCompos', [TShapeRu]);
    end;
     
    end.
    J'ai essayé quelque truc, mais il apparait jamais le checkbox.

    Pouvez-vous m'aider ?

  2. #2
    Membre éprouvé Avatar de BuzzLeclaire
    Homme Profil pro
    Dev/For/Vte/Ass
    Inscrit en
    Août 2008
    Messages
    1 606
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Dev/For/Vte/Ass

    Informations forums :
    Inscription : Août 2008
    Messages : 1 606
    Points : 1 113
    Points
    1 113
    Par défaut
    Re bonjour,

    Je suis partis sur un nouveau composant pour ne pas toucher à celui-ci.

    Mais je ne sais pas du toiut comment faire dans ma procedure PAINT pour placer mon Check box.
    Est-ce que dans le create du compo le terme SELF et approrié pour la creation du checkbox ?

    Voici le composant avec un propriété CheckBox

    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
    unit ShapeBoxRu;
     
    interface
     
    uses
      Windows, SysUtils, Classes, Controls, StdCtrls ,ExtCtrls, Graphics, Math, Grids,
      StringGridRu, StrUtils, dialogs, Messages;
     
    type
      TShapeBoxRu = class(TShape)
      private
        { Déclarations }
        fStartColor    : Tcolor;
        fEndColor      : Tcolor;
        fCheckBox      : TCheckBox;
        procedure SetCheckBox(value: TCheckBox);
      protected
        { Déclarations protégées }
        procedure Paint; override;
        procedure WMMOUSEWHEEL(var Message: TMessage); message WM_MOUSEWHEEL;
     
      public
        { Déclarations publiques }
        constructor Create(AOwner : TComponent); override;
        destructor Destroy; override;
      published
        { Déclarations publiées }
        property Caption;
        property StartColor    : Tcolor read fStartColor write fStartColor;
        property EndColor      : Tcolor read fEndColor write FEndColor;
        property CheckBox      : TCheckBox read fCheckBox write SetCheckBox;
      end;
     
    procedure Register;
     
    implementation
     
    constructor TShapeBoxRu.Create(AOwner : TComponent);
    begin
      inherited Create(AOwner);
      fCheckBox := fCheckBox.Create(Self);
    end;
     
    destructor TShapeBoxRu.Destroy;
    begin
      fCheckBox.Free;
      inherited Destroy;
    end;
     
    procedure TShapeBoxRu.SetCheckBox(value: TCheckBox);
    begin
      fCheckBox.assign(value);
    end;
     
    procedure TShapeBoxRu.Paint;
      Procedure Degrader;
      Var
        TailleDuTexte : Integer;
        aBand : TRect;    { Bande rectangulaire de couleur courante }
        i : Integer;  { Compteur pour parcourir la hauteur de la fiche }
        FStartRGB  : Array[0..2] of Byte;    { RGB de la couleur de départ }
        FCurrentRGB : Array[0..2] of Byte;    { RGB de la couleur courante  }
        FDeltaRGB  : Array[0..2] of Integer; { RGB à ajouter à la couleur de départ pour atteindre la couleur de fin }
        nbtranches: integer;
        Rect:TRect;
      Begin
        Rect.Left := 2;
        Rect.Top := 2;
        Rect.Right := Self.Width-2;
        Rect.Bottom := Self.Height-2;
        self.ParentColor := false;
        { Calcul des valeurs RGB pour la couleur courante }
        FStartRGB[0] := GetRValue( ColorToRGB( StartColor ) );
        FStartRGB[1] := GetGValue( ColorToRGB( StartColor ) );
        FStartRGB[2] := GetBValue( ColorToRGB( StartColor ) );
        { Calcul des valeurs à ajouter pour atteindre la couleur de fin }
        FDeltaRGB[0] := GetRValue( ColorToRGB( EndColor )) - FStartRGB[0] ;
        FDeltaRGB[1] := GetgValue( ColorToRGB( EndColor )) - FStartRGB[1] ;
        FDeltaRGB[2] := GetbValue( ColorToRGB( EndColor )) - FStartRGB[2] ;
     
        { Initialisation des dimensions de la bande de couleur }
        aBand.Left :=Rect.Left;
        aBand.Right:=Rect.Right;
        nbtranches:=min(256, Rect.Bottom-Rect.Top);
        { Boucle pour remplir la fiche courante en dégradé }
        With Canvas Do
        Begin
          Pen.Style:=psSolid;
          Pen.Mode:=pmCopy;
          For i:= 0 To nbtranches-1 Do
          Begin
              { Dimensions verticales de la bande }
              aBand.Left :=Rect.Left;
              aBand.Right:=Rect.Right;
              aBand.Top := Rect.Top+Round((Rect.Bottom-Rect.Top)/nbtranches*i);
              aBand.Bottom := Rect.Top+Round((Rect.Bottom-Rect.Top)/nbtranches*(i+1));
     
              { Calcul de la couleur courante }
              FCurrentRGB[0] := (FStartRGB[0] + MulDiv( i , FDeltaRGB[0] , nbtranches )) mod 256;
              FCurrentRGB[1] := (FStartRGB[1] + MulDiv( i , FDeltaRGB[1] , nbtranches )) mod 256;
              FCurrentRGB[2] := (FStartRGB[2] + MulDiv( i , FDeltaRGB[2] , nbtranches )) mod 256;
              { Affichage sur la fiche }
              Brush.color:=RGB(FCurrentRGB[0],FCurrentRGB[1],FCurrentRGB[2]);
              FillRect(aBand);
          End;
          Font.Name := Self.Font.Name;
          Font.Size := Self.Font.Size;
          Brush.Style := bsClear;
          DrawText(Canvas.Handle, PChar(Self.Caption) , -1, Rect, DT_NOPREFIX or DT_VCENTER or DT_SINGLELINE)
        End;
      End;
    begin
      inherited Paint;
      Degrader;
    end;
     
    procedure TShapeBoxRu.WMMOUSEWHEEL(var Message: TMessage);
    begin
      inherited;
      TStringGridRu(Parent).CheckInBounds;
    end;
     
    procedure Register;
    begin
      RegisterComponents('RuCompos', [TShapeBoxRu]);
    end;
     
    end.
    Peut-etre que ce que je fais est pas possible ?

  3. #3
    Membre chevronné
    Avatar de Archimède
    Homme Profil pro
    Enseignant
    Inscrit en
    Avril 2005
    Messages
    1 644
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 58
    Localisation : France, Charente Maritime (Poitou Charente)

    Informations professionnelles :
    Activité : Enseignant
    Secteur : Enseignement

    Informations forums :
    Inscription : Avril 2005
    Messages : 1 644
    Points : 1 975
    Points
    1 975
    Par défaut
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
     
    constructor TShapeBoxRu.Create(AOwner : TComponent);
    begin
      inherited Create(AOwner);
      fCheckBox := fCheckBox.Create(Self);
      fCheckBox.parent:=self;
    end;
    je crois que si tu ne définis pas son parent, tu ne le verras pas...

  4. #4
    Membre éprouvé Avatar de BuzzLeclaire
    Homme Profil pro
    Dev/For/Vte/Ass
    Inscrit en
    Août 2008
    Messages
    1 606
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Dev/For/Vte/Ass

    Informations forums :
    Inscription : Août 2008
    Messages : 1 606
    Points : 1 113
    Points
    1 113
    Par défaut
    Citation Envoyé par Archimède Voir le message
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
     
    constructor TShapeBoxRu.Create(AOwner : TComponent);
    begin
      inherited Create(AOwner);
      fCheckBox := fCheckBox.Create(Self);
      fCheckBox.parent:=self;
    end;
    je crois que si tu ne définis pas son parent, tu ne le verras pas...
    Salut,

    En fait en voulant poser un TShapeBoxRu sur une form vierge, j'ai droit à un super message d'erreur (je suis pas pro des compos perso) et j'ai ajouter ta proposition et là je peux carément pas compiler :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    [DCC Erreur] ShapeBoxRu.pas(43): E2010 Types incompatibles : 'TWinControl' et 'TComponent'
    Sur la ligne du parent.

  5. #5
    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
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
     fCheckBox := fCheckBox.Create(Self);


    Code : Sélectionner tout - Visualiser dans une fenêtre à part
     fCheckBox := TCheckBox.Create(Self);
    @+

  6. #6
    Membre chevronné
    Avatar de Archimède
    Homme Profil pro
    Enseignant
    Inscrit en
    Avril 2005
    Messages
    1 644
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 58
    Localisation : France, Charente Maritime (Poitou Charente)

    Informations professionnelles :
    Activité : Enseignant
    Secteur : Enseignement

    Informations forums :
    Inscription : Avril 2005
    Messages : 1 644
    Points : 1 975
    Points
    1 975
    Par défaut
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
     
    constructor TShapeBoxRu.Create(AOwner : TComponent;hote:Twincontrol));
    begin
    begin
    inherited create(aowner);
    parent:=hote;
    fCheckBox := TCheckBox.Create(Self);
    fCheckBox.parent:=self;
    end;
    non ?

    avec déclaration
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    constructor create(aowner:Tcomponent;hote:Twincontrol);reintroduce;overload;

  7. #7
    Membre éprouvé Avatar de BuzzLeclaire
    Homme Profil pro
    Dev/For/Vte/Ass
    Inscrit en
    Août 2008
    Messages
    1 606
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Dev/For/Vte/Ass

    Informations forums :
    Inscription : Août 2008
    Messages : 1 606
    Points : 1 113
    Points
    1 113
    Par défaut
    Citation Envoyé par Cl@udius Voir le message
    Salut
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
     fCheckBox := fCheckBox.Create(Self);


    Code : Sélectionner tout - Visualiser dans une fenêtre à part
     fCheckBox := TCheckBox.Create(Self);
    @+
    Pfff quel idiot.. merci.

    Donc là je peux poser mon compo sur une form. Mais je ne vois pas le CheckBox.

    Que me reste-t-il à faire ?

    Et quellle sont les choses que j'oublis ?

    Merci

  8. #8
    Membre éprouvé Avatar de BuzzLeclaire
    Homme Profil pro
    Dev/For/Vte/Ass
    Inscrit en
    Août 2008
    Messages
    1 606
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Dev/For/Vte/Ass

    Informations forums :
    Inscription : Août 2008
    Messages : 1 606
    Points : 1 113
    Points
    1 113
    Par défaut
    Citation Envoyé par Archimède Voir le message
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
     
    constructor TShapeBoxRu.Create(AOwner : TComponent;hote:Twincontrol));
    begin
    begin
    inherited create(aowner);
    parent:=hote;
    fCheckBox := TCheckBox.Create(Self);
    fCheckBox.parent:=self;
    end;
    non ?
    A priori je n'ai pas besoin de parent.

    J'ai tout de même ajouter ta proposition (en corrigeant Self par hote) et le probleme c'est que 1 le create n'ai plus override ce qui peut-etre fais qu'ensuite cela ne fonctionne pas du tout en conception, la prorpiété CheckBox est bien présent mais rien d'autre.

    Donc j'ai remis comme cela

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    constructor TShapeBoxRu.Create(AOwner : TComponent);
    begin
      inherited Create(AOwner);
      fCheckBox := TCheckBox.Create(Self);
    end;
    Mais en conception, déjà le nom du compo (pas le name) est ShapeBoxRu1.
    J'ai bien toutes les fonctions du CheckBox accessible (dans l'inspecteur d'objet) mais toujours invisible, même si je n'execute pas le Paint du ShapeBoxRu.

  9. #9
    Membre chevronné
    Avatar de Archimède
    Homme Profil pro
    Enseignant
    Inscrit en
    Avril 2005
    Messages
    1 644
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 58
    Localisation : France, Charente Maritime (Poitou Charente)

    Informations professionnelles :
    Activité : Enseignant
    Secteur : Enseignement

    Informations forums :
    Inscription : Avril 2005
    Messages : 1 644
    Points : 1 975
    Points
    1 975
    Par défaut
    Regarde la modif déjà... il faut réintroduire le constructor create...

  10. #10
    Membre éprouvé Avatar de BuzzLeclaire
    Homme Profil pro
    Dev/For/Vte/Ass
    Inscrit en
    Août 2008
    Messages
    1 606
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Dev/For/Vte/Ass

    Informations forums :
    Inscription : Août 2008
    Messages : 1 606
    Points : 1 113
    Points
    1 113
    Par défaut
    Citation Envoyé par Archimède Voir le message
    Regarde la modif déjà... il faut réintroduire le constructor create...
    Je suis désolé mais je ne comprends pas ce que tu veux dire ? je rèpete que je suis pas un pro des compos alors un qui integre un compo dans un compo imagine...

    Pourrais-tu être plus explicite ?

  11. #11
    Membre éprouvé Avatar de BuzzLeclaire
    Homme Profil pro
    Dev/For/Vte/Ass
    Inscrit en
    Août 2008
    Messages
    1 606
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Dev/For/Vte/Ass

    Informations forums :
    Inscription : Août 2008
    Messages : 1 606
    Points : 1 113
    Points
    1 113
    Par défaut
    Ok,

    Tu as modifié ton potes entre temps et j'avais pas vue

    Je teste.

  12. #12
    Membre éprouvé Avatar de BuzzLeclaire
    Homme Profil pro
    Dev/For/Vte/Ass
    Inscrit en
    Août 2008
    Messages
    1 606
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Dev/For/Vte/Ass

    Informations forums :
    Inscription : Août 2008
    Messages : 1 606
    Points : 1 113
    Points
    1 113
    Par défaut
    Bon,

    Cela compile, mais avec un parent dans l'isnpecteur d'objet je peux apparement mettre un checkbox au lieu dans avoir un par defaut.
    Et si j'affecte un checkbox (que j'ai poser sur ma form) j'ai un message d'erreur.

    De plus avec un parent je n'ai pas les propriété du check box

  13. #13
    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
    Le TShape n'héritant pas de TWinControl (mais de TGraphicControl) tu n'as pas choisi la meilleure solution pour y intégrer un TChechBox.

    En deux mots, quelle est la finalité de ce composant ? Un Checkbox posé sur un fond dégradé ?
    Pourquoi ne pas te baser sur un TPanel par exemple ?

    @+

  14. #14
    Modérateur
    Avatar de Rayek
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Mars 2005
    Messages
    5 235
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 50
    Localisation : France, Haute Savoie (Rhône Alpes)

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Mars 2005
    Messages : 5 235
    Points : 8 504
    Points
    8 504
    Par défaut
    Après la construction de ton compo rajoute

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    fCheckBox.Visible := True;
    Si je me souviens bien, quand tu créés dynamiquement des composants, il faut toujours les rendre visible.
    Modérateur Delphi

    Le guide du bon forumeur :
    __________
    Rayek World : Youtube Facebook

  15. #15
    Membre éprouvé Avatar de BuzzLeclaire
    Homme Profil pro
    Dev/For/Vte/Ass
    Inscrit en
    Août 2008
    Messages
    1 606
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Dev/For/Vte/Ass

    Informations forums :
    Inscription : Août 2008
    Messages : 1 606
    Points : 1 113
    Points
    1 113
    Par défaut
    Citation Envoyé par Cl@udius Voir le message
    Le TShape n'héritant pas de TWinControl (mais de TGraphicControl) tu n'as pas choisi la meilleure solution pour y intégrer un TChechBox.

    En deux mots, quelle est la finalité de ce composant ? Un Checkbox posé sur un fond dégradé ?
    Pourquoi ne pas te baser sur un TPanel par exemple ?

    @+
    Tu as raison, et à un moment je me suis poser la question... de prendre un Tpanel. En fais comme j'avais deja fais un composant perso Shape je me suis dis...

    Bref.

    Je vais essayer un TPanel.

    Juste un truc je mets

    Type

    TpanelBoxRu := class(TCustompanel)

  16. #16
    Membre éprouvé Avatar de BuzzLeclaire
    Homme Profil pro
    Dev/For/Vte/Ass
    Inscrit en
    Août 2008
    Messages
    1 606
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Dev/For/Vte/Ass

    Informations forums :
    Inscription : Août 2008
    Messages : 1 606
    Points : 1 113
    Points
    1 113
    Par défaut
    Alors

    @ Rayek, meme avec cela (visible := True) je ne vois pas le check box que se soit avec un parent @Archimède ou sans

    @ Claudius, je viens de le transformer en TPanel, mais je ne vois toujours pas mon checkbox lorsque je pose ce composant sur une fiche.

    merci.

    PS : j'oubliais avec ou sans procédure Degrader activé

  17. #17
    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
    Oui tu peux hériter de TCustomPanel et ensuite choisir les propriétés que tu veux publier.

    Au fait que viens faire un:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    TStringGridRu(Parent).CheckInBounds;
    dans le MouseWheel ?

    D'où ma question sur la finalité de ton composant.

    @+

  18. #18
    Membre éprouvé Avatar de BuzzLeclaire
    Homme Profil pro
    Dev/For/Vte/Ass
    Inscrit en
    Août 2008
    Messages
    1 606
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Dev/For/Vte/Ass

    Informations forums :
    Inscription : Août 2008
    Messages : 1 606
    Points : 1 113
    Points
    1 113
    Par défaut
    @ claudius,

    Pour expliquer.

    Mon composant je l'utilise en création dynamique, de plus le parent du ShapeRu ou futur Shape/panelBoxRu sera enfant d'un autre composant le StringGridRu (identique à un StringGrid avec des fonctions de bounds () replace le controls correctement) de ces controls d'où CheckInbounds)

    Cette procedure MouseWheel de l'enfant donc de StringGridRu je suis obligé de la mettre car quand tu scroll et que ta souris est sur l'enfant (ShapeRu ou etc.) du stringgrid, je perds la position du composant sans cette procédure.


    voilà.

  19. #19
    Modérateur
    Avatar de Rayek
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Mars 2005
    Messages
    5 235
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 50
    Localisation : France, Haute Savoie (Rhône Alpes)

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Mars 2005
    Messages : 5 235
    Points : 8 504
    Points
    8 504
    Par défaut
    et en jouant avec le Top et Left (les initialiser correctement) car on sait jamais, ils sont peut être hors du composant
    Modérateur Delphi

    Le guide du bon forumeur :
    __________
    Rayek World : Youtube Facebook

  20. #20
    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
    Le constructeur du compo devrait au moins posséder ceci:

    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
    constructor TPanelBoxRu.Create(AOwner: TComponent);
    begin
      inherited Create(AOwner);
      Parent := AOwner as TWinControl;
      FStartColor := clSkyBlue;  // Default de la property
      FEndColor := clWhite;      // Default de la property
     
      FCheckBox := TCheckBox.Create(Self);
      with FCheckBox do
      begin
        Parent := Self;
        Caption := 'Inner Checkbox'; // A traiter différemment
        Left := 5; // A traiter différemment
        Top := 5; // A traiter différemment
      end;
    end;

+ Répondre à la discussion
Cette discussion est résolue.
Page 1 sur 3 123 DernièreDernière

Discussions similaires

  1. Differentes Checkbox? Checkbox qui se modifient?
    Par kataiyai dans le forum Balisage (X)HTML et validation W3C
    Réponses: 1
    Dernier message: 10/01/2012, 09h42
  2. [MySQL] utilisation d'un checkbox pour supprimé modifier ou autre action
    Par Whinespirit dans le forum PHP & Base de données
    Réponses: 5
    Dernier message: 05/06/2010, 23h36
  3. Savoir si une checkbox a été modifier
    Par MooGle dans le forum Struts 1
    Réponses: 5
    Dernier message: 25/05/2007, 16h33
  4. Modifier les checkbox
    Par HwRZxLc4 dans le forum Mise en page CSS
    Réponses: 3
    Dernier message: 25/11/2006, 18h12
  5. Réponses: 14
    Dernier message: 24/10/2006, 06h51

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