Click here to Skip to main content
15,881,092 members

Comments by Gian.girardelli (Top 1 by date)

Gian.girardelli 29-Dec-22 2:55am View    
@Mike Hankey thanks for the answer, but the problem is a little bit more complicate.
I'll try to explain better what I'm doing.
I'm developing a software for rendering a room in 3D, in my form I need to drag an element using the mouse and during the dragging, in OnMouseMove, I need to change the position of the mouse cursor, but without generate the corresponding message WM_MOUSEMOVE and the coresponding OnMouseMove.
I thought to your solution, but the probelm is that Windows generate events that contain not only the one generated by my "new position", but also the others that are in progress.

This is a snap of the code to set the cursor position in OnMouseMove.

protected override void OnMouseMove(MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
if (Cursor.Position.X < 500)
{
Debug.WriteLine(string.Format("X {0} Y {1}", Cursor.Position.X, Cursor.Position.Y));
Cursor.Position = new Point(Cursor.Position.X + 10, Cursor.Position.Y + 10);
}
}
}

What I see in the console when I move the mouse is:
X 188 Y 231
X 198 Y 241
X 211 Y 254
X 224 Y 267
X 234 Y 277
X 247 Y 290
X 261 Y 302
X 271 Y 312
X 286 Y 325
X 300 Y 338
X 310 Y 348
X 325 Y 361
X 339 Y 373
X 349 Y 383
X 365 Y 397
X 379 Y 408
X 389 Y 418
X 403 Y 430
X 418 Y 442
X 428 Y 452
X 442 Y 464
X 456 Y 476
X 466 Y 486
X 479 Y 498
X 492 Y 511
There's no stepping 10 pixels by 10 pixels, but a continuos moving ... as should be