Forum > LCL

TCombobox - no selection on hoover


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)

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.

i tried some programs and they dont't have this behaviour:
* outlook
* vmware player
* ultravnc

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  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---Procedure Form1.ComboBoxMouseWheel(Sender:TObject;Shift:TShiftState;  WheelDelta:Integer;MousePos:TPoint;var Handled:Boolean);begin  if not (Sender as TCombobox).DroppedDown  then Handled:= true;end;


[0] Message Index

Go to full version