Grant
Grant

Reputation: 11356

Obtain a window coordinates from processID or hWnd

does anyone know if you can get the coordinates of a window using the .NET framework or via pinvoking?

I would have the processID or mainwindowhandle.

Upvotes: 0

Views: 866

Answers (2)

G S
G S

Reputation: 36838

In Windows Forms API, form.Top and form.Left should do.

If all you have is the process Id, you can iterate through the process's widows using EnumWindowsProc windows API method. once you get the window's handle which you want, you can query for its size and position.

Upvotes: 1

Firoz
Firoz

Reputation: 7454

HI, you can use System.Windows.Forms.Control cr= System.Windows.Forms.Control.FromHandle(System.Diagnostics.Process.GetCurrentProcess().MainWindowHandle); now u can get location of that control.

Upvotes: 1

Related Questions