This is a migrated thread and some comments may be shown as answers.

Embed an application in a RadPane.

1 Answer 49 Views
This is a migrated thread and some comments may be shown as answers.
Top achievements
Rank 1
Oreades asked on 17 Mar 2016, 06:01 PM


I need to place an application window (for example, notepad.exe) embedded within a RadPane.

I've managed to do in a Window application but do not get into a RadPane.

XAML user control located in the RadPane:

<UserControl x:Class="EmbeddedApp"
    <StackPanel x:Name="AppContainer" />

[DllImport("user32.dll", SetLastError = true)]
private static extern long SetParent(IntPtr hWndChild, IntPtr hWndNewParent);
[DllImport("user32.dll", EntryPoint = "SetWindowLongA", SetLastError = true)]
public static extern int SetWindowLongA([System.Runtime.InteropServices.InAttribute()] System.IntPtr hWnd, int nIndex, int dwNewLong);
[DllImport("user32.dll", SetLastError = true)]
private static extern bool MoveWindow(IntPtr hwnd, int x, int y, int cx, int cy, bool repaint);
private const int GWL_STYLE = (-16);
private const int WS_VISIBLE = 0x10000000;
public EmbeddedApp()
    this.Loaded += new RoutedEventHandler(OnVisibleChanged);
/// <summary>
/// Create control when visibility changes
/// </summary>
/// <param name="e">Not used</param>
protected void OnVisibleChanged(object s, RoutedEventArgs e)
    // If control needs to be initialized/created
    if (_iscreated == false)
        // Mark that control is created
        _iscreated = true;
        // Initialize handle value to invalid
        _appWin = IntPtr.Zero;
            var procInfo = new System.Diagnostics.ProcessStartInfo(this.exeName);
            procInfo.WorkingDirectory = System.IO.Path.GetDirectoryName(this.exeName);
            // Start the process
            _childp = System.Diagnostics.Process.Start(procInfo);
            // Wait for process to be created and enter idle condition
            // Get the main handle
            _appWin = _childp.MainWindowHandle;
        catch (Exception ex)
            Debug.Print(ex.Message + "Error");
        // Put it into this form
        var helper = new WindowInteropHelper(Window.GetWindow(this.AppContainer));
        SetParent(_appWin, helper.Handle);
        // Remove border and whatnot
        SetWindowLongA(_appWin, GWL_STYLE, WS_VISIBLE);
        // Move the window to overlay it on this window
        MoveWindow(_appWin, 0, 0, (int)this.ActualWidth, (int)this.ActualHeight, true);


Thank you!

1 Answer, 1 is accepted

Sort by
Telerik team
answered on 21 Mar 2016, 07:00 AM

You can check the following example in our SDK Repository which demonstrates how to embed WinForms application inside RadDocking control:

Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
Asked by
Top achievements
Rank 1
Answers by
Telerik team
Share this question