dcsimg
Results 1 to 2 of 2

Thread: Embed an application into a WPF

  1. #1

    Thread Starter
    Member
    Join Date
    Nov 2016
    Posts
    35

    Embed an application into a WPF

    Hi there,

    I'm in the process of porting my project to WPF.
    I'm trying to launch an application (SmatraPDF) in a SlackPanel within my WPF program that has got several controls.

    Code:
    {
    	/// <summary>
    	/// Interaction logic for Window1.xaml
    	/// </summary>
    	public partial class Window1 : Window
    	{
    		public Window1()
    		{
    		InitializeComponent();
    			
    		this.PreviewKeyDown += new KeyEventHandler(HandleEsc);
    		}
    		
    	        private void HandleEsc(object sender, KeyEventArgs e)
    {
                          if (e.Key == Key.Escape)
                          Close();
                         if (e.Key == Key.F1)
        	             WindowState = WindowState.Minimized;
    }
    	
    	           [DllImport("user32.dll")]
                       static extern IntPtr SetParent(IntPtr hwc, IntPtr hwp);
    	
    		  void button1_Click(object sender, RoutedEventArgs e)
    		{
    		
    		 Process p = Process.Start("Path_to_SumatraPDF.exe");
    		 p.WaitForInputIdle();
    		 SetParent(p.MainWindowHandle, StackPanel.Handle);
    
    		}	
    		
    	}
    }
    ... but to no avail as I'm getting the following error:

    Code:
    'System.Windows.Controls.StackPanel' does not contain a definition for 'Handle' and no extension method 'Handle' accepting a first argument of type 'System.Windows.Controls.StackPanel' could be found (are you missing a using directive or an assembly reference?) (CS1061) 
    Could anyone please give me a hint?

  2. #2

    Thread Starter
    Member
    Join Date
    Nov 2016
    Posts
    35

    Re: Embed an application into a WPF

    I was able to get a lot further over here.
    Moving to CefSharp anyway .....

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width