Solved

Mouse Messages and the Mouse Wheel.

Posted on 1998-11-06
2
697 Views
Last Modified: 2008-03-04
I'm looking for help from someone who has actually used the
mouse wheel output as a control source. I'm not sure if it is the mouse driver or my understanding of the mousewheelhandler (Tmessage elements) and the Onmousewheel event(wheeldelta). I'm trying to get some type of forward reverse increment/decrement counter but the mousewheelhandler doesn't seem very reliable? Any help would be welcome.
Thx in advance!
/steve
0
Comment
Question by:sz3905
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 4

Accepted Solution

by:
BoRiS earned 200 total points
ID: 1345952
sz3905

I recieved this not so long ago, it shows how to trap the mousewheel message in windows 9x and send a mesage is NT for the mouse wheel...this should shed so light...

 
              unit Unit1;
               
              interface
               
              uses
                Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
              StdCtrls, ComCtrls;
               
              type
                (*
                WM_MOUSEWHEEL
                fwKeys = LOWORD(wParam); // key flags
                zDelta = (short) HIWORD(wParam); // wheel rotation
                xPos = (short) LOWORD(lParam); // horizontal position of pointer
                yPos = (short) HIWORD(lParam); // vertical position of pointer
               
                fwKeys: Value of the low-order word of wParam. Indicates whether
                        various virtual keys are down. This parameter can be any
                        combination of the following values:
                            MK_CONTROL Set if the CTRL key is down.
                            MK_LBUTTON Set if the left mouse button is down.
                            MK_MBUTTON Set if the middle mouse button is down.
                            MK_RBUTTON Set if the right mouse button is down.
                            MK_SHIFT Set if the SHIFT key is down.
                *)
                TWMMouseWheelNT = record
                  msg: Cardinal; // msg
                  fwKeys: smallint;
                  rotation: smallint; // wParam
                  mousepos: TSmallPoint; // lParam
                  result: longint;
                end;
               
                TWMMouseWheel95 = record
                  msg: Cardinal; // msg
                  rotation: integer; // wParam
                  mousepos: TSmallPoint; // lParam
                  result: longint;
                end;
               
                TForm1 = class(TForm)
                  Button1: TButton;
                  Memo1: TRichEdit;
                  procedure FormCreate(Sender: TObject);
                  procedure Button1Click(Sender: TObject);
                private
                  { Private declarations }
                  FWheelMsg: Cardinal;
                protected
                  { Protected declarations }
                  procedure wheelMove(numScroll: integer);
                public
                  { Public declarations }
                  procedure WndProc(var Message: TMessage); override;
                  procedure WMMouseWheel(var Msg: TWMMouseWheelNT);
                            message WM_MOUSEWHEEL;
                end;
               
              var
                Form1: TForm1;
               
              implementation
               
              {$R *.DFM}
               
              procedure TForm1.FormCreate(Sender: TObject);
              begin
                Memo1.Lines.LoadFromFile('C:\WINDOWS\WIN.INI');
               
                // line below only is meaningfull under Windows 95
                FWheelMsg := RegisterWindowMessage('MSWHEEL_ROLLMSG');
              end;
               
              procedure TForm1.wheelMove(numScroll: integer);
              var
                i: integer;
              begin
                if (numScroll > 0) then
                  for i := 0 to numScroll do
                    SendMessage(Memo1.Handle, WM_VSCROLL, SB_LINEUP, 0)
                else
                  for i := 0 downto numScroll do
                    SendMessage(Memo1.Handle, WM_VSCROLL, SB_LINEDOWN, 0);
              end;
               
              procedure TForm1.WndProc(var Message: TMessage);
              begin
                // called only under Windows 95
                inherited WndProc(Message);
                if (TMessage(Message).Msg = FWheelMsg) then
                  wheelMove( TWMMouseWheel95(Message).Rotation div WHEEL_DELTA );
              end;
               
              procedure TForm1.WMMouseWheel(var Msg: TWMMouseWheelNT);
              begin
                // called only under NT 4
                wheelMove( msg.Rotation div WHEEL_DELTA );
              end;
               
              procedure TForm1.Button1Click(Sender: TObject);
              begin
                Close;
              end;
               
              end.

Thank you to Peter below for this code...

Later
BoRiS
0
 

Author Comment

by:sz3905
ID: 1345953
Thank You Boris, It made some things a lot clearer for me!
/Steve

0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
find a node in VST 2 78
URL for downloading Google Chrome for Win XP 2 233
How to renew a Delphi rad-studio licence? 5 76
Controlled Assessment GCSE - desperate help needed 4 111
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

756 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question