Aquí si le veo sentido:
Código:
const char* wrongKey = "|°¬!\"#$%&/()='?\\¿¡@´¨+*~{[^}]`<>,;.:-";
//---------------------------------------------------------------------------
// Limpiar Edit ingreso de nombre
void __fastcall TForm1::FormCreate(TObject *Sender)
{
Edit1->Clear();
Edit2->Clear();
Edit3->Clear();
}
//---------------------------------------------------------------------------
// Verificar en escritura
void VerifyKey(TObject *Sender, char &Key)
{
TEdit *ed = static_cast<TEdit*>(Sender);
if((ed->SelStart+ed->SelLength == 0 && isdigit(Key)) ||
StrPos(wrongKey, String(Key).c_str()) != NULL)
Key=0;
}
//---------------------------------------------------------------------------
// Verificar por copiado/pegado
void VerifyOnPaste(TObject *Sender)
{
TEdit *ed = static_cast<TEdit*>(Sender);
for(int i = 1; i <= ed->Text.Length();i++)
if (StrPos(wrongKey, ed->Text.c_str()+i) != NULL || isdigit(ed->Text[1])) {
MessageBox(Application->Handle,AnsiString("Una cadena no válida fue pegada en " + ed->Name + ".\nRevísela antes de continuar.").c_str(),"Atención",MB_OK | MB_ICONERROR);
ed->SetFocus();
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Edit1KeyPress(TObject *Sender, char &Key)
{
VerifyKey(Sender,Key);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Edit2KeyPress(TObject *Sender, char &Key)
{
VerifyKey(Sender,Key);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Edit3KeyPress(TObject *Sender, char &Key)
{
VerifyKey(Sender,Key);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Edit1Exit(TObject *Sender)
{
VerifyOnPaste(Sender);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Edit2Exit(TObject *Sender)
{
VerifyOnPaste(Sender);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Edit3Exit(TObject *Sender)
{
VerifyOnPaste(Sender);
}
//---------------------------------------------------------------------------
Ya que si son muchos TEdits nos ahorramos codigo y es mas facil entenderlo. ¿que opinas?