TIP: Click on subject to list as thread! ANSI
echo: os2prog
to: Peter Fitzsimmons
from: Craig Swanson
date: 1994-09-23 18:38:48
subject: PM mouse tracking

PF> *Whenever* you receive a WM_MOUSEMOVE message,  the
 PF> mouse is over your window (unless you have called
 PF> WinSetCapture(),  in which case your window is the
 PF> only one that receives mouse messages,  even if the
 PF> pointer moves outside your window).

 PF> The mouse co-ordinates will be adjusted for your
 PF> window, so the when the mouse is over the bottom left
 PF> of your window,  you will recieve the coordinates 0, 0.

But what do you do if you want to track the mouse pointer outside your own
window but do not want to capture the mouse pointer?  It seems to me there
are two choices:

    1) Use WM_TIMER messages to periodically poll the location
       of the mouse pointer.

    2) Set an input queue hook and inspect all mouse messages
       and then process those that indicate the mouse is moving.

Are you aware of any other methods?  Neither is perfect for what I want. 
From the WM_MOUSEMOVE messages I can determine when the mouse is in the
window, but there isn't a good (i.e., simple and efficient) way to
determine when the mouse leaves the window.

For one application, I just want to use the mouse messages to update a
static text control indicating a time at which the user is pointing. When
the mouse moves outside of the control, I want the static text control to
be cleared.  This would be simple and efficient if IBM implemented a couple
new features in PM.

IBM should modify PM as follows:

  First would be an internal change to store the previous HWND over
  which the mouse was located.  Any mouse movement would cause PM to
  check if the new mouse location is still over the previous HWND.  If
  so, just sent WM_MOUSEMOVE messages.  If not, sent a WM_MOUSELEAVING
  (or some similar name) message to the previous HWND and and
  WM_MOUSEENTERING message to the window that it has just entered.
  Now if you want to change something when the mouse enters or leaves
  your window, just process the WM_MOUSEENTERING and WM_MOUSELEAVING
  messages.  Now to tie this up completely, the case of a window being
  made visible underneath the mouse pointer needs to be handled.  If
  this happens, simply send a WM_MOUSELEAVING message to the window
  being obscured and a WM_MOUSEENTERING message to the window that has
  just been made visible.

  For the ultimate in flexibility, there should be a window style or
  some window state that can be set to request that any mouse movement
  (even outside the window) generate a WM_MOUSEMOVE message to the
  window.  Perhaps a linked list could be used to internally chain
  together the windows that need continuous WM_MOUSEMOVE messages
  in order to keep efficient the job of notifying the small number of
  windows that would need such service.


I think these two modifications would take care of nearly all mouse tracking needs.


--- Maximus/2 2.01wb

* Origin: OS/2 Connection {at} Mira Mesa, CA (1:202/354)
SEEN-BY: 12/2442 54/54 620/243 624/50 632/348 640/820 690/660 711/409 410 413
SEEN-BY: 711/430 807 808 809 934 942 712/353 623 713/888 800/1
@PATH: 202/354 301 1 3615/50 229/2 12/2442 711/409 54/54 711/808 809 934

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.