|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Magnetic CursorI have written some custom controls that can dragged around a container
control. When the controls reach the edges of the container control, they stop moving. The mouse continues to travel beyond the border of the control. When the mouse direction of travel changes, the control then moves accordingly (I tie the movement of the control to the MousePosition delta). Is there some way to magnet the cursor to the control, so when the control stops moving the mouse does the same? Charlie Brown ha scritto:
> I have written some custom controls that can dragged around a container The most obvious way seems to keep track of the mouse position> control. When the controls reach the edges of the container control, > they stop moving. The mouse continues to travel beyond the border of > the control. When the mouse direction of travel changes, the control > then moves accordingly (I tie the movement of the control to the > MousePosition delta). Is there some way to magnet the cursor to the > control, so when the control stops moving the mouse does the same? under MouseMove and, when you need to freeze it, just: Windows.Forms.Cursor.Position = PreviousPosition I gave that one a shot, it just makes the mouse jump all over the
place. tommaso.gasta***@uniroma1.it wrote: Show quoteHide quote > Charlie Brown ha scritto: > > > I have written some custom controls that can dragged around a container > > control. When the controls reach the edges of the container control, > > they stop moving. The mouse continues to travel beyond the border of > > the control. When the mouse direction of travel changes, the control > > then moves accordingly (I tie the movement of the control to the > > MousePosition delta). Is there some way to magnet the cursor to the > > control, so when the control stops moving the mouse does the same? > > The most obvious way seems to keep track of the mouse position > under MouseMove and, when you need to freeze it, just: > > Windows.Forms.Cursor.Position = PreviousPosition It depends on how you have implemented it.
I used this technique and to me it worked fine. If you wish, post a very simplified and working sample of your code showing the problem, I will be happy to take a look at it... -T Charlie Brown ha scritto: Show quoteHide quote > I gave that one a shot, it just makes the mouse jump all over the > place. > > tommaso.gasta***@uniroma1.it wrote: > > Charlie Brown ha scritto: > > > > > I have written some custom controls that can dragged around a container > > > control. When the controls reach the edges of the container control, > > > they stop moving. The mouse continues to travel beyond the border of > > > the control. When the mouse direction of travel changes, the control > > > then moves accordingly (I tie the movement of the control to the > > > MousePosition delta). Is there some way to magnet the cursor to the > > > control, so when the control stops moving the mouse does the same? > > > > The most obvious way seems to keep track of the mouse position > > under MouseMove and, when you need to freeze it, just: > > > > Windows.Forms.Cursor.Position = PreviousPosition
Changing Color of Textbox on Hover
Offline application for reporting and collect data Report Viewer Asynchronous thread abort error Manage DataBase Best Approach When Saving a New Project No Response Redirect but something like Response Forward? Disable sort on specific columns with VB.NET datagrid SyncLock Required? Changing Color of TextBox on Hover - With Correct Examples!!! Error in displaying data grid |
|||||||||||||||||||||||