?
Solved

Mouse Messages and the Mouse Wheel.

Posted on 1998-11-06
2
Medium Priority
?
711 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 600 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
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…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Suggested Courses

719 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