Page 1 of 1

Lost selection on MouseWheel-Action problem in TCRDBGrid

Posted: Thu 05 Apr 2007 13:49
by deca
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

Posted: Fri 06 Apr 2007 10:07
by Antaeus
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.