Solved

Mouse Messages and the Mouse Wheel.

Posted on 1998-11-06
2
680 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
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
IdTelnet1DataAvailable handler freezes the Application 4 62
Downloading email attachments 2 67
TServerSocket - file via sendbuf or Text via sendtext ? 1 42
LAN or WAN ? 11 81
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…
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
Delivering innovative fully-managed cloud services for mission-critical applications requires expertise in multiple areas plus vision and commitment. Meet a few of the people behind the quality services of Concerto.

932 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now