Components for Delphi and C++ Builder.

Go to Russian forum
Go to EhLib.com
It is currently 19 Apr 2024, 01:08

All times are UTC




Post new topic Reply to topic  [ 4 posts ] 
Author Message
PostPosted: 14 Nov 2017, 06:31 
Offline

Joined: 11 May 2014, 20:36
Posts: 12
Users are complaining that the mouse wheel changes the data without them noticing:
How can I disable mouse wheel scroll change when cursor is in a TDBLookupComboboxEh.
I tried adding the event to the form :

procedure TfrmFilms.FormMouseWheel(Sender: TObject; Shift: TShiftState;
WheelDelta: Integer; MousePos: TPoint; var Handled: Boolean);
begin
if Screen.ActiveControl is TDBLookupComboboxEh then
Handled := True;
end;

But it didn't work. The event is not always triggered.

Delphi 2007, Ehlib 9.1


Top
 Profile  
 
PostPosted: 22 Nov 2017, 12:53 
Offline

Joined: 09 Feb 2012, 17:05
Posts: 124
Hello,

I had the same problem
To solve it I used interposer classes

Add my unit ComboBoxNoWheel in your uses clause
In form.create disable mouse wheel on comboBoxes by adding this line :

MyDbComBoEh.DisableMouseWheel := True;

Rico

I can't attach a file so use this code :

Code:
unit ComboBoxNoWheel;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Vcl.Mask, DBCtrlsEh,
  DBGridEh, DBLookupEh;


Type
  TDBComboBoxEh = Class(DBCtrlsEh.TDBComboBoxEh)
    function DoMouseWheel(Shift: TShiftState; WheelDelta: Integer; MousePos: TPoint): Boolean; override;
  private
    FDisableMouseWheel: Boolean;
  public
    Property DisableMouseWheel: Boolean Read FDisableMouseWheel Write FDisableMouseWheel;
  End;



  TDBLookupComboBoxEh = Class(DBLookupEh.TDBLookupComboBoxEh)
    function DoMouseWheel(Shift: TShiftState; WheelDelta: Integer; MousePos: TPoint): Boolean; override;
  private
    FDisableMouseWheel: Boolean;
  public
    Property DisableMouseWheel: Boolean Read FDisableMouseWheel Write FDisableMouseWheel;
  End;


implementation

function TDBComboBoxEh.DoMouseWheel(Shift: TShiftState; WheelDelta: Integer; MousePos: TPoint): Boolean;
begin
if Not FDisableMouseWheel then inherited
else Result := true;
end;


function TDBLookupComboBoxEh.DoMouseWheel(Shift: TShiftState; WheelDelta: Integer; MousePos: TPoint): Boolean;
begin
if Not FDisableMouseWheel then inherited
else Result := true;
end;

end.


Top
 Profile  
 
PostPosted: 28 Nov 2017, 11:23 
Offline

Joined: 11 May 2014, 20:36
Posts: 12
Thanks for the reply,
But I had two issues with your unit.
1. Specifying the System.Variants and Vcl.Dialogs and the rest of the units, gave me file not found error. Maybe cause I using D2007
2. After removing all prefixes to the units in the uses, I got "E2008 Incompatible types" for the two lines
Code:
else Result := true;


What is wrong?


Top
 Profile  
 
PostPosted: 01 Dec 2017, 11:53 
Offline

Joined: 11 May 2014, 20:36
Posts: 12
Fixed it. The line before was missing a call to the parent function.
Code:
function TDBComboBoxEh.DoMouseWheel(Shift: TShiftState; WheelDelta: Integer; MousePos: TPoint): Boolean;
begin
   if Not FDisableMouseWheel then
      inherited DoMouseWheel(Shift, WheelDelta, MousePos)
   else
      Result := true;
end;

Which should be added to the second function also.

Thanks Rico


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC


Who is online

Users browsing this forum: Google [Bot] and 10 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group