-1

I am able to get the window handle value of an application and to capture the whole window. but I need to capture only client rectangle of that Form/Window, so I need respective instance from the handle (either it is form or window).

Does anyone know how to achieve this?

Process[] p = Process.GetProcessesByName(fileName);
IntPtr handle = p[0].MainWindowHandle;
rene
  • 41,474
  • 78
  • 114
  • 152
Prithiv
  • 504
  • 5
  • 20
  • So you want the client rect of a window in another process? You could p/invoke GetClientRect() – Alex K. Jan 12 '18 at 11:53
  • Possible duplicate of [Capture screen of Window by handle](https://stackoverflow.com/questions/37931433/capture-screen-of-window-by-handle) – BugFinder Jan 12 '18 at 11:54
  • I have already tried GetClientRect() and ClientToScreen() methods from user32.dll. but not working – Prithiv Jan 12 '18 at 11:57
  • so that, i'm trying to get the form instance. So that i can use Form.ClientSize property – Prithiv Jan 12 '18 at 11:59
  • You simply cannot convert an external window into a Form instance. GetClientRect() is the correct approach, if your code does not work then that's another issue. – Alex K. Jan 12 '18 at 12:18

1 Answers1

-1

Yes.

Control.FormHandle(handler);

https://msdn.microsoft.com/en-us/library/system.windows.forms.control.fromhandle(v=vs.71).aspx

Oscar
  • 13,594
  • 8
  • 47
  • 75
  • I think, this will return control instance only, not Form or Window. because I tried this, it returns null. – Prithiv Jan 12 '18 at 11:51