Hola a todos.
Hay una forma mas eficiente de controlar el enter en una aplicacion, yo la que utilizo desde hace años es esta.
Crear esta función (AppMessage) en el formulario principal.
Código Delphi
[-]
procedure TMain.AppMessage(var Msg: TMsg; var Handled: Boolean);
var
actual: TWinControl;
begin
if Msg.message = WM_KEYDOWN then
begin
if Screen.ActiveControl.Tag = 77 then Exit;
case Msg.wParam of
VK_ADD: ; VK_F12: ; VK_RETURN:
begin
actual := Screen.ActiveControl;
if actual is TEdit then Msg.wParam := VK_TAB;
if actual is TJvValidateEdit then Msg.wParam := VK_TAB;
if actual is TDBEdit then Msg.wParam := VK_TAB;
if actual is TjvDateEdit then
if not TjvDateEdit(actual).PopupVisible then Msg.wParam := VK_TAB;
if actual is TjvDBDateEdit then
if not TjvDBDateEdit(actual).PopupVisible then Msg.wParam := VK_TAB;
if actual is TDateTimePicker then Msg.wParam := VK_TAB;
if actual is TDBLookupComboBox then
if not TDBLookupComboBox(actual).ListVisible then Msg.wParam := VK_TAB;
if actual is TjvDBLookupCombo then
if not TjvDBLookupCombo(actual).ListVisible then Msg.wParam := VK_TAB;
if actual is TStringGrid then Msg.wParam := VK_TAB;
END;
end;
end;
end;
y en el create del formulario poner esto
Código Delphi
[-]
Application.OnMessage := AppMessage;
Con esto tendrás toda la aplicación controlados los enter, pero solo de los tipos de controles que ayas declarado y si algún control no quieres que trasforme los enter por tad y esta declarado su tipo le pones el tag a 77 y listo.
Funciona de maravilla y ademas te da un fuerte control de cualquier tecla que se pulse.
Saludos.