Embed an application in a RadPane.

2 posts, 0 answers
  1. Oreades
    Oreades avatar
    4 posts
    Member since:
    Nov 2013

    Posted 17 Mar 2016 Link to this post


    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!

  2. Yana
    Yana avatar
    4970 posts

    Posted 21 Mar 2016 Link to this post


    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.
Back to Top