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;
I'm using:
Delphi 7.0 Build 4.453 with MyDac 5.00.0.4
Best regards,
Karsten Hansske