Solved

Mouse Messages and the Mouse Wheel.

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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

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…
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…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

757 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

20 Experts available now in Live!

Get 1:1 Help Now