Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. MDI - Is there an other way ??

MDI - Is there an other way ??

Scheduled Pinned Locked Moved C / C++ / MFC
tutorialquestion
3 Posts 3 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    Rene D
    wrote on last edited by
    #1

    Hi all, Currently I'm working on a program with (at this moment) 100 windows. In the app of the program I have this code - (x 100).

    m_pProg001Template = new CMultiDocTemplate(
    IDR_MENU,
    RUNTIME_CLASS(CDProg001Doc),
    RUNTIME_CLASS(CDProg001Frame),
    RUNTIME_CLASS(CDProg001View));
    AddDocTemplate(m_pProg001Template);

    m_pProg002Template = new CMultiDocTemplate(
    IDR_MENU,
    RUNTIME_CLASS(CDProg002Doc),
    RUNTIME_CLASS(CDProg002Frame),
    RUNTIME_CLASS(CDProg002View));
    AddDocTemplate(m_pProg002Template);

    etc, etc.. then ..

    OnCommand (ID_MENU_001, OnProg001)
    OnCommand (ID_MENU_002, OnProg002)

    (x 100) etc, etc..

    App::OnProg001() (x 100)
    {
    m_pProg001Template->OpenDocumentFile(NULL, TRUE);
    }

    etc, etc .. This doesn't look good, and gives a lot of code in the app. I have the feeling that there is a easier way to do this, maybe with 5 lines of code:-D , but I have no idea how to do this. Anybody?? Greetings Rene

    R R 2 Replies Last reply
    0
    • R Rene D

      Hi all, Currently I'm working on a program with (at this moment) 100 windows. In the app of the program I have this code - (x 100).

      m_pProg001Template = new CMultiDocTemplate(
      IDR_MENU,
      RUNTIME_CLASS(CDProg001Doc),
      RUNTIME_CLASS(CDProg001Frame),
      RUNTIME_CLASS(CDProg001View));
      AddDocTemplate(m_pProg001Template);

      m_pProg002Template = new CMultiDocTemplate(
      IDR_MENU,
      RUNTIME_CLASS(CDProg002Doc),
      RUNTIME_CLASS(CDProg002Frame),
      RUNTIME_CLASS(CDProg002View));
      AddDocTemplate(m_pProg002Template);

      etc, etc.. then ..

      OnCommand (ID_MENU_001, OnProg001)
      OnCommand (ID_MENU_002, OnProg002)

      (x 100) etc, etc..

      App::OnProg001() (x 100)
      {
      m_pProg001Template->OpenDocumentFile(NULL, TRUE);
      }

      etc, etc .. This doesn't look good, and gives a lot of code in the app. I have the feeling that there is a easier way to do this, maybe with 5 lines of code:-D , but I have no idea how to do this. Anybody?? Greetings Rene

      R Offline
      R Offline
      Rassman
      wrote on last edited by
      #2

      I never criticise another persons code, afteral. Displaying your code is a bit like displaying your underpants, you never really know if there's a skid mark showing. But, 100 windows in one application?, Lets just say it seemed a good idea at the time and tell the project leader it was only done to test the theory before going on to the release version, ok? If you still want 100 windows, you could have an array of doctemplates, CString sClasssName; for( j=0;j<100;j++) { sClassName = ArrayofClassNames[j]; m_pArrayofTemplates[j] = new CMultiDocTemplate( IDR_MENU, RUNTIME_CLASS(sClassName), RUNTIME_CLASS(CDProg002Frame), RUNTIME_CLASS(sClassName)); AddDocTemplate(m_pProg002Template); } I'm sure you get the gist (sorry have to rush this my German server has just gone awal). But, are you sure you need 100 windows? do you actually need 100 ActiveX windows displaying various information (whatever your app is) which you can create/show/hide/ etc as needed. shit shit even i can't get in my german server. better go sort it. We do it for the joy of seeing the users struggle.

      1 Reply Last reply
      0
      • R Rene D

        Hi all, Currently I'm working on a program with (at this moment) 100 windows. In the app of the program I have this code - (x 100).

        m_pProg001Template = new CMultiDocTemplate(
        IDR_MENU,
        RUNTIME_CLASS(CDProg001Doc),
        RUNTIME_CLASS(CDProg001Frame),
        RUNTIME_CLASS(CDProg001View));
        AddDocTemplate(m_pProg001Template);

        m_pProg002Template = new CMultiDocTemplate(
        IDR_MENU,
        RUNTIME_CLASS(CDProg002Doc),
        RUNTIME_CLASS(CDProg002Frame),
        RUNTIME_CLASS(CDProg002View));
        AddDocTemplate(m_pProg002Template);

        etc, etc.. then ..

        OnCommand (ID_MENU_001, OnProg001)
        OnCommand (ID_MENU_002, OnProg002)

        (x 100) etc, etc..

        App::OnProg001() (x 100)
        {
        m_pProg001Template->OpenDocumentFile(NULL, TRUE);
        }

        etc, etc .. This doesn't look good, and gives a lot of code in the app. I have the feeling that there is a easier way to do this, maybe with 5 lines of code:-D , but I have no idea how to do this. Anybody?? Greetings Rene

        R Offline
        R Offline
        Roger Allen
        wrote on last edited by
        #3

        When you create your doc templates, put the pointers into an array:

        m_pDocTemplate[0] = new CMultiDocTemplate(
        m_pDocTemplate[1] = new CMultiDocTemplate(
        m_pDocTemplate[2] = new CMultiDocTemplate(
        ... etc

        Then for you ID_MENU_001..ID_MENU_100 id's you need to map a command range

        ON_COMMAND_RANGE(ID_MENU_001, ID_MENU_100, OnNewDocument)

        void CYourApp::OnNewDocument(UINT nID)
        {
        m_pDocTemplate[nID-ID_MENU_001]->OpenDocumentFile(NULL, TRUE) ;
        }

        This should then open the right document type. Your ID_MENU_001...ID_MENU_100 id's need to be numbered consecutively for this to work. Roger Allen Sonork 100.10016

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups