Click here to Skip to main content
15,124,353 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear All,
I have a MFC MDI project where in on start a maximised MDI child window is created. Later the user can create more MDI children. It is observed that when more children (12 of them) are created by OnFileNew() the existing maximized MDI child is restored and we see the restored mdi child window on screen.
Is there a way to stop the restoring of the existing maximized MDI child window.
I have got screenshot which shows the problem.

Thanks and Regards,
Rakesh

What I have tried:

I have tried creating the new children in hide mode (SW_HIDE). It didnt work. I tried creating the new children in very small size and outside the mdi main frame client area.
I have tried putting the existing window on top
(
pAnimView->SetWindowPos(&CWnd::wndTop, 0, 0, 0, 0,SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
)
and then making calls to OnFileNew();
Nothing worked.
Posted
Updated 1-May-17 8:03am
v2

1 solution

You must carefully implement the OnNewFile command handler. Renumbering or renaming the IDs is a common trap for messing up the message handling.

Check that you create a new child window object and not only re-run the commands with the actual object.
   
Comments
Member 11380615 1-May-17 23:57pm
   
ID_FILE_NEW is mapped to OnFileNew1 . Which is what the system calls when creating the first mdi child window. When user creates new mdi child windows OnFileNew is used. Both OnFileNew and OnFIleNew1 are functions in theApp.

void CMarkBullNewVApp::OnFileNew1()
{
tagPlot ltempPlot;
theApp.Is_Graph_Data_3D = ANIMATION_WIN;
ltempPlot.WinCount = 0;
ltempPlot.Is_Graph_Data_3D = ANIMATION_WIN;
ltempPlot.Graph_Type = 0;// ii++;
ltempPlot.WinViewMap = 1;// lnumPlotCount[ii];
ltempPlot.RowCol[0] = 0;// DataColumnInt[jj];
strncpy(ltempPlot.PlotLegend[0], "0", 200);
ltempPlot.m_szXCaption[0] = "0";// m_szXCaption[0];
ltempPlot.m_szYCaption[0] = "0";// m_szYCaption[0];
ltempPlot.DirectionPlus[0] = "0";// DirectionPlus[0];
ltempPlot.DirectionMinus[0] = "0";// DirectionMinus[0];
theApp.plotList.clear();
theApp.plotList.push_back(ltempPlot);
CWinAppEx::OnFileNew(); // call base class method and / or...
// ...add other tasks here.
}


void CMarkBullNewVApp::OnFileNew()
{
CWinAppEx::OnFileNew(); // call base class method and / or...
}

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




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900