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 );
} |
Partager