Home › Unified Service Desk › Win32API SetWindowPos Example
Unified Service Desk · Sep 12, 2017

Win32API SetWindowPos Example

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:

 

Leave a Reply

Your email address will not be published. Required fields are marked *

Carl de Souza
KEEP LEARNING. KEEP BUILDING.

Explore AI, agents & Microsoft technology.

I share practical ideas, tutorials, and videos about AI, AI agents, Microsoft technologies, and the Power Platform.