Paint d'un composant en boucle ?
Re-bonjour,
je travail toujours sur le même composant. Je surcharge la fonction Paint...lorsque j'ajoute ce composant à une fiche je le vois qui "clignote" (redessin en permanence). Et pas moyen de modifier les TPicture (plantage).
Voila mon code :
Code:
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
|
__fastcall TImageButton::TImageButton(TComponent* Owner)
: TImage(Owner)
{
down = false;
picture_down = new TPicture();
if ( picture_down == NULL )
{
MessageDlg("Erreur : impossible de créer le TPicture pour PictureDown.",
mtError, TMsgDlgButtons() << mbOK, 0 );
Free();
}
}
//---------------------------------------------------------------------------
__fastcall TImageButton::~TImageButton( void )
{
// TImage::~TImage();
delete picture_down;
}
//---------------------------------------------------------------------------
void __fastcall TImageButton::SetPictureDown ( TPicture *value )
{
picture_down->Assign( value );
if ( down )
this->Invalidate();
}
//---------------------------------------------------------------------------
void __fastcall TImageButton::MouseDown ( System::TObject* Sender,
TMouseButton Button, Classes::TShiftState Shift, int X, int Y )
{
TImage::OnMouseDown( Sender, Button , Shift, X, Y );
this->down = true;
this->Invalidate();
}
//---------------------------------------------------------------------------
void __fastcall TImageButton::Paint( void )
{
if ( down )
this->Canvas->Draw( 0, 0, this->picture_down->Graphic );
else
this->Canvas->Draw( 0, 0, this->Picture->Graphic );
} |
et le .h :
Code:
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
|
class PACKAGE TImageButton : public TImage
{
private:
// Propriétés
TPicture *picture_down;
// Autres variables
bool down;
// Fonctions
void __fastcall SetPictureDown ( TPicture *value );
protected:
virtual void __fastcall Paint ( void );
virtual void __fastcall MouseDown ( System::TObject* Sender,
TMouseButton Button, Classes::TShiftState Shift, int X, int Y );
public:
__fastcall TImageButton(TComponent* Owner);
__fastcall ~TImageButton( void );
__published:
__property OnMouseDown;
__property Picture;
__property TPicture* PictureDown = {read = picture_down, write = SetPictureDown };
__property bool Down = { read = down, write = down }; |
Merci d'avance pour votre aide !