"Trap" mouse cursor al''a MDI.

Hi, I'm working on a window system similair to MDI, having a working area where you can move around windows, which are just HeaderedContentControl by the way. But now I want to "trap" the mouse cursor inside the working areas border while moving a window, to have the same feel as with forms and MDI (if you don't know what I mean, just create a windows forms application, create another form and add that form as a child to the main form).

I've tried to do "trap" the mouse cursor by listening to the MouseLeave event and setting the mouse cursor position with win32 api call (since I don't find the corresponding wpf call to do that), but it doesn't look good because you can see the cursor jump back.

Is there any good WPF way to make this happen without seeing the mouse cursor jump? Are there any solution to do this?

Well, hope you understand =).

Thanks for you help in advance,

Joakim Rosendahl.

[976 byte] By [Kimmen] at [2008-1-9]
# 1

try calling the ReleaseCapture method on the control ....
MarlonGrech at 2007-10-3 > top of Msdn Tech,Visual Studio Orcas,Windows Presentation Foundation (WPF)...
# 2
Correct a minor mistake. Control class has a CaptureMouse and a ReleaseMouseCapture method, not ReleaseCapture Smile.
Yi-LunLuo-MSFT at 2007-10-3 > top of Msdn Tech,Visual Studio Orcas,Windows Presentation Foundation (WPF)...
# 3

Thanks for your replies, Marlon och Yi-Lun.

I sat with CaptureMouse yesterday and it gave me a satisfactory solution, not exactly what I was hoping for but it better than the old one =D.

Can I presume that is not really possible to visually "trap" the mouse cursor within a control / framework element? I could probably make the cursor invisible and move a fake cursor or something .

Thanks anyway!

Kimmen at 2007-10-3 > top of Msdn Tech,Visual Studio Orcas,Windows Presentation Foundation (WPF)...

Visual Studio Orcas

Site Classified