Confining Your Mouse to a Form

Confining Your Mouse to a Form

With Modal forms there is a need to restrict the movement of the mouse to the form until user closes the form. This can be achieved by using the ClipCursor API. ClipCursor API takes one parameter, the rectangular area of type RECT to which the mouse will be confined.

 Public Sub Clip()1Dim iRect as RECT' first populate the iRect with Form's dimensions & then call the ClipCursor APIWith iRect  .Left = Form1.Left  .Top = Form1.Top  .Right = Form1.Left + Form1.Width  .Bottom = Form1.Top + Form1.HeightEnd WithClipCursor iRectEnd Sub' and finally in Form's Unload event call ClipCursor again to release the mouse :-ClipCursor 0&

Note that RECT expects dimensions of the form in pixels, as is the case with all APIs. Set the form’s ScaleMode to vbPixels before calling the ClipCursor API.

Share the Post:
data observability

Data Observability Explained

Data is the lifeblood of any successful business, as it is the driving force behind critical decision-making, insight generation, and strategic development. However, due to its intricate nature, ensuring the

Heading photo, Metadata.

What is Metadata?

What is metadata? Well, It’s an odd concept to wrap your head around. Metadata is essentially the secondary layer of data that tracks details about the “regular” data. The regular