Lost selection on MouseWheel-Action problem in TCRDBGrid

Discussion of open issues, suggestions and bugs regarding MyDAC (Data Access Components for MySQL) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
deca
Posts: 19
Joined: Thu 05 Apr 2007 13:36
Location: Germany

Lost selection on MouseWheel-Action problem in TCRDBGrid

Post by deca » Thu 05 Apr 2007 13:49

Hello,

since I'm using the TCRDBGrid instead of the normal TDBGrid i have a problem to handle the WM_MOUSEWHEEL message to prevent the lost of my current (multi-)selection.


Here's the code including the extension for the TCRDBGrid:

Code: Select all

procedure TfmMain.AppMessage(var Msg: TMsg; var Handled: Boolean);
var DBGrid : TDBGrid;
		CRDBGrid : TCRDBGrid;
begin
 	if not fmMain.Showing then Exit;

  if Msg.message = WM_MOUSEWHEEL then
  begin
    if (Screen.ActiveControl is TDBGrid) or (Screen.ActiveControl is TCRDBGrid)then
    begin
      if Screen.ActiveControl is TDBGrid then
      begin
      	DBGrid := Screen.ActiveControl as TDBGrid;

        if Msg.wParam > 0 then
          Msg.wParam := SendMessage(DBGrid.Handle, WM_VSCROLL, SB_LINEUP, 0)
        else Msg.wParam := SendMessage(DBGrid.Handle, WM_VSCROLL, SB_LINEDOWN, 0);
      end
      else if Screen.ActiveControl is TCRDBGrid then
      begin
      	CRDBGrid := Screen.ActiveControl as TCRDBGrid;

        if Msg.wParam > 0 then
          Msg.wParam := SendMessage(CRDBGrid.Handle, WM_VSCROLL, SB_LINEUP, 0)
        else Msg.wParam := SendMessage(CRDBGrid.Handle, WM_VSCROLL, SB_LINEDOWN, 0);
      end;
      Handled := False;
    end;
  end;
end;
Any idea?

I'm using:
Delphi 7.0 Build 4.453 with MyDac 5.00.0.4

Best regards,
Karsten Hansske

Antaeus
Posts: 2098
Joined: Tue 14 Feb 2006 10:14

Post by Antaeus » Fri 06 Apr 2007 10:07

We do not plan to change behaviour of CRDBGrig in the near future. You can do it yourself by changing the TCRDBGrid.WMMouseWheel procedure in the CRGrid.pas unit.
Note: this file is a part of the TCRDBGrid source code. It is available only for registered users.

Post Reply