Mouse scroll button on a quick report report

0

How to make the mouse scroll button work in Quick Report reports.

Today I use a custom Preview using the TQRPreview component.

I use Delphi 7 and Quick Report 3.0.9.

    
asked by anonymous 28.06.2016 / 14:35

1 answer

2

Updated 05/07/2016

I found this other tip in the Embarcadero forum, even simpler than the tip below.

procedure TForm1.ApplicationEvents1Message(var Msg: tagMSG;
var Handled: Boolean);
var
    i: SmallInt;
    pt : Tpoint;
begin
    GetCursorPos(pt); // Get the position from Cursor
    if Msg.message = WM_MOUSEWHEEL then // WheelMouse Message when scrolling
    begin 
        Msg.lParam := 0;
        i := HiWord(Msg.wParam) ;
        if i > 0 then // If Scrolling Up
            SendMessage(WindowFromPoint(pt),WM_VSCROLL, SB_LINEUP,0) 
        else 
            SendMessage(WindowFromPoint(pt),WM_VSCROLL, SB_LINEDOWN,0);

        Handled := False;
    end;
end;
  • Drop an Application Event component on your form.
  • Go to the events tab and add the OnMessage
  • Copy and paste the above code into the added event.
  • Second oldest tip

    First, add a BeforePrint event to your report:

    procedure Form1.QuickRep1BeforePrint(Sender: TCustomQuickRep;
      var PrintReport: Boolean);
    begin
      SetupMouseWheel;
    end;
    

    Then, create the function SetupMouseWheel :

    procedure Form1.SetupMouseWheel;
    begin
      with TQRStandardPreview(Application.FindComponent('QRStandardPreview')) do
        begin
          OnMouseWheel := MouseWheel;
        end;
    end;
    

    Finally, create the function MouseWheel :

    procedure Form1.MouseWheel(Sender: TObject; Shift: TShiftState;
      WheelDelta: Integer; MousePos: TPoint; var Handled: Boolean);
    begin
      with TQRStandardPreview(Application.FindComponent('QRStandardPreview')) do
      begin
        Application.ProcessMessages;
        VertScrollBar.Range := 1350;
        VertScrollBar.Position := VertScrollBar.Position - trunc(WheelDelta / 4);
      end;
    end;
    

    Replace QRStandardPreview in both functions with the name of your TQRPreview component.

    See more here:

    QuickReport Delphi 7 - Scrollbar .

        
    30.06.2016 / 04:39