MDI - Is there an other way ??
-
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
-
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
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.
-
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
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(
... etcThen 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