mfc >> Question on MDI Apps

by William Gower » Thu, 27 Nov 2003 09:18:58 GMT

I have never done an MDI app before always SDI. I have seen programs like
Peachtree Accounting that have a menu called Maintain and in that menu they
have an item called Customers and when you click on Customers it pops open a
windows for maintaining information on Customers and in the Windows menu it
shows up as an item. I am wondering, are they using some kind of a view or
are they using a modeless dialog box. If they are using a view, how do you
display a view based upon a click on a menu item?




mfc >> Question on MDI Apps

by Scott McPhillips [MVP] » Thu, 27 Nov 2003 10:27:58 GMT






A view window does not have a titlebar or border. It is useful only
within another window that does have a titlebar and border, such as
CFrameWnd. So your choices are to create a new CFrameWnd with a view
inside it, or a modeless dialog. The dialog would be preferred if all
you have on it is controls. The frame window would be preferred if you
need drawing or scrolling or splitters inside it. With either choice
you would have to add it to the Windows menu dynamically.

--
Scott McPhillips [VC++ MVP]




mfc >> Question on MDI Apps

by William Gower » Thu, 27 Nov 2003 13:17:04 GMT

Ok if I am going to use Modeless Dialogs for my forms, how do I tell the app
that I don't need a MDI child window? and if I want my menu not to change
whether I have a MDI child window or not, do I make sure that both the
IDR_MAINFRAME and the MDI Child Window are the same structure?




like
they
open a
it
or
you




Question on MDI Apps

by William Gower » Fri, 28 Nov 2003 03:31:31 GMT

I am creating an MDI app that will have a variety of dialog boxes that will
be displayed from clicking on Menu items. ex. Customers, Vendors, Inventory
etc. I want to have the ability to have a single copy of each of these open
at the same time. ex. both the customer and inventory dialog box open at the
same time in the app. I also want to have them both listed in the Window
menu. Should I use a Modeless Dialog Box or should I use a FormView? If
you say a FormView, I know how to display a dialog box from a menu click but
how do you display a formview based on a menu click? Also if you say Dialog
boxes, how do I add the name of the dialog box to the Window menu? Also I
noticed that when I display a dialog box based on a menu click, the menu and
tool bar lose focus and gray out until I click them again. How can I have
them look like they still have focus even though the dialog box is
displayed?




Question on MDI Apps

by Scott McPhillips [MVP] » Fri, 28 Nov 2003 03:47:41 GMT





Modeless dialog boxes will let you open more than one at a time, such as
Customers, Vendors. There is no reason to use a FormView if a dialog
fits your needs.

You can add things to the Window menu with CMenu::InsertMenu or
CMenu::AppendMenu. Start with GetMenu and GetSubMenu in CMainFrame.
The MFC DynaMenu sample code should help.

--
Scott McPhillips [VC++ MVP]



Similar Threads

1. A Question, Hiding Child frame in MDI App.

Hi, everybody.

I need to hide child frame in MDI app.

But, I will use document and view in the child frame.

So, I've got to hide the child frame with no destruction.

ShowWindow( SW_HIDE ) makes the child frame just minimize.

Is it possible to hide child frame in MDI app?

I need your helps.

Help me~

2. integration MDI child views from VC i VB into one MDI App

3. MDI frame & MDI child window questions

Hello fellow Newsgroupies,

When an MDI child window is maximized within its MDI frame window the
title of the child window is wrapped in square brackets and added to
the end of the frame windows title.

Is there anyway to prevent this from happening?

I want everything else to happen as normal except for the child title
to be added to the frame title.

Many thanks,

'Newsgroupie'
England

4. newbie question: embedding Python into a C++ app and calling app functions

5. Scope of Child Window in MDI app

I am writing an MDI app that uses a document manager class 
to keep track of opened child windows.  I want the user to 
be able to close a child window, but then re-open the 
window from the "Window" menu if they want.

What happens to the child window after it is closed?  Even 
though my document manager maintains the instance of the 
child and displays the name in the menu, when I try to use 
the show() method or the activate() method on a closed 
child, nothing happens.

Can anyone help me with this?

Some of the code is below:

In the load event handler for the child, I register the 
child with the following code-

DocumentManager.Current.RegisterDocumentView(this);


Here is the DocumentManager Class:

public class DocumentManager
{
    public DocumentManager()
     {}
    
    private static DocumentManager current;
    private ArrayList documents = new ArrayList();

    public static DocumentManager Current
    {get{return current;}}


    public ArrayList Documents
    {get{return documents;}}

    [STAThread()] static void Main()
    {
        current = new DocumentManager();
        ///instantiate the parent window
        PunchDocumentView view = new PunchDocumentView();
        view.Show();
        Application.Run();

    public void RegisterDocumentView (frmChild view)
    {
        Documents.Add(view);
    }
}

The popup event handler for the parent window creates the 
menu with all documents currently in the manager:

private void menuWindow_Popup(object sender, 
System.EventArgs e)
{
    menuWindow.MenuItems.Clear();
    int ordinal = 1;
    foreach (frmChild view in 
DocumentManager.Current.Documents)
    {
        WindowMenuItem item = new WindowMenuItem();
        menuWindow.Menuitems.Add(item);
        ordinal++;

And finally the WindowMenuItem class constructs the items 
to be displayed in the menu.  The overridden OnClick event 
handler is where I am trying to display the closed form, 
but it isn't working:

public class WindowMenuItem : System.Windows.Forms.MenuItem
{
    public frmChild View;

    public WindowMenuItem(int index, frmChild view)
    {
        View = view;
        Text = string.Format("{0}{1}", index, View.Text)
    }

    protected override void OnClick(System.EventArgs e)
    {
        View.Show();       ///These 2 methods don't appear
        View.Activate();   ///to do anything if the child
                           ///is closed
    }

}

6. How to access control in child form (MDI app) - CSharp/C#

7. Adding VB6 Forms(in an ActiveX DLL) to a C# app as MDI Child windows

I have a number of VB6 ActiveX DLL's that contain forms. The fornt end
is VB6 at this point and the forms are dispalyed as MDI child windows.
I am attempting to convert the front end to C# and would like to use
these forms.

I have been able to load the forms and set the parent, but the C# app
seems to hang once the form is added. The forms are modal.

I have seen a number of posts related to this topic. I am not sure
that this is the best method.

Any ideas or suggestions would be appreciated.

8. Windows Menu in MDI app. - CSharp/C#