Hello.
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" xmlns:local="clr-namespace:I3TV.GAMA.WPF.UI.Media.Player.Player" d:DesignHeight="300" d:DesignWidth="300" mc:Ignorable="d"> <StackPanel x:Name="AppContainer" /></UserControl>[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(){ InitializeComponent(); 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; try { 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 _childp.WaitForInputIdle(); // 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!