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);
posted @ 2014-07-24 13:58  高_山_流_水  阅读(110)  评论(0)    收藏  举报