Go WPF methods for implementing MDI Forms

Source: Internet
Author: User

(The effect is not very good, for reference only)

First: Create a new class win32native, introducing the Win32 external function.

The code is as follows:

public class Win32native
{
[System.Runtime.InteropServices.DllImport ("user32.dll", EntryPoint = "SetParent")]
public extern static IntPtr SetParent (IntPtr childptr, IntPtr parentptr);
}

Second: Create a new two form:

Window1.xaml

Window2.xaml

Third: Add references in Window1.xaml.cs

Using System.Windows.Interop;

IV: Put a Button1 in the Window1 form

The events are as follows:

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);
}

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

WinForms implementation method is simpler,

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

PS: Original address: http://blog.csdn.net/dotkit/article/details/4799055

Copy to Google TranslateTranslation Results

Search

Copy

Go WPF methods for implementing MDI Forms

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.