Ver Mensaje Individual
  #5  
Antiguo 29-02-2008
[FGarcia] FGarcia is offline
Miembro Premium
 
Registrado: sep 2005
Ubicación: Cordoba, Veracruz, México
Posts: 1.123
Reputación: 20
FGarcia Va por buen camino
Bueno realize esto, en un DataModule que es donde tengo el acceso a mi BD declare una variable global llamada NumRegistro y en el evento DataChange del DataSet le asigne valor a esta variable.

Código Delphi [-]
var
  CnxDatos: TCnxDatos;
  RutaAPP, RutaDBDatos: string;
  NumRegistro: integer;
 
{CUANDO EL CURSOR CAMBIA A OTRO DATO }
procedure TCnxDatos.DSTablaDataChange(Sender: TObject; Field: TField);
begin
  NumRegistro := ADOTabla1.RecNo;
end;

y en el formulario principal de la aplicacion en el ApllicationEvents:

Código Delphi [-]
{Este procedimiento hace que la rueda del raton funcione correctamente con los
DBgrid, ListBox y demas compònentes similares. Es un truco de Delphi.about.com}
procedure TfrmPrincipal.ApplicationEvents1Message(var Msg: tagMSG;
  var Handled: Boolean);
var
   i: SmallInt;
begin
   case Msg.message of
      {SI EL MENSAJE ES LA RUEDA DEL RATON}
      WM_MOUSEWHEEL: begin
                      Msg.message := WM_KEYDOWN;
                      Msg.lParam := 0;
                      i := HiWord(Msg.wParam) ;
                        if i > 0 then
                          Msg.wParam := VK_UP
                        else
                          Msg.wParam := VK_DOWN;
                        Handled := False;
                        {ESTO ES AÑADIDO}
                        if PageControl1.ActivePage = TabSheet1 then
                          NumRegistroActual;
                     end;
      {SI EL MENSAJE ES EL BOTON DE FLECHA ARRIBA O ABAJO}
      WM_KEYDOWN,WM_KEYUP: NumRegistroActual;
    end;
end;
 
procedure TfrmPrincipal.PageControl1Change(Sender: TObject);
begin
  if PageControl1.ActivePageIndex = 1 then
    begin
      Label1.Caption := IntToStr(CnxDatos.ADOTabla1.RecNo );
      Label2.Caption := IntToStr(CnxDatos.ADOTabla1.RecordCount);
    end;
end;
 
procedure TfrmPrincipal.DBGrid1CellClick(Column: TColumn);
begin
  NumRegistroActual;
end;
 
{Este procedimiento es el que actualiza el valor del Label}
procedure TfrmPrincipal.NumRegistroActual ;
begin
  Label1.Caption := IntToStr(NumRegistro);
end;
 
procedure TfrmPrincipal.DBNavigator1Click(Sender: TObject;
  Button: TNavigateBtn);
begin
  case Button of
    nbFirst,nbPrior,nbNext,nbLast: NumRegistroActual;
  end;
end;

De esta manera me esta funcionando, solo existe un problema cuando avanzo con la rueda del raton y es que el numero de registro siempres es uno menos; por ejemplo estoy en el 38 y el valor en la etiqueta es 37 .

Como siempre se siguen aceptando sugerencias. Gracias.
Responder Con Cita