WPF 窗口相关
1.在WPF中设置Window类窗口为子窗口的一种方法
public class Win32Native { [System.Runtime.InteropServices.DllImport("user32.dll", EntryPoint = "SetParent")] //主要调用了windows API public extern static IntPtr SetParent(IntPtr childPtr,IntPtr parentPtr); } Window2 w2 = new Window2(); w2.Show(); WindowInteropHelper parentHelper = new WindowInteropHelper(this); //WindowInteropHelper可以获取窗口的句柄 WindowInteropHelper childHelper = new WindowInteropHelper(w2); Win32Native.SetParent(childHelper.Handle,parentHelper.Handle);

浙公网安备 33010602011771号