我有這個代碼,現在讓我打開notepad.exe在WPF窗口內,問題是當我打開窗口,我看到記事本,但沒有在窗口內的完整大小,希望有人能幫助,謝謝:最大尺寸在wpf窗口中打開EXE
/// <summary>
/// Interaction logic for windows1.xaml
/// </summary>
public partial class windows1 : Window
{
public IntPtr MainWindowHandle { get; set; }
[DllImport("user32.dll", SetLastError = true)]
private static extern long SetParent(IntPtr hWndChild, IntPtr hWndNewParent);
//[DllImport("user32.dll", SetLastError = true)]
//private static extern int GetWindowLong(IntPtr hWnd, int nIndex);
public windows1()
{
InitializeComponent();
try
{
//External exe inside WPF Window
System.Windows.Forms.Panel _pnlSched = new System.Windows.Forms.Panel();
WindowsFormsHost windowsFormsHost1 = new WindowsFormsHost();
windowsFormsHost1.Child = _pnlSched;
this.gridtest.Children.Add(windowsFormsHost1);
ProcessStartInfo psi = new ProcessStartInfo("notepad.exe");
psi.WindowStyle = ProcessWindowStyle.Maximized;
Process PR = Process.Start(psi);
// true if the associated process has reached an idle state:
PR.WaitForInputIdle();
//System.Threading.Thread.Sleep(3000);
IntPtr hwd = PR.MainWindowHandle;
// loading exe to the wpf window:
SetParent(PR.MainWindowHandle, _pnlSched.Handle);
}
catch (Exception ex)
{
//Nothing...
}
}
}
你檢查出窗口樣式使記事本無國界(如果你願意),還試圖設置記事本的主窗口的狀態最大化? – Warty
我該如何設置windows狀態?以及如何檢查Windows風格,看到記事本無國界? – eran10
請問以下網站可以幫助你嗎... http://stackoverflow.com/questions/4743213/application-that-can-open-program-in-full-screen或http://stackoverflow.com/questions/14799691/ wpf-maximizing-borderless-window-by-taking-in-account-the-user-taskbar – bucketblast