Версия для печати темы
Нажмите сюда для просмотра этой темы в оригинальном формате
Форум программистов > Visual C++/MFC/WTL > Получить все открытые CMDIChildWnd


Автор: Rapalex 23.8.2007, 13:08
Мне нужно пробежаться по всем открытым фреймам (или view) и активировать нужный.

Автор: zkv 23.8.2007, 15:19
пример из MSDN (для CMDIFrameWnd::GetWindowMenuPopup() ), добавить нечего.
Код

// CMainFrame::OnActivateFirstMDIChild() is a menu command handler for
// CMainFrame class, which in turn is a CMDIFrameWnd-derived class.
// It looks for the caption of the first created MDI child window from
// the Window popup menu, and then activate the child window.
void CMainFrame::OnActivateFirstMDIChild() 
{
   // Get handle to the Window pop-up menu.
   CMenu* menubar = GetMenu();
   CMenu* wmenu = CMenu::FromHandle(GetWindowMenuPopup(menubar->GetSafeHmenu()));
   if (wmenu == NULL)
      return;
 
   // Get the caption of the first created MDI child window.
   CString caption;
   if (!wmenu->GetMenuString(AFX_IDM_FIRST_MDICHILD, caption, MF_BYCOMMAND))
      return;

   // Get the actual name of the first created MDI child window by 
   // getting rid of the number and space, e.g. "&1 MDI 1".
   int pos = caption.FindOneOf(" ");
   if (pos == -1)
      return;

   caption = caption.Right(caption.GetLength() - (pos + 1));

   // Get the CWnd* of the first created MDI child window by comparing
   // the caption of each MDI child window in the MDI application. 
   // Activate the first created MDI child window if found.
   CMDIChildWnd* child = MDIGetActive();
   do
   {
      CString str;
      child->GetWindowText(str);
      if (str == caption)
      {
         child->MDIActivate();        // or MDIActivate(child);
         break;
      }

      child = (CMDIChildWnd*) child->GetWindow(GW_HWNDNEXT);
   }
   while (child);
}

Автор: Rapalex 23.8.2007, 15:19
Ха, нешол решение, удокумента пробежался по всем представлениям... smile

Автор: zkv 23.8.2007, 15:21
Цитата(Rapalex @  23.8.2007,  15:19 Найти цитируемый пост)
удокумента пробежался по всем представлениям...

а как активировал вид?

Автор: Rapalex 23.8.2007, 16:13
Незнаю, я вызвал CMDIFrameWnd::MDIActivate вроде сработало.

Автор: zkv 23.8.2007, 16:27
Цитата(Rapalex @  23.8.2007,  16:13 Найти цитируемый пост)
Незнаю, я вызвал CMDIFrameWnd::MDIActivate вроде сработало.

я ступил, неверно понял задачу...

Powered by Invision Power Board (http://www.invisionboard.com)
© Invision Power Services (http://www.invisionpower.com)