【发布时间】:2018-03-26 12:11:09
【问题描述】:
您可以使用以下代码在 WinForm 中打开记事本:
public partial class Form1 : Form
{
[DllImport("user32.dll")]
static extern IntPtr SetParent(IntPtr hWndChild, IntPtr hWndNewParent);
public Form1()
{
InitializeComponent();
Process p = Process.Start("notepad.exe");
p.WaitForInputIdle(); // Allow the process to open it's window
SetParent(p.MainWindowHandle, this.Handle);
}
}
在 WPF 中 this.handle 无法识别。 this.Handle 的 WPF 版本是什么?
如何在 WPF 屏幕中没有关闭按钮的情况下全屏打开记事本?
【问题讨论】:
-
WPF 版本是
new System.Windows.Interop.WindowInteropHelper(this).Handle,其中this是 WPFWindow的实例。 -
@Evk 确实是这样,但嗯猜它不会在 WPF 中工作。记事本从 wpf 窗口中打开。
-
你达到你想要的了吗? @user7849697