menu change runtime

Helo everybody!
I'm writing to ask you some advices....
I'm programming in Visual C++ (ver. 6.0), with MFC; in my application, I'm modifying the menu of the main frame window in runtime, such as:
CMainFrame* pMainFrame = (CMainFrame*)AfxGetApp()->GetMainWnd();
CMenu* pMenu = pMainFrame->GetMenu();

// modifications, like pMenu->GetSubMenu(2)->AppendMenu(MF_STRING|MF_ENABLED, ID_DISPLAY_IMAGE, nome);

pMainFrame->SetMenu( pMenu );
pMainFrame->DrawMenuBar();

My problem is that when I open several documents (2 or more), and I change the focus of a child window (i.e. I click on a lower child wnd to let it be close up), the menu change its appearance in the basic appearance (loaded during the initialization of the application); more exactly, I write in the sub menu the name of the open images and the menu shows, after the change of focus, a list of Image#1, Image#2, ... which is the basic form of the sub menu itself.

Any idea how to fix it??

Thank you all for your help!!
Topic archived. No new replies allowed.