Mouse scroll button on a Quick report

Asked

Viewed 534 times

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.

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;
  1. Drope a component Application Event on your form.
  2. Go to the events tab and add the OnMessage
  3. Copy and paste the above code into the added event.

Second oldest tip

First, add an event BeforePrint in his 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 the QRStandardPreview in both functions by the name of its component TQRPreview.


See more here:

Quickreport Delphi 7 - Scrolling on scrollbar.

  • you have some example you can send me. I did as you say in your example and it didn’t work. In this part of the code "Onmousewheel := Mousewheel;" from access Violation.

  • Hello Ariel, you replaced the QRStandardPreview by the name of its component? It may be in this part that it gives the memory error, because there is no component. Check the post again, I added an update with a code I found on the Embarcadero website.

  • Hello Vitor, to resolve this situation, I did it this way. No evento onMouseWheel coloquei o seguinte código:

Application.ProcessMessages;
QRPreview.VertScrollBar.Position := QRPreview.VertScrollBar.Position - trunc(WheelDelta / 4);

Isso já foi o bastante para que o que estava precisando funcionasse.

  • Ariel, yes also works, the difference is that you accessed the component directly without searching for it as I did in the example. Also test with the Applicationevents that I put up, it sends a scroll message to your report, maybe it’s even simpler.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.