Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 946075
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T22:51:27+00:00 2026-05-15T22:51:27+00:00

My WinForms app uses Process.Start() to open files in their native app. I want

  • 0

My WinForms app uses Process.Start() to open files in their native app. I want to split the screen in half, showing my WinForms app on one half and the new process on the other. I know I can use Process.MainWindowHandle to get the window handle, but how can I set its size and position?

I imagine I have have to use some kind of Windows API, but which one and how? Since this is not really “in my wheelhouse”, I am unsure of whether (and how) I need to use different APIs on 64bit Windows.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T22:51:28+00:00Added an answer on May 15, 2026 at 10:51 pm

    The Windows API method in question is SetWindowPos. You can declare it like so:

    [DllImport("user32.dll")]
    private extern static bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int X, int Y, int cx, int cy, int uFlags);
    

    and read about it here:
    http://msdn.microsoft.com/en-us/library/ms633545.aspx

    Added

    Process.MainWindowHandle is the hWnd parameter you will use.
    hWndInsertAfter will probably be your own Form’s handle (Form.Handle).
    You can use the Screen type to access information about the desktop:
    http://msdn.microsoft.com/en-us/library/system.windows.forms.screen.aspx

    Added Thomas’ comment

    Make sure you WaitForInputIdle before calling SetWindowPos.

    Process process = Process.Start(...);
    if (process.WaitForInputIdle(15000))
        SetWindowPos(process.MainWindowHandle, this.Handle, ...);
    

    The declaration for SetWindowPos above works for both 32- and 64-bit Windows.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a winforms app that uses a strongly typed custom DataSet for holding
I have a winforms app that uses a UserControl. The user control's job is
we have a .NET 3.5 WinForms app that uses Linq2Sql to insert records into
Ok, I'm making a very basic vb.net winforms app, essentially you can drag files
I am working on a WinForms app that uses the ReportViewer control to show
Short Version: I have a WinForms app that uses a .NET 4.0 WebBrowser control
I have a WinForms app that uses the Settings feature of .NET 2, but
I'm working on a simple WinForms app that uses an .sdf database to store
I have a WinForms C# app which uses a SqlCommand to extract info from
My WinForms app uses a number of BackgroundWorker objects to retrieve information from a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.