Recent

Author Topic: TCombobox - no selection on hoover  (Read 3091 times)

MisterE

  • New Member
  • *
  • Posts: 13
TCombobox - no selection on hoover
« on: October 13, 2012, 09:11:17 pm »
I use multiple TComboboxes on a TScrollBox. It is very annoying that all comboxes start scrolling (selecting items) when  pointing the mouse on it (hoover) and using the mouse scroll wheel.

Is it possible to disable this? (and only activate the scrollwheel for a combobox when first clicking on it)

howardpc

  • Hero Member
  • *****
  • Posts: 4144
Re: TCombobox - no selection on hoover
« Reply #1 on: October 14, 2012, 12:24:40 am »
AFAIK this is not possible because it is the behaviour of the underlying OS widget, and TComboBox does not implement an OnMouseWheel event which you could hook to disable anything (it is protected in the ancestor). In fact even setting Enabled to False for a combobox does not prevent this underlying widget behaviour. Setting Style to ownerdrawn does not help either, since that paints the dropdown, not the edit field area where the scrolling happens.

MisterE

  • New Member
  • *
  • Posts: 13
Re: TCombobox - no selection on hoover
« Reply #2 on: October 14, 2012, 12:05:31 pm »
i tried some programs and they dont't have this behaviour:
* outlook
* vmware player
* ultravnc


kupferstecher

  • Hero Member
  • *****
  • Posts: 603
Re: TCombobox - no selection on hoover
« Reply #3 on: February 18, 2024, 12:25:11 pm »
Very old topic, but for those that search for this issue and stumble over this thread, here is a solution:

Define the MouseWheel event handler of the TComboBox and set handled:= true. The if part is to not block scrolling when the drop down is opened. But thats self explanatory  :)

Code: Pascal  [Select][+][-]
  1. Procedure Form1.ComboBoxMouseWheel(Sender:TObject;Shift:TShiftState;
  2.   WheelDelta:Integer;MousePos:TPoint;var Handled:Boolean);
  3. begin
  4.   if not (Sender as TCombobox).DroppedDown
  5.   then Handled:= true;
  6. end;

 

TinyPortal © 2005-2018