I have a form with a scrollbox.  The scrollboxhas 1 to many controls,
added dynamically.  When enough controls are added, the box expands to
larger than its showing size and a scrollbar appears.

I have the following code in the Mouse wheel handlers for scrolling
this box up and down using the mouse wheel:

procedure TfrmMain.sbxStdArgsMouseWheelDown(Sender: TObject;
  Shift: TShiftState; MousePos: TPoint; var Handled: Boolean);
begin
   If (sbxStdArgs.VertScrollBar.Visible) Then Begin
      If (sbxStdArgs.VertScrollBar.Position <
sbxStdArgs.VertScrollBar.Range) Then Begin
         sbxStdArgs.VertScrollBar.Position :=
sbxStdArgs.VertScrollBar.Position + (sbxStdArgs.VertScrollBar.Range
Div 300);
         Application.ProcessMessages;
      End;
   End;
end;

procedure TfrmMain.sbxStdArgsMouseWheelUp(Sender: TObject;
  Shift: TShiftState; MousePos: TPoint; var Handled: Boolean);
begin
   If (sbxStdArgs.VertScrollBar.Visible) Then Begin
      If (sbxStdArgs.VertScrollBar.ScrollPos > 0) Then Begin
         sbxStdArgs.VertScrollBar.Position :=
sbxStdArgs.VertScrollBar.Position - (sbxStdArgs.VertScrollBar.Range
Div 300);
         Application.ProcessMessages;
      End;
   End;
end;

This works pretty well.  However, you must click on a control owned by
the box before the handlers actually get called.  It does not seem to
matter whether the control clicked on is enabled or not; however, no
click, no wheel action.

I would like to make the wheel act the way it does in Office products
or in the browser: i.e. if the mouse cursor is directly over the
scrollbox, or a control owned by the scrollbox, then the scrollbox
gets the wheel up and down messages.  You should not need to establish
the cursor in an owned control before the wheel works on any container
or control with a scrollbar.

Thanks in advance.

jamie




-----------------------------------------------------
Home page: http://groups.yahoo.com/group/delphi-en/
To unsubscribe: [EMAIL PROTECTED] 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/delphi-en/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 


Reply via email to