Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Keeping Cursor on Active Form?

Posted on 1997-10-13
4
Medium Priority
?
152 Views
Last Modified: 2010-04-04
Can someone tell me and give me an example of how to keep the cursor on the Active Form?
0
Comment
Question by:Rick_S
  • 2
4 Comments
 
LVL 1

Expert Comment

by:fsanchez
ID: 1347425
You need to call the SetCapture(HandleOfMyWindow) function. The parameter is the handle of the window that should capture the mouse, for example MyForm.Handle.

When you have finished you have to call the ReleaseCapture function.

Good luck, Rick
0
 

Author Comment

by:Rick_S
ID: 1347426
I guess I was not very clear, I need the to cursor to stay within the borders of my active window. The SetCapture only directs the input to the window specified but still lets the cursor go else where on the screen. Here is what the help file says:

"The SetCapture function sets the mouse capture to the specified window belonging to the current thread. Once a window has captured the mouse, all mouse input is directed to that window, regardless of whether the cursor is within the borders of that window. Only one window at a time can capture the mouse."

Thanks for the quick responce!

Rick S.
0
 
LVL 5

Accepted Solution

by:
JimBob091197 earned 400 total points
ID: 1347427
Use ClipCursor.

Example:
procedure TForm1.FormCreate(Sender: TObject);
var
    r: TRect;
begin
    // This restricts the cursor to Form1's borders.
    r.Left := Left;
    r.Top := Top;
    r.Right := Left + Width;
    r.Bottom := Top + Height;
    ClipCursor(@r);
end;

procedure TForm1.FormDestroy(Sender: TObject);
begin
    // This allows the cursor to move anywhere.
    ClipCursor(nil);
end;

Hope this is what you're looking for.
JB
0
 

Author Comment

by:Rick_S
ID: 1347428
JimBob,

I happen to find this answer on a newgroup but you are right on this is exactly what I was looking for....

Thanks for your time,
Rick S.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Suggested Courses

927 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