Ver Mensaje Individual
  #4  
Antiguo 21-07-2010
Avatar de ecfisa
ecfisa ecfisa is offline
Moderador
 
Registrado: dic 2005
Ubicación: Tres Arroyos, Argentina
Posts: 10.508
Reputación: 36
ecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to behold
Hola Kandorf.

Lo hubiqué así y no da error:
Código Delphi [-]
unit Unit1;
interface
uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;
type
{$IFDEF WIN32}
  WParameter = LongInt;
{$ELSE}
  WParameter = Word;
{$ENDIF}
  LParameter = LongInt;
  TForm1 = class(TForm)
    ScrollBox1: TScrollBox;
    procedure FormCreate(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;
var
  Form1: TForm1;
 OldWindowProc : Pointer;
implementation
{$R *.dfm}
function NewWindowProc(WindowHandle : hWnd;
                        TheMessage   : WParameter;
                        ParamW       : WParameter;
                        ParamL       : LParameter) : LongInt
                        {$IFDEF WIN32} stdcall;
                        {$ELSE} ; export; {$ENDIF}
var
  TheRangeMin : integer;
  TheRangeMax : integer;
  TheRange : integer;
begin
  if TheMessage = WM_VSCROLL then
  begin
    {Get the min and max range of the horizontal scroll box}
    GetScrollRange(WindowHandle,
                   SB_HORZ,
                   TheRangeMin,
                   TheRangeMax);
    {Get the vertical scroll box position}
    TheRange := GetScrollPos(WindowHandle,
                             SB_VERT);
    {Make sure we wont exceed the range}
    if TheRange < TheRangeMin then
      TheRange := TheRangeMin else
    if TheRange > TheRangeMax then
      TheRange := TheRangeMax;
    {Set the horizontal scroll bar}
    SetScrollPos(WindowHandle,
                 SB_HORZ,
                 TheRange,
                 true);
  end;
  if TheMessage = WM_HSCROLL then begin
  {Get the min and max range of the horizontal scroll box}
    GetScrollRange(WindowHandle,
                   SB_VERT,
                   TheRangeMin,
                   TheRangeMax);
  {Get the horizontal scroll box position}
    TheRange := GetScrollPos(WindowHandle,
                             SB_HORZ);
  {Make sure we wont exceed the range}
    if TheRange < TheRangeMin then
      TheRange := TheRangeMin else
    if TheRange > TheRangeMax then
      TheRange := TheRangeMax;
  {Set the vertical scroll bar}
    SetScrollPos(WindowHandle,
                 SB_VERT,
                 TheRange,
                 true);
  end;
  { Call the old Window procedure to }
  { allow processing of the message. }
  NewWindowProc := CallWindowProc(OldWindowProc,
                                  WindowHandle,
                                  TheMessage,
                                  ParamW,
                                  ParamL);
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
{ Set the new window procedure for the control }
{ and remember the old window procedure.       }
  OldWindowProc := Pointer(SetWindowLong(ScrollBox1.Handle,
                                         GWL_WNDPROC,
                                         LongInt(@NewWindowProc)));
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
{ Set the window procedure back }
{ to the old window procedure.  }
  SetWindowLong(ScrollBox1.Handle,
                GWL_WNDPROC,
                LongInt(OldWindowProc));
end;
end.

Nota: Para probarlo agregué un TScrollBox con varios botones.

Saludos.
__________________
Daniel Didriksen

Guía de estilo - Uso de las etiquetas - La otra guía de estilo ....
Responder Con Cita