TValueListEditor * problem


2003-11-30 11:30:12 PM
cppbuilder101
Hi all,
The following code works fine:
//---------------------------------------------------------------------------
void __fastcall TForm1::VLEStatusCodeMessagesStringsChange(TObject
*Sender)
{
if((VLEStatusCodeMessages->Cells[VLEStatusCodeMessages->Col][VLEStatusCodeMessages->Row]).Length()
Quote
30)
{
String itstr = VLEStatusCodeMessages->Cells[VLEStatusCodeMessages->Col][VLEStatusCodeMessages->Row];
itstr.SetLength(30);
VLEStatusCodeMessages->Cells[VLEStatusCodeMessages->Col][VLEStatusCodeMessages->Row]
= itstr;
Beep();
VLEStatusCodeMessages->Refresh();
}
}
//---------------------------------------------------------------------------
But changing it to use a pointer causes a problem an AV. Any ideas?
//---------------------------------------------------------------------------
void __fastcall TForm1::VLEStatusCodeMessagesStringsChange(TObject
*Sender)
{
TValueListEditor * VLEptr = dynamic_cast<TValueListEditor
*>(Sender);
if((VLEptr->Cells[VLEptr->Col][VLEptr->Row]).Length()>30)
{
String itstr = VLEptr->Cells[VLEptr->Col][VLEptr->Row];
itstr.SetLength(30);
VLEptr->Cells[VLEptr->Col][VLEptr->Row] = itstr;
Beep();
VLEptr->Refresh();
}
}
TIA
Terrence