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:
Share on facebook
Share on twitter
Share on linkedin


The Latest

iOS app development

The Future of iOS App Development: Trends to Watch

When it launched in 2008, the Apple App Store only had 500 apps available. By the first quarter of 2022, the store had about 2.18 million iOS-exclusive apps. Average monthly app releases for the platform reached 34,000 in the first half of 2022, indicating rapid growth in iOS app development.

microsoft careers

Top Careers at Microsoft

Microsoft has gained its position as one of the top companies in the world, and Microsoft careers are flourishing. This multinational company is efficiently developing popular software and computers with other consumer electronics. It is a dream come true for so many people to acquire a high paid, high-prestige job

your company's audio

4 Areas of Your Company Where Your Audio Really Matters

Your company probably relies on audio more than you realize. Whether you’re creating a spoken text message to a colleague or giving a speech, you want your audio to shine. Otherwise, you could cause avoidable friction points and potentially hurt your brand reputation. For example, let’s say you create a