Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# .NET WinForm
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 14-Sep-11 9:10am
johnbMA532
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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[^]
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Create one class for API call
 

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

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

  Print Answers RSS
0 Zoltán Zörgő 185
1 Sergey Alexandrovich Kryukov 160
2 Peter Leow 100
3 CPallini 70
4 Ramza360 51
0 Zoltán Zörgő 80
1 the other paul 23
2 Shmuel Zang 10
3 Aarti Meswania 5
4 Member 11389991 -2


Advertise | Privacy | Mobile
Web02 | 2.8.150129.1 | Last Updated 14 Sep 2011
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100