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:
THANKS FOR READING. BEFORE YOU LEAVE, I NEED YOUR HELP.
I AM SPENDING MORE TIME THESE DAYS CREATING YOUTUBE VIDEOS TO HELP PEOPLE LEARN THE MICROSOFT POWER PLATFORM.
IF YOU WOULD LIKE TO SEE HOW I BUILD APPS, OR FIND SOMETHING USEFUL READING MY BLOG, I WOULD REALLY APPRECIATE YOU SUBSCRIBING TO MY YOUTUBE CHANNEL.
THANK YOU, AND LET'S KEEP LEARNING TOGETHER.
CARL