[Home]
[Edit this page]
[Recent Changes]
[Special Pages]
[Help]
CppVclEvent
Like any pointer-to-function, you can change it at run-time, like the example code below:
[Edit this page] [Page history] [What links here] [Discuss this topic] [Printer Friendly]
CppVclEvent
(C++ VCL) Event
'Something that can happen to a Control'.Changing an Event at run-time
An OnClick Event is a pointer to a function (sometimes called a callback function), of type 'void __fastcall (TForm1::*)(TObject * Sender)'.Like any pointer-to-function, you can change it at run-time, like the example code below:
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
Button1->OnClick = ClickOne;
Button1->Click();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Timer1Timer(TObject *Sender)
{
++Timer1->Tag;
if (Timer1->Tag % 2 ==0 )
{
Button1->OnClick = ClickOne;
}
else
{
Button1->OnClick = ClickTwo;
}
Button1->Click();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::ClickOne(TObject *Sender)
{
Button1->Caption = "One";
}
//---------------------------------------------------------------------------
void __fastcall TForm1::ClickTwo(TObject *Sender)
{
Button1->Caption = "Two";
}
//---------------------------------------------------------------------------
'Event' links
- C++ Builder
- ?C++ CLX
Code links
[Edit this page] [Page history] [What links here] [Discuss this topic] [Printer Friendly]
