1

How to insert a window of another application (for example Notepad) into my WinForm app? I am using the SetParent, but focus of my app disappears. If the embedded window set WS_CHILD style it does not receive focus.

int style = GetWindowLong(_childHWnd, GWL_STYLE);
RECT rect = new RECT();
GetClientRect(_parentHWnd, out rect);
SetParent(_childHWnd, _parentHWnd);
SetWindowPos(_childHWnd, IntPtr.Zero, 0, 0, rect.Width, rect.Height, 0);
SetWindowLong(_childHWnd, GWL_STYLE, style);
QUQ
  • 11
  • 1
  • I haven't used `SetParent` api before so I don't know the implications doing it. If you don't fully understand what an api function is doing my suggestion is don't do it. However here [SetParent function](http://msdn.microsoft.com/en-us/library/windows/desktop/ms633541%28v=vs.85%29.aspx) is some reading for the function and [here](http://stackoverflow.com/questions/5836176/docking-window-inside-another-window) something similar that might help you. Proceed at your discretion – γηράσκω δ' αεί πολλά διδασκόμε Dec 07 '14 at 22:07

0 Answers0