[Newbie] Opening two child windows on startup - Programmer

This is a discussion on [Newbie] Opening two child windows on startup - Programmer ; Hi Again, I have created a default-setting MDI application using the wizard, and want to modify it so that two child windows are opened when the application loads. However, I cannot seem to find where abouts in the project source ...

+ Reply to Thread
Results 1 to 2 of 2

Thread: [Newbie] Opening two child windows on startup

  1. [Newbie] Opening two child windows on startup

    Hi Again,

    I have created a default-setting MDI application using the wizard, and
    want to modify it so that two child windows are opened when the
    application loads.

    However, I cannot seem to find where abouts in the project source
    files the initial child frame is created - can anyone point it out to
    me please?

  2. Re: [Newbie] Opening two child windows on startup

    > However, I cannot seem to find where abouts in the project source
    > files the initial child frame is created - can anyone point it out to
    > me please?


    The child frame is created inside CWinApp::ProcessShellCommand
    which is called from your application's InitInstance method. The
    CCommandLineInfo object passed to this method determines what
    is done inside. By default its m_nShellCommand member is set to
    FileNew which makes ProcessShellCommand create a child frame.

    > I have created a default-setting MDI application using the wizard, and
    > want to modify it so that two child windows are opened when the
    > application loads.


    As far as I've understand your intent from your previous posting you'd
    like to have another child frame that works on the same document
    object as the first one (same data). The easiest way to achieve this is
    to issue a ID_WINDOW_NEW command as is done when the user
    selects the "New Window" menu item. Something like this in your
    application's InitInstance method:

    if (!ProcessShellCommand(cmdInfo)) // document object and first child frame created
    return FALSE;
    m_pMainWnd->OnCmdMsg(ID_WINDOW_NEW, 0, NULL, NULL); // second child frame created (same document object)

    Note that ProcessShellCommand does not only create the first child
    frame but also a document object. Sending the ID_WINDOW_NEW
    command however creates a child frame that works on the document
    object associated with the child frame that was active at the time the
    command was issued. It does NOT create another document object.

    If you'd like to have another child frame / document object pair you'd
    have to modify the code above like this:

    if (!ProcessShellCommand(cmdInfo)) // first document object and child frame created
    return FALSE;
    OnFileNew(); // second document object and child frame created

    Regards,
    Frank



+ Reply to Thread