I wrote a C++ program using Borland C++ Builder 5.  The program dynamically creates an array of TCheckBox objects.  I have tried to write an OnClick event handler that would identify which checkbox is being clicked and execute some instructions based on that.  My event handler is based on similar posts to this website, but I cannot seem to make it work.
Here is the (abbreviated) code
// Header declaration
void __fastcall CBoxClick(TObject *Sender); 
// End Header
// CBoxClick function (the event handler)
void __fastcall CBoxClick(TObject *Sender){
    if (dynamic_cast<TCheckBox*>(Sender)!=NULL){
        //Do stuff
    }
    else{
        Form1 -> Debug -> Text = "Object is not a TCheckBox";         
    }
}
void ChkBoxInit(void){
    int i;                                            //Loop counter index
    TCheckBox* ChkBx[NCARDS];                         //Define array of type checkboxes
    for(i = 0; i < NCARDS; i++){                      //Initalize each checkbox
        ChkBx[i] = new TCheckBox(Form1);              //Create a new checkbox
        ChkBx[i] -> Parent = Form1;                   //Define parent of checkbox
        ChkBx[i] -> Tag = i;                          //Set value of Tag to index
        //  Other CheckBox parameters here such as Height, Width, Top, Left, Name are here
        //  Next, call event handler. I've tried the following 2 statements with the comment results
        ChkBx[i] -> OnClick = CBoxClick(ChkBx[i]);    //  Results in E2109: Not an allowed type
        ChkBx[i] -> OnClick = CBoxClick;              /* Alternate try - Results in E2034: Cannot convert
                                                        'void (_fastcall *)(TObject *)' to 
                                                        'void (_fastcall * (_closure )(TObject *))(TObject *)'  */
    }                                                 //End of for loop
}                                                     //End of function
– Doug Aug 29 '18 at 17:18