ClipCursor() Requires WINSTA_WRITEATTRIBUTES
  
PSS ID Number: Q106384
Article last modified on 01-05-1995
 
3.10
 
WINDOWS NT
 

----------------------------------------------------------------------
The information in this article applies to:
 
 - Microsoft Win32 Software Development Kit (SDK) for Windows NT
   version 3.1
----------------------------------------------------------------------
 
SUMMARY
=======
 
The documentation for ClipCursor() states that the calling process must
have WINSTA_WRITEATTRIBUTES access to the window station. However, this
permission does not have to be enabled programmatically because the system
always grants the Local Login SID (the interactive user)
WINSTA_WRITEATTRIBUTES access, regardless of the permission groups to which
the user belongs.
 
MORE INFORMATION
================
 
The following code shows how to confine the cursor to the application
window during WM_ACTIVATE processing. Note that the clip cursor region must
be restored to its previous state each time the application deactivates.
 
Sample Code
-----------
 
   static RECT rcOldClip;
    .
    .
    .
 
      case WM_ACTIVATE:{¬
         short fActive = LOWORD( wParam );
 
         if( fActive ){¬
            RECT rcNewClip;
 
            /* Record the area in which the cursor can move. */
            GetClipCursor( &rcOldClip );
 
            /* Get the dimensions of the application's client area. */
            GetClientRect( hWnd, &rcNewClip);
 
            /* Convert to screen coordinates. */
            MapWindowPoints( hWnd, NULL, (LPPOINT)&rcNewClip, 2 );
 
            /* Confine the cursor to the application's window. */
            ClipCursor( &rcNewClip );
        }
        else{¬
            /* Restore the cursor to its previous area. */
            ClipCursor( &rcOldClip );
        }
        break;
    }
 
Additional reference words: 3.10
KBCategory: kbprg
KBSubcategory: GdiCurico
 
=============================================================================
 
Copyright Microsoft Corporation 1995.
