In C++ , how can I get the user to specify a point on the screen (X,Y) out of the app window?

StackOverflow https://stackoverflow.com/questions/23504166

Pergunta

I must find the coordinates of a point which is out of the application window.

I intend to have a button "Specify Point" and when the user clicks this button, their next mouseclick will be registered by the program as this desired point. The problem is I don't know how to implement this....Any ideas ?

Foi útil?

Solução

You can call SetCapture to direct mouse clicks from anywhere on the desktop to your window. Call ReleaseCapture after the click to return to normal.

If the user clicks on another application you will receive the click but the other application will also be activated, which you probably don't want. To avoid this, an alternative approach is to overlay the entire desktop with an always-on-top very nearly fully transparent window (a fully transparent window won't get clicks). Transparent windows are known as layered windows; use the WS_EX_LAYERED extended style to create one.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top