Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

7
  • Related. Commented Mar 12 at 12:06
  • 1
    It sounds like you want snapping which is already available on Windows and customizable by Windows. Or utilities like Windows PowerToys Workspaces or FancyZones, which work on top of Windows features. You can't just lock another application's location and size. SetWindowsPos isn't enough - that API goes back to Windows 9x and doesn't handle the newer features Commented Mar 12 at 12:09
  • 3
    The PowerToys code is hosted on Github. You can check the code of eg the WorkspacesWindowArranger class or WindowsCreationHandler. Not only do they modify other app windows (using SetWindowPlacement, SetWindowsPos) but also listen for show/hide events so they can modify those "new" windows Commented Mar 12 at 12:13
  • I'm not sure what you mean by "open external applications within my own WinForms application". Windows have APIs for interacting with windows of other applications, but not all APIs are available in .Net So you will need to be very comfortable with the win32 API and P/Invoke if you want to do this yourself. I also imagine that it will be quite difficult to make this both easy to use and reliable. Commented Mar 12 at 12:32
  • I suggest changing the title to "How do I set the size and position of an external application's window?" or "How do I prevent an external application's main window from being moved or resized?" (These seem like different problems to me as well.) Commented Mar 13 at 17:56