Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2016-01

ScrollBox - How to get proper scrolling for a TPanel?

4 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Gabor Boros

Hi All,

I have a TScrollBox (Height=150) and a TPanel (Height=450) in it. With Linux-Qt I can scroll up and down if the mouse over the scrollbar, the empty space or the Panel in 13 steps.
With Windows can scroll if over the scrollbar or the empty space (in 13 steps too). But the scroll not working if mouse over the Panel. I can override DoMouseWheel but down know how to get the 13 steps long scrolling from it. Any idea? (I use latest fixes_1_6.)

Gabor

Reply by email

Michael W. Vogel
to Gabor Boros

I've a similar problem, so I made a little test, but it is imho not the best solution (I have some flickering, but it works on Windows(7) ).

You can use a own inherited TPanel and override its WndProc to send the message to its parent (TScrollBox):

uses  Classes, ExtCtrls, LMessages, Forms, Controls;
type
   TMyPanel = class(TPanel)
     procedure WndProc(var TheMessage: TLMessage); override;
   end;

...

procedure TMyPanel.WndProc(var TheMessage: TLMessage);
var
   aControl: TControl;
begin
   case TheMessage.Msg of
     LM_MOUSEWHEEL:
       begin
         aControl := Parent;
         if Assigned(aControl) then
           aControl.Perform(TheMessage.Msg, TheMessage.wParam,
TheMessage.lParam);
         Exit;
       end;
   end;
   inherited WndProc(TheMessage);
end;
Gabor Boros wrote 17 lines
Hi All, I have a TScrollBox (Height=150) and a TPanel (Height=450) in it. With Linux-Qt I can scroll up and down if the mouse over the scrollbar, the empty space or the Panel in 13 steps. With Windows can scroll if over the scrollbar or the empty space (in 13 steps too). But the scroll not working if mouse over the Panel. I can override DoMouseWheel but down know how to get the 13 steps long scrolling from it. Any idea? (I use latest fixes_1_6.) Gabor -- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply by email

Sandro Cumerlato
to Gabor Boros: I have a TScrollBox (Height=150) and a TPanel (Height=450) in it. With Linux-Qt I can…

Hello Gabor,
take a look at the OnMouseWheel.zip example available on this page:

http://bugs.freepascal.org/view.php?id=26781

Sandro

"Gabor Boros" wrote 18 lines
Hi All, I have a TScrollBox (Height=150) and a TPanel (Height=450) in it. With Linux-Qt I can scroll up and down if the mouse over the scrollbar, the empty space or the Panel in 13 steps. With Windows can scroll if over the scrollbar or the empty space (in 13 steps too). But the scroll not working if mouse over the Panel. I can override DoMouseWheel but down know how to get the 13 steps long scrolling from it. Any idea? (I use latest fixes_1_6.) Gabor -- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20160107/5df68ef7/attachment.html>

Reply by email

Gabor Boros
to Michael W. Vogel: I've a similar problem, so I made a little test, but it is imho not the best solution (I…

2016.01.06. 23:40 keltez?ssel, Michael W. Vogel ?rta:

I've a similar problem, so I made a little test, but it is imho not the best solution (I have some flickering, but it works on Windows(7) ).

Michael, Sandro,

Now I have a component level solution which work for me.

function TMyPanel.DoMouseWheel(Shift: TShiftState; WheelDelta: Integer;
MousePos: TPoint): Boolean;
begin
   Result:=inherited DoMouseWheel(Shift,WheelDelta,MousePos);
   if (Parent is TScrollBox) then
    begin
      if (WheelDelta<0) then Parent.Perform(LM_VSCROLL,1,0) else
       if (WheelDelta>0) then Parent.Perform(LM_VSCROLL,0,0);
    end;
end;

Gabor

Reply by email