Solved

Mouse Messages and the Mouse Wheel.

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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Suggested Courses
Course of the Month9 days, 9 hours left to enroll

623 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