65 lines
1.8 KiB
C++
65 lines
1.8 KiB
C++
//---------------------------------------------------------------------------
|
|
#include <vcl\vcl.h>
|
|
#pragma hdrstop
|
|
|
|
#include "actbtn.h"
|
|
//---------------------------------------------------------------------------
|
|
static inline TActiveButton *ValidCtrCheck()
|
|
{
|
|
return new TActiveButton(NULL);
|
|
}
|
|
//---------------------------------------------------------------------------
|
|
__fastcall TActiveButton::TActiveButton(TComponent* Owner)
|
|
: TBitBtn(Owner)
|
|
{
|
|
captured = false;
|
|
Glyph1 = new Graphics::TBitmap;
|
|
FGlyph2 = new Graphics::TBitmap;
|
|
}
|
|
//---------------------------------------------------------------------------
|
|
__fastcall TActiveButton::~TActiveButton()
|
|
{
|
|
delete Glyph1;
|
|
delete FGlyph2;
|
|
}
|
|
//---------------------------------------------------------------------------
|
|
void __fastcall TActiveButton::MouseMove( Classes::TShiftState Shift, int X, int Y)
|
|
{
|
|
if( !captured){
|
|
SetCapture( Handle);
|
|
captured = true;
|
|
Glyph1->Assign( Glyph); // save old glyph
|
|
Glyph = Glyph2; // show new glyph
|
|
}
|
|
if( (X<0) || (Y<0) || (X>Width) || (Y>Height)){
|
|
ReleaseCapture();
|
|
captured = false;
|
|
Glyph = Glyph1; // restore old glyph
|
|
}else{
|
|
TBitBtn::MouseMove( Shift, X, Y);
|
|
}
|
|
}
|
|
//---------------------------------------------------------------------------
|
|
void __fastcall TActiveButton::Click( void)
|
|
{
|
|
TBitBtn::Click();
|
|
ReleaseCapture();
|
|
captured = false;
|
|
Glyph = Glyph1;
|
|
}
|
|
//---------------------------------------------------------------------------
|
|
void __fastcall TActiveButton::SetGlyph2( Graphics::TBitmap *val)
|
|
{
|
|
Glyph2->Assign( val);
|
|
}
|
|
//---------------------------------------------------------------------------
|
|
namespace Actbtn
|
|
{
|
|
void __fastcall Register()
|
|
{
|
|
TComponentClass classes[1] = {__classid(TActiveButton)};
|
|
RegisterComponents("Extras", classes, 0);
|
|
}
|
|
}
|
|
//---------------------------------------------------------------------------
|