Como centralizar o cursor do Mouse em um objeto? - How to center the Mouse cursor on an object?

Gabriel Near 1 Reputation point
2021-02-05T19:28:54.237+00:00

[PT-BR]
Ois, eu estou fazendo um aplicativo e nesse aplicativo estou fazendo uma borda personalizada... Então fiz um sistema que permite que o usuário possa movimentar o formulário com o mouse, e depois um sistema de maximização (Não é "WindowState"). O meu objetivo era que toda vez em que o formulário estiver maximizado e ela tentar movimentar o formulário o aplicativo restaura a resolução do formulário pra normal e então ela consiga movimentar o formulário sem precisar soltar o mouse, deu certo porém dependendo de onde ela pegar no painel o formulário sai da tela porém se a pessoa pegar no meio ela consegue movimentar normal. Eu queria saber como eu faço (em C#) uma forma de centralizar o cursor do mouse independentemente se ela pegou nos cantos ou no meio do painel pra evitar esse problema, alguém sabe?

[EN-US]
Hi, I'm making an application and in this application I'm making a custom border ... So I made a system that allows the user to move the form with the mouse, and then a maximization system (It is not "WindowState"). My goal was that every time the form is maximized and she tries to move the form, the application restores the form's resolution to normal and then she can move the form without releasing the mouse, it worked but depending on where she grabs the panel the form leaves the screen but if the person picks it up in the middle he can move normally. I was wondering how I do (in C #) a way to center the mouse cursor regardless of whether it caught on the corners or in the middle of the panel to avoid this problem, does anyone know?

C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,410 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Castorix31 82,206 Reputation points
    2021-02-05T22:47:05.927+00:00

    So I made a system that allows the user to move the form with the mouse, and then a maximization system (It is not "WindowState"). My goal was that every time the form is maximized and she tries to move the form, the application restores the form's resolution to normal and then she can move the form without releasing the mouse,

    You can let Windows do it with WM_NCHITTEST (move window with mouse, maximize on double-click, restore when moving on maximized, ...)
    I cannot post code, a link to a test : Test WM_NCHITTEST

    0 comments No comments