sScrollbox on an sFrameBar

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #34934
    mol
    Participant

    I usually use the following procedure to trap mouse wheel messages when the cursor is over a control:

    procedure TForm1.MouseWheelHandler(var Message: TMessage);

    var

    Target: TWinControl;

    begin

    Target := FindVCLWindow(SmallPointToPoint(TWMMouseWheel(Message).Pos));

    if Assigned(Target) then

    Target.Perform(CM_MOUSEWHEEL, Message.WParam, Message.LParam)

    else

    inherited MouseWheelHandler(Message);

    Message.Result := 1;

    end;

    This works for all controls – no matter if they are located on a frame or form. The scrollbars of the control react to movements of the mouse wheel. The only exception is an sScrollbox which is sitting on a frame within an sFrameBar. I cannot get the sScrollbox to react to the mouse wheel when the cursor is over the control.

    So, how do I do that?

    Steps to reproduce:

    Put an sFrameBar on a form

    Create a TFrame and drop an sScrollbox on it

    Place a few panels on the sScrollbox

    Run the program and reduce size so that the vertical scrollbar of the scrollbox becomes visible

    Place mouse cursor over scrollbox and move the mouse wheel

    Nothing happens

    Thanks!

    #47323
    Support
    Keymaster

    Hello

    Maybe this is standard behavior?

    Can you check the TSrollBox component please?

    Here I uploaded the test-app by your problem description. It's correct?

    #47233
    mol
    Participant

    Yes, your test application shows the behaviour I was experiencing. In the meantime, I have found an old solution posted by Peter Below for a related problem:

    Quote:

    “The main problem seems to be that the scrollbox does not take focus when clicked on, and the MS Intellimouse driver will only send WM_MOUSEWHEEL messages to the control with focus. So the messages go to the form.”

    procedure TForm1.FormMouseWheel(Sender: TObject; Shift: TShiftState;

    WheelDelta: Integer; MousePos: TPoint; var Handled: Boolean);

    begin

    if PtInRect(scrollbox1.BoundsRect, ScreenToClient(Mouse.CursorPos)) then

    scrollbox1MouseWheel(Sender, Shift, WheelDelta, MousePos, Handled);

    end;

    procedure TForm1.scrollbox1MouseWheel(Sender: TObject;

    Shift: TShiftState; WheelDelta: Integer; MousePos: TPoint;

    var Handled: Boolean);

    var

    msg: Cardinal;

    code: Cardinal;

    i, n: Integer;

    begin

    Handled := true;

    if ssShift in Shift then

    msg := WM_HSCROLL

    else

    msg := WM_VSCROLL;

    if WheelDelta > 0 then

    code := SB_LINEUP

    else

    code := SB_LINEDOWN;

    n:= Mouse.WheelScrollLines;

    for i:= 1 to n do

    scrollbox1.Perform(msg, code, 0);

    scrollbox1.Perform(msg, SB_ENDSCROLL, 0);

    end;

    The above works with a regular scrollbox, but I haven't checked with the sScrollBox. Anyway, I hope this helps others in the future.

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.