b2科目四模拟试题多少题驾考考爆了怎么补救
b2科目四模拟试题多少题 驾考考爆了怎么补救

WPF实现MDI窗体的方法

电脑杂谈  发布时间:2016-04-17 13:47:21  来源:网络整理

你是否正在寻找关于mdi窗体的内容?让我把最俱价值的东西奉献给你:

WPF实现mdi窗体的方法

Posted on

第一:新建一个类(Class)

Win32Native.cs

代码如下:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace WpfApplication1
{
public class Win32Native
{
[System.Runtime.InteropServices.DllImport("user32.dll", EntryPoint = "SetParent")]
public extern static IntPtr SetParent(IntPtr childPtr, IntPtr parentPtr);
}
}

第二:新建两个窗体:

Window1.xaml

Window2.xaml

第三:Window1.xaml.cs中添加引用

using System.Windows.Interop;

第四:在Window1窗体中放上一个Button1

其事件如下:


private void button1_Click(object sender, RoutedEventArgs e)
{
Window2 w2 = new Window2();
w2.Show();

WindowInteropHelper parentHelper = new WindowInteropHelper(this);
WindowInteropHelper childHelper = new WindowInteropHelper(w2);

Win32Native.SetParent(childHelper.Handle, parentHelper.Handle);

testMdiWindow.WindowState = WindowState.Maximized;//加上这句可实现窗口加载时最大化,注意语句位置
}

WinForms实现方法较简单一些,

private void button1_Click(object sender, RoutedEventArgs e)
{
Window2 w2 = new Window2();
w2.MdiParent = this;
w2.Show();


本文来自CSDN博客,转载请标明出处:

以上就是关于mdi窗体的全部内容,相信你一定会非常满意,。


本文来自电脑杂谈,转载请注明本文网址:
http://www.pc-fly.com/a/jisuanjixue/article-1505-1.html

    相关阅读
      发表评论  请自觉遵守互联网相关的政策法规,严禁发布、暴力、反动的言论

      • 高春梅
        高春梅

        那就是统一之时

      • 崔臣
        崔臣

        不知道是什么品牌味道超级难喝零售假要比RIO便宜2元

      • 赵运鸿
        赵运鸿

        没钱拿不是应该的吗

      热点图片
      拼命载入中...