Can a Child Window of MDI have a menu item ? If yes, pls tell me how to do it with an example.Very Urgent.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Yes ,U certainly can.

Let say  U want to popup a view say TestView.
Do following things
Add a Dialog with style "child " & Border "none"
Add a class CTestView derived from CFormView

Declare this in Application.h file
CMultiDocTemplate* pDocTemplateForScrolling;

In the initinstance of the application
pDocTemplateForTest = new CMultiDocTemplate(
IDR_TEST, // Menu
RUNTIME_CLASS(CTestDoc),            RUNTIME_CLASS(CChildFrame), // custom MDI child frame
where CTestView is derived from CFormview

Let us say U have a menu item ViewTest in the app class
In the  ViewTest() function
void  CTestApp :: ViewTest()

BOOL CTestApp::CreateOrActivateView(CMDIFrameWnd* pMDIFrameWnd,CDocTemplate* pTemplate,CRuntimeClass* pViewClass)
CMDIChildWnd* pMDIActiveChild = (CMDIChildWnd*)pMDIFrameWnd->MDIGetActive();
CMDIChildWnd* pNewFrameWnd = NULL;
if(pMDIActiveChild != NULL)
CDocument* pDoc = pMDIActiveChild->GetActiveDocument();
CView *pView;
      POSITION pos;
      pos = pDoc->GetFirstViewPosition();
      pView = pDoc->GetNextView(pos);
      {                                      pView->GetParentFrame()->ActivateFrame();
      return TRUE;

pNewFrameWnd = ((CMDIChildWnd*)pTemplate->CreateNewFrame(pDoc,NULL));      pTemplate->InitialUpdateFrame(pNewFrameWnd,pDoc);
pNewFrameWnd = ((CMDIChildWnd*) pTemplate->OpenDocumentFile(NULL));
if(pNewFrameWnd == NULL)
      return FALSE;
      return TRUE;


This will display a new view with a menu IDR_Test
Change  pDocTemplateForScrolling
to  pDocTemplateForTest  eveywhere in the above given code snippet
Uh, doesn't this put a different menu on the active MDI Parent Frame depending on which MDI Child frame is active?  I thought gurukg wanted to put menus on each child frame window--on the child window itself, not on the frame.

..B ekiM
gurukg102498Author Commented:
Mu main aim is to create a menu iten for the child window and not on the main window(frame).Can anybody tell me how to do it ? It is very urgent requirement.
You can't. MDI Child Windows don't support menus.

If your requirement is an absolute must, your only alternative is to start rewriting the MDI framework supplied by Windows. You'll have to create your own top-level window, then manage phony MDI child frame windows yourself. YOu can give those menus.

But you'll need to work out all the notifications, management of the "Window" menu, and layout chorse by yourself.

..B ekiM

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
System Programming

From novice to tech pro — start learning today.