Teoz
Teoz

Reputation: 111

Get mouse coordinates relative to the active window

I don't understand how to get the coordinates relative to the active window... I have a program that keeps on refreshing a label which contains the coorinates of the mouse position, I want the coordinates to be relative to the active window. (ex. i start the program, i click on notepad -> the coordinates shown are relative to the notepad window). Thank you.

Upvotes: 2

Views: 1892

Answers (1)

Teoz
Teoz

Reputation: 111

Thanks to everyone, I reached to solve my problem using Blorgbeared tip... I get the window position with GetWindowRect, then i get the relative coordinates using Cursor.Position.X - rect.X and Cursor.Position.Y - rect.Y The coordinates are wrong of about 1/2 pixel but working, ty!

Upvotes: 2

Related Questions