We will continue on from a previous post to show how to use SetWindowPos.
In our app, we are embedding a console app into WPF. However, we are not setting the window position, so it defaults to where the window is:
To set the position, use SetWindowPos. We will set the coordinates to 0, 0 and use Win32API.SWP_NOSIZE to ensure the window isn’t resized:
Win32API.SetWindowPos(cmdProcess.MainWindowHandle, Win32API.HWND_TOP, 0, 0, -1, -1, Win32API.SWP_NOSIZE);
Running this, we can see the window has been positioned correctly: