Click here to Skip to main content
15,867,765 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
See more:
Hi:

How do I create an MDI-like panel framework to embed in an existing MDI Child window in .Net winforms?

Our current application is built using a .Net winforms MDI framework.

I'd like to be able to embed a panel in an MDI Child. The panel itself would behave exactly like an MDI parent with the capability of adding child controls the panel. This should include the ability to resize, move, position, max/min the child windows within this new panel control. Users should be able to move freely within the "panel."

The easiest solution would be to embed a new MDI parent (as the panel) within the MDIChild control. I know that this approach is not possible (at least directly). I really would like to avoid writing my own home grown custom MDI framework for the panel.

Is there an easy approach that I'm missing here?

Are there any existing implemetations, open source solutions, design patterns 3rd party controls which already support what I'm trying to do? Although we are winforms based, I wouldn't be opposed to using WPF for this solution, provided that I can embed the new "panel" within an existing MDI Child window.
(Not sure if that's possible or not.).


Our current applications is a C#/.Net/winforms solution based in VS 2010.

Thanks,
JohnB
Posted

You can achieve this using windows API call,Check this discussion in MSDN


http://social.msdn.microsoft.com/Forums/en-US/winforms/thread/de2f86f4-8f81-4f74-a355-cde8e1c37489[^]
 
Share this answer
 
Create one class for API call


C#
using Microsoft.VisualBasic;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Diagnostics;
using System.Runtime.InteropServices;
public class Win32API
{
    [DllImport("user32", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
    public static extern bool ShowWindow(System.IntPtr hWnd, int nCmdShow);
    [DllImport("user32", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
    public static extern System.IntPtr SetParent(System.IntPtr hWndChild, System.IntPtr hWndNewParent);
    [DllImport("user32", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
    public static extern int SetForegroundWindow(System.IntPtr hwnd);

    public static bool ShowWindowAPI(System.IntPtr hWnd, int nCmdShow)
    {
        return ShowWindow(hWnd, nCmdShow);
    }

    public static System.IntPtr SetParentAPI(System.IntPtr hWndChild, System.IntPtr hWndNewParent)
    {
        return SetParent(hWndChild, hWndNewParent);
    }
}



To load the MDI Form as children
MDIWindowForm frm = new MDIWindowForm();
// use the API call instead of frm.MDIParent assignment 
Win32API.SetParent(frm.Handle, this.Handle);
Win32API.ShowWindow(frm.Handle, 1);
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900