Recent

Author Topic: Disabling a Scroll Box [Solved]  (Read 496 times)

Badger

  • Full Member
  • ***
  • Posts: 144
Disabling a Scroll Box [Solved]
« on: August 19, 2022, 02:55:24 pm »
I am using a scrollbox with a number of objects on it.  One of these objects is a Label. I have included code to make the font of the label larger or smaller when the mouse is over the label and the mouse wheel is rotated.
The font change takes place BUT, of course, the scroll box scrolls at the same time.
Is there any way of disabling the scroll box scrolling while the cursor is over the label?
« Last Edit: August 19, 2022, 11:50:12 pm by Badger »
Badger
(A bad tempered, grumpy animal that sleeps most of the winter!)

If at first you don't succeed - you're running about average!

I'm using Windows 10 Lazarus v2.4.4  FPC 3.2.2   Win 32/64

dje

  • Full Member
  • ***
  • Posts: 134
Re: Disabling a Scroll Box
« Reply #1 on: August 19, 2022, 03:39:35 pm »
Set Handled to True.

Code: Pascal  [Select][+][-]
  1. procedure TForm1.Label1MouseWheel(Sender: TObject; Shift: TShiftState; WheelDelta: integer;
  2.   MousePos: TPoint; var Handled: boolean);
  3. begin
  4.   if Label1.ClientRect.Contains(MousePos) then begin
  5.     Handled := True;
  6.     Label1.Font.Height := Max(12, Label1.Font.Height + Sign(WheelDelta) * 2);
  7.   end;
  8. end;

Badger

  • Full Member
  • ***
  • Posts: 144
Re: Disabling a Scroll Box
« Reply #2 on: August 19, 2022, 11:49:32 pm »
So Easy!
Thanks
Badger
(A bad tempered, grumpy animal that sleeps most of the winter!)

If at first you don't succeed - you're running about average!

I'm using Windows 10 Lazarus v2.4.4  FPC 3.2.2   Win 32/64

 

TinyPortal © 2005-2018