Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Keeping Cursor on Active Form?

Posted on 1997-10-13
4
Medium Priority
?
151 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Technology Partners: 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

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

719 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