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
| //---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "MyPanel.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(TMyPanel *)
{
new TMyPanel(NULL);
}
//---------------------------------------------------------------------------
__fastcall TMyPanel::TMyPanel(TComponent* Owner)
: TCustomPanel(Owner)
{
}
bool __fastcall TMyPanel::GetEnabled(void)
{
return TCustomPanel::Enabled;
}
void __fastcall TMyPanel::SetEnabled(bool enabled)
{
if (enabled)
Caption = "Enabled";
else
Caption = "Disabled";
for (int i=0; i<ControlCount; i++)
{
TButton* pBouton = dynamic_cast<TButton*>(Controls[i]);
if (pBouton != NULL)
{
pBouton->Enabled = enabled;
pBouton->Caption = enabled ? "Bouton Enabled" : "Bouton Disabled";
}
}
TCustomPanel::SetEnabled(enabled);
}
//---------------------------------------------------------------------------
namespace Mypanel
{
void __fastcall PACKAGE Register()
{
TComponentClass classes[1] = {__classid(TMyPanel)};
RegisterComponents(L"Samples", classes, 0);
}
}
//--------------------------------------------------------------------------- |
Partager