Ver Mensaje Individual
  #9  
Antiguo 28-03-2012
marcial marcial is offline
Miembro
 
Registrado: may 2003
Posts: 147
Reputación: 21
marcial Va por buen camino
De hecho, y gracias a tu inestimable ayuda he mezclado tus códigos y he añadido algo hasta que ha quedado a mi gusto.
Reitero nuevamente mi agradecimiento porque sólo no podría haberlo hecho.

Código Delphi [-]
procedure TForm1.MMouseEvent(var Msg: TMsg; var Handled: Boolean);
{$J+}
const InZD: Boolean = False;
{$J-}
var
  P, PP: TPoint;
  WControl: TWinControl;
  G: TDBGrid;
  ZD, i: Integer;
begin
  WControl:= FindVCLWindow(Mouse.CursorPos);  // ¿ Esta sobre un TWinControl ?
  if Assigned(WControl) and (WControl is TDBGrid) then // ¿ Es tambien un TDBGrid ?
  begin
    P:= ScreenToClient(Mouse.CursorPos);  // Obtener posición del mouse
    G:= TDBGRid(WControl);
    ZD:=  GetSystemMetrics(SM_CXVSCROLL);  // Ancho zona desplazamiento
    if (P.X < G.Left + ZD) and not InZD then  // Ingresa zona desplazamiento izquierda
         for i:= G.Columns.Count-1 downto G.SelectedIndex do
                begin
                PP := ScreenToClient(Mouse.CursorPos);
                if pp.x <> p.x then exit;
                SendMessage(G.Handle, WM_HSCROLL, SB_LINELEFT, 0);
                sleep(100);
                end;
    if (P.X > G.Left + G.Width - ZD) and not InZD then  // Ingresa zona desplazamiento derecha
      for i:= G.SelectedIndex to G.Columns.Count-1 do  //Así no hay que ingresar en la zona de desplazamiento columna a columna
                begin
                PP := ScreenToClient(Mouse.CursorPos); 
                if pp.x <> p.x then exit;  //Chequea que la posición haya cambiado con respecto de la inicial para salir del buche

                SendMessage(G.Handle, WM_HSCROLL, SB_LINERIGHT, 0);
                sleep(100);  // Una pequeña pausa a gusto del consumidor para que el scroll no sea tan rápido
                end;
    InZD:= (P.X < G.Left + ZD) or (P.X > G.Left + G.Width - ZD); // ¿ En zona desplazamiento ?

  end;
end;
Responder Con Cita