Ver Mensaje Individual
  #7  
Antiguo 22-09-2011
Avatar de escafandra
[escafandra] escafandra is offline
Miembro Premium
 
Registrado: nov 2007
Posts: 2.197
Reputación: 20
escafandra Tiene un aura espectacularescafandra Tiene un aura espectacular
Quisiera hacer un comentario al último código de ecfisa.

Declaras un puntero a TMsg, ese puntero no apunta a nada válido, no está inicializado. Antes o después dará lugar a un error difícil de depurar. Las prisas...

Tu código está mejor así:
Código:
void __fastcall TForm1::FormKeyDown(TObject *Sender, WORD &Key,
      TShiftState Shift)
{
   TMsg Msg;
   if(Key == VK_RETURN){
     PeekMessage(&Msg, 0, WM_CHAR, WM_CHAR,PM_REMOVE);
     SelectNext(ActiveControl, true, true);
   }
}
O así:
Código:
void __fastcall TForm1::FormKeyDown(TObject *Sender, WORD &Key,
      TShiftState Shift)
{
   if(Key == VK_RETURN){
     PeekMessage(0, 0, WM_CHAR, WM_CHAR,PM_REMOVE);
     SelectNext(ActiveControl, true, true);
   }
}
Aunque lo que apuntó newtron se entiende mejor y tiene una traducción casi literal:
Código:
void __fastcall TForm1::FormKeyDown(TObject *Sender, WORD &Key,
      TShiftState Shift)
{
   if(Key == VK_RETURN){
     Key = 0;
     SelectNext(ActiveControl, true, true);
   }
}
Las dos opciones son perfectamente válidas

Saludos.

Última edición por escafandra fecha: 22-09-2011 a las 20:08:35.
Responder Con Cita