Link to home
Start Free TrialLog in
Avatar of Frits2
Frits2

asked on

Delphi 7 QuickReport with MouseWheel support

Hello Experts

I need the QuickReportForm to respond to the MouseWheel, now I found the next code snipe on this site from expert pcsentinel. Somehow I can't get this code working. using Delphi 7 & QuickReport 4.05. No errors messages but QRform does not respond on the MouseWheel.
what do I do wrong?
if there is an other solution I am happy to hear it
Many thanks,
Frits2

Type
    procedure MouseWheelHandler(var Message: TMessage); override;
    procedure FormMouseWheelDown(Sender: TObject; Shift: TShiftState;
      MousePos: TPoint; var Handled: Boolean);
    procedure FormMouseWheelUp(Sender: TObject; Shift: TShiftState;
      MousePos: TPoint; var Handled: Boolean);

implementation
procedure TForm1.MouseWheelHandler(var Message: TMessage);
begin
with Message do
  Result := Perform(CM_MOUSEWHEEL, WParam, LParam);
end;

procedure TForm1.FormMouseWheelDown(Sender: TObject;
  Shift: TShiftState; MousePos: TPoint; var Handled: Boolean);
begin
  QRForm.VertScrollBar.Position := QRForm.VertScrollBar.Position + 50;
  Handled:=true;
end;

procedure TForm1.FormMouseWheelUp(Sender: TObject; Shift: TShiftState;
  MousePos: TPoint; var Handled: Boolean);
begin
  QRForm.VertScrollBar.Position := QRForm.VertScrollBar.Position - 50;
  Handled:=true;
end;
Avatar of sun4sunday
sun4sunday
Flag of India image

This gives the solution for the DbGrid, http://delphi.about.com/cs/adptips2002/a/bltip1102_3.htm

Test with Qreport
sun4sunday
Avatar of Frits2
Frits2

ASKER

Hi Sun4Sunday

thanks for the contribution.
I have tried this in all the ways I can think of! and it does catch my MouseWheel movement but It doesn't make the QReport react on it.It works on the DBGrid and DBLookUpComboBox But not on QuickReport
When I change the lines for i>o with
  qrPreview1.VertScrollBar.Position:=qrPreview1.VertScrollBar.Position-50;
  Handled:=true;
and the opposit for i < 0
No QR mousemoves

thanks and Best regards
Frits


May be Qreport not supporting this

sun4sunday
Avatar of Frits2

ASKER

Hi Sun4Sunday

The form does have OnMouseWheel events and according other with the same question he/she did find a solution but this doesn't work for me somehow.
But I will check the QBS Site once again

thanks again & best regards
Frits
Avatar of Frits2

ASKER

Hi Again Sun4Sunday

Yes Here is the answer from, the qusoft F.A.Q. list:
Q.  Is it possible, to use the MS Intellimouse's wheel inside the preview of quickreport?
A.  This should be handled by the OS or by the mouse driver.  With Win98, the mouse wheel support is in the OS, with Win95 you can enable the wheel with the Intellimouse 2.2 driver from MS.  I have tested the preview with Intellimouse 2.2 under Win95 and the preview could be scrolled by the wheel.
I asked qusoft support for a example but my emails get returned undeliverable .

best regards
Frits
Try to ask a new mail from what information you got. Like example to implement mouse wheel .

Also search the google with    

mouse wheel preview of quickreport

and go for the

Google Groups results for mouse wheel preview of quickreport

There some solutions are given
http://groups.google.com/group/borland.public.delphi.reporting-charting/browse_thread/thread/5a94894f2f8a2721/d6fa116f7acddc8c?lnk=st&q=mouse+wheel+preview+of+quickreport&rnum=2&hl=en#d6fa116f7acddc8c

http://groups.google.com/group/borland.public.delphi.reporting-charting/browse_thread/thread/5a94894f2f8a2721/d6fa116f7acddc8c?lnk=st&q=mouse+wheel+preview+of+quickreport&rnum=2&hl=en#d6fa116f7acddc8c

Copied from there


uses
...
Private
    procedure WM_MOUSEWHEEL(var Msg: TWMMOUSEWHEEL); message WM_MOUSEWHEEL;
Public
end;


implementation


procedure TMyPreview.WM_MOUSEWHEEL(var Msg: TWMMOUSEWHEEL);
begin
  with QRPreview1.VertScrollBar do Position := Position - Msg.WheelDelta;


  inherited;
end;



sun4sunday
Avatar of Frits2

ASKER

Hi Sun4Sunday
I tried the code and reviewed my attempts before but still no succes in mousewheel movement for my QReports I''ll check it all again next weekend
I will let you know the results

best regards.
Frits
Avatar of Frits2

ASKER

Hi Sun4Sunday

the code doen't work and all what I have tried more I can't get the QR form moved by th mousewheel movement. for now I am stopping this because it costs me to much time...for now.
Don't know what to do with the points .
for now I leave my question open for any suggestions.
thanks for your efforts
best regards Frits
ASKER CERTIFIED SOLUTION
Avatar of sun4sunday
sun4sunday
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Frits2

ASKER

Thanks for your help Sun4Sunday

I did find a piece of code this weekend,  together with some other code from Expert-Exchange.com
It made the QR react on the mouse.
I have QR 4.06 pro and I now understand that it does work with the WheelMouse only after entering a procedure to the QR software. Then a Wheel mouse movement comes to life with QR.
All the code is below.

If having professional edition of QuickReports you can copy this in the QRPrev.pas to make QR react on arrow keys.

unit QRPrev;

interface
uses
...
Private
    procedure CMDialogKey(var message: TCMDialogKey); message CM_DIALOGKEY;

Public  

end;

implementation

procedure TQRStandardPreview.CMDialogKey(var message: TCMDialogKey);
begin {INTERCEPTS ARROW KEYS INORDER TO MOVE AROUND PAGE}
  with message do
    case CharCode of
     VK_LEFT: begin
       with QRPreview.HorzScrollbar do Position := Position -50;
       exit;
       end;
      VK_RIGHT: begin
       with QRPreview.HorzScrollbar do Position := Position +50;
       exit;
       end;
      VK_UP: begin
       with QRPreview.VertScrollbar do Position := Position -50;
       exit;
       end;
      VK_DOWN: begin
       with QRPreview.VertScrollbar do Position := Position +50;
       exit;
       end;
    end;
  inherited;
end;

Save de QRPrev.pas, then open and compile de QR4DesignD7.dpk

Use the next code on in own program form to make the WheelMouse act like an arrow key:

Type
procedure ApplicationMessageHandler(var Msg:tmsg;var handled:boolean);

{in FormCreate}
Application.OnMessage := ApplicationMessageHandler;

procedure TForm1.ApplicationMessageHandler(var Msg:tmsg;var handled:boolean);
var
  i:SmallInt;
begin
if msg.message=WM_MOUSEWHEEL then
  begin
    msg.message:=WM_KEYDOWN;
    msg.lParam:=0;
    {$R-}
    i:=hiword(msg.wParam);
    {$R+}
    if i>0 then msg.wParam:=VK_UP
           else msg.wParam:=VK_DOWN;
    handled:=false;
  end;{if msg.message..}
end; {procedure}

Now every thing works as desired... So actually you initial answer from 5 march 07 was corect
QR does not support Wheelmouse support unless above code is added to the QRPrev.pas

Although your answer did not lead to the solution, actually if I was sure that you where right at 5 march I would have stopped my search to a solution but since you are the only one how took some effort to help, I leave you all the points

Hope the Webmaster will point to this entry as a solution support.

Thank you again and best regards
Frits
You got the solution and sharing the code here. Great

sun4sunday