How to register a global hotkey for your application in C#

How to register a global hotkey for your application in C#

Register a hotkey for your application that can be triggered even if your form is minimized and does not have focus. More »

How to download a file in C# (progressbar and download speed)

How to download a file in C# (progressbar and download speed)

Learn how to download files in C# while displaying the percentage and the download speed. More »

UDP hole punching implementation in C#

UDP hole punching implementation in C#

Learn how to implement UDP hole punching so you can make your clients life a lot easier by not forcing them to open ports on their end. More »

 

Host a process window inside your applications window

The following snippet will allow you to host the window of any application inside your own application. This isn’t a recommended practice but it’s a fun method that might spawn some interesting ideas.

In order to get this working we will need to pinvoke two Win32 functions, SetParent and SetWindowPos.

Place the following lines in your class


Now add our LoadApplication method which takes a string and an IntPtr value as an argument and will attempt to run the application and set our argument handle value as its parent.

And we are done! Now just call our LoadApplication method with the file you want its window to be in your application

The end result will be something like this
Process SetParent example

Share on FacebookTweet about this on TwitterShare on Google+Share on StumbleUponShare on LinkedInShare on RedditPin on PinterestShare on TumblrDigg thisPrint this pageEmail this to someone

4 Responses to Host a process window inside your applications window

  1. Abhijeet says:

    I have developed an app using MS Word (VSTO Addin) and has a child windows form inside the app. first MS Word Application gets launched and then the form. I want to set MS Word inside this form. I tried the same method as you mentioned but it did not worked.

    I do not want to create a windows form as a separate application and also cannot change the loading sequence in my App.

    Kindly help

  2. Steven says:

    Is there a way to do this while limiting the application within a grid or stackpanel? I’d like the external application to be docked within a grid I have on a specific tab in my application.

  3. mike says:

    How do you reverse this now? I am able to do the above but now need to be able to reverse it.

Leave a Reply

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