OnClick динамического объекта не видит себя-же
Код:
//--------------H-file----------------
class Integrate
{
private:
TComponent* Owner;
public:
Integrate(TComponent *Owner);
~Integrate();
TStringGrid *sgIntgr;
void SetParent(TWinControl* Parent);
void sgIntgrClick(TObject *Sender);
};
//-------------CPP-file---------------
Integrate::Integrate(TComponent *Owner)
{
this->Owner = Owner;
sgIntgr = new TStringGrid(this->Owner);
sgIntgr->Name = "TEST";
sgIntgr->OnClick = TNotifyEvent(&sgIntgrClick);
}
//---------------------------------------------------------------------------
Integrate::~Integrate()
{
delete sgIntgr;
}
//---------------------------------------------------------------------------
void Integrate::SetParent(TWinControl* Parent)
{
this->sgIntgr->Parent = Parent;
}
//---------------------------------------------------------------------------
void Integrate::sgIntgrClick(TObject *Sender)
{
try {
ShowMessage(this->sgIntgr->Name);
} catch (...) {
}
}
class Integrate
{
private:
TComponent* Owner;
public:
Integrate(TComponent *Owner);
~Integrate();
TStringGrid *sgIntgr;
void SetParent(TWinControl* Parent);
void sgIntgrClick(TObject *Sender);
};
//-------------CPP-file---------------
Integrate::Integrate(TComponent *Owner)
{
this->Owner = Owner;
sgIntgr = new TStringGrid(this->Owner);
sgIntgr->Name = "TEST";
sgIntgr->OnClick = TNotifyEvent(&sgIntgrClick);
}
//---------------------------------------------------------------------------
Integrate::~Integrate()
{
delete sgIntgr;
}
//---------------------------------------------------------------------------
void Integrate::SetParent(TWinControl* Parent)
{
this->sgIntgr->Parent = Parent;
}
//---------------------------------------------------------------------------
void Integrate::sgIntgrClick(TObject *Sender)
{
try {
ShowMessage(this->sgIntgr->Name);
} catch (...) {
}
}
Код:
//--------------H-file----------------
class TForm1 : public TForm
{
__published: // IDE-managed Components
void __fastcall FormShow(TObject *Sender);
private: // User declarations
Integrate *intgr;
public: // User declarations
__fastcall TForm1(TComponent* Owner);
__fastcall ~TForm1();
};
//-------------CPP-file---------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
intgr = new Integrate(this);
}
//---------------------------------------------------------------------------
__fastcall TForm1::~TForm1()
{
delete intgr;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormShow(TObject *Sender)
{
intgr->SetParent(this);
ShowMessage(intgr->sgIntgr->Name);
}
//---------------------------------------------------------------------------
class TForm1 : public TForm
{
__published: // IDE-managed Components
void __fastcall FormShow(TObject *Sender);
private: // User declarations
Integrate *intgr;
public: // User declarations
__fastcall TForm1(TComponent* Owner);
__fastcall ~TForm1();
};
//-------------CPP-file---------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
intgr = new Integrate(this);
}
//---------------------------------------------------------------------------
__fastcall TForm1::~TForm1()
{
delete intgr;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormShow(TObject *Sender)
{
intgr->SetParent(this);
ShowMessage(intgr->sgIntgr->Name);
}
//---------------------------------------------------------------------------
Обработчик-же sgIntgrClick при щелчке - StringGrid'а не видит как будто бы его не существует!
Никак не могу понять в чем дело
Решение найдено