Recent

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

Badger

  • Full Member
  • ***
  • Posts: 117
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

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

I'm using Windows 10 Lazarus v2.0.10

dje

  • Full Member
  • ***
  • Posts: 107
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: 117
Re: Disabling a Scroll Box
« Reply #2 on: August 19, 2022, 11:49:32 pm »
So Easy!
Thanks
Badger

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

I'm using Windows 10 Lazarus v2.0.10

 

TinyPortal © 2005-2018