Tema: Enter a tabs
Ver Mensaje Individual
  #9  
Antiguo 22-03-2010
Avatar de Softweb
Softweb Softweb is offline
Miembro
 
Registrado: ago 2008
Posts: 46
Reputación: 0
Softweb Va por buen camino
Thumbs up

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.

Última edición por Softweb fecha: 22-03-2010 a las 16:57:21.
Responder Con Cita