CompuServe Thread

#Window menu

2 messages in this thread
#30220From: Paul MindrupJul 7, 1994 11:58 PM
I need some information about the Window menu, not just any Windows menu, but the default menu which appears just to the left of the Help menu. How do the names of windows get added to it? Where does this occur? How can I do this myself? TIAFAH. -Paul
#30261From: Peter GlickJul 8, 1994 7:53 AM
Hi Paul – I just went through this exercise and hacked together the following code to display and add a check beside the current top window. CGrayFormView is derived from CFormView. GetNextView is a routine to find all the active views. This varies on how one keeps track them. I used the OnUpdateCascade event to trigger the code, as I included "Cascade" and "Tile" in the &Window pulldown. Finally, I added 6 "ID_NEXT_WINDOWn" items to the menu for placemarkers. They are deleted and replaced by active window names every time the pulldown occurs. In the message map: ON_COMMAND_EX(ID_NEXT_WINDOW1, OnNextWindow) ON_COMMAND_EX(ID_NEXT_WINDOW2, OnNextWindow) . . ON_COMMAND_EX(ID_NEXT_WINDOW6, OnNextWindow) void CGrayFormView::OnUpdateCascade(CCmdUI* /*pCmdUI*/) { // TODO: Add your command update UI handler code here CView* pView; CString nextWinText, thisWinText; CMenu* pMenu = m_mainFrame->GetMenu(); UINT nItems = pMenu->GetMenuItemCount(); GetParent()->GetWindowText(thisWinText); //Get this window title CString menuString; for (UINT nIDItem = 0; nIDItem < nItems; nIDItem++) { //Locate, by position, the "Window" menu item pMenu->GetMenuString(nIDItem, menuString.GetBuffer(30), 30, MF_BYPOSITION); if (menuString == "&Window") { m_pMenu = pMenu->GetSubMenu(nIDItem); //Get CMenu object for popup nItems = m_pMenu->GetMenuItemCount(); //Get count of items in popup for (int i=nItems; i>2; i–) //Dump all previously added menus items m_pMenu->RemoveMenu(i, MF_BYPOSITION); POSITION pos = m_pDocument->GetFirstViewPosition(); i = ID_NEXT_WINDOW1; while (pos != NULL && i <= ID_NEXT_WINDOW6) //Get all active window views { if ((pView = m_theDoc->GetNextView(pos)) != NULL) { ASSERT(pView->IsKindOf(RUNTIME_CLASS(CGrayFormView))); pView->GetParent()->GetWindowText(nextWinText); m_pMenu->AppendMenu(nextWinText == thisWinText ? MF_CHECKED : 0, i++, nextWinText); //Append next view title } } } } m_mainFrame->DrawMenuBar (); } Clicking on any of the items in the pulldown calls OnNextWindow where you add the code to locate and call BringWindowToTop() to BringWindowToTop. Simple. Hope this does it for you… Pete