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 4599148
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T23:29:57+00:00 2026-05-21T23:29:57+00:00

I have a winform application (.NET 2.0 C#). From this application, I want to

  • 0

I have a winform application (.NET 2.0 C#). From this application, I want to start another process (another winform application) and dock it to my window (or at least make it look like it is docked). So far, I can only find information about docking controls, not windows in separate processes. My first thought is to get the handle of the window and use unmanaged system calls to set the height/width and position of the window to my docking area. But before I got started, I wanted to check to see if any of you good people have done something similar. I have access to the source code of the application I want docked but would rather not make any changes if I can avoid it. I have complete programming control over what will be the parent application. Any advice? Thanks in advance!

  • 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-21T23:29:58+00:00Added an answer on May 21, 2026 at 11:29 pm

    The solution I have used before is to set the application window as a child of the control you want to dock it in.

    using System.Diagnostics;
    using System.Runtime.InteropServices;
    
    private Process pDocked;
    private IntPtr hWndOriginalParent;
    private IntPtr hWndDocked;
    
    [DllImport("user32.dll")]
    public static extern IntPtr SetParent(IntPtr hWndChild, IntPtr hWndNewParent);
    
    [DllImport("user32.dll", SetLastError = true)]
    public static extern bool MoveWindow(IntPtr hWnd, int X, int Y, int nWidth, int nHeight, bool bRepaint);
    
    private void dockIt()
    {
        if (hWndDocked != IntPtr.Zero) //don't do anything if there's already a window docked.
            return;
        hWndParent = IntPtr.Zero;
    
        pDocked = Process.Start(@"notepad");
        while (hWndDocked == IntPtr.Zero)
        {
            pDocked.WaitForInputIdle(1000); //wait for the window to be ready for input;
            pDocked.Refresh();              //update process info
            if (pDocked.HasExited)
            {
                return; //abort if the process finished before we got a handle.
            }
            hWndDocked = pDocked.MainWindowHandle;  //cache the window handle
        }
        //Windows API call to change the parent of the target window.
        //It returns the hWnd of the window's parent prior to this call.
        hWndOriginalParent = SetParent(hWndDocked, Panel1.Handle);
    
        //Wire up the event to keep the window sized to match the control
        Panel1.SizeChanged += new EventHandler(Panel1_Resize);
        //Perform an initial call to set the size.
        Panel1_Resize(new Object(), new EventArgs());
    }
    
    private void undockIt()
    {
        //Restores the application to it's original parent.
        SetParent(hWndDocked, hWndOriginalParent);
    }
    
    private void Panel1_Resize(object sender, EventArgs e)
    {
        //Change the docked windows size to match its parent's size. 
        MoveWindow(hWndDocked, 0, 0, Panel1.Width, Panel1.Height, true);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

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.