Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. 890901 - getting the currently active child frame

890901 - getting the currently active child frame

Scheduled Pinned Locked Moved C / C++ / MFC
question
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • I Offline
    I Offline
    ilostmyid2
    wrote on last edited by
    #1

    hi what's the best method to get the currently active child frame window/ currently active view/ or document? consider we're in one of children of main frame or their children and have no access to any window.

    N 1 Reply Last reply
    0
    • I ilostmyid2

      hi what's the best method to get the currently active child frame window/ currently active view/ or document? consider we're in one of children of main frame or their children and have no access to any window.

      N Offline
      N Offline
      Nuri Ismail
      wrote on last edited by
      #2

      Here is what use in my MDI applications:

      // First get the MDI frame window
      CMDIFrameWnd* pFrame = (CMDIFrameWnd*)AfxGetApp()->m_pMainWnd;

      // !Here we get the active MDI child window!
      CMDIChildWnd* pChild = (CMDIChildWnd*)pFrame->GetActiveFrame();

      // Alternatively you can use
      // CMDIChildWnd* pChild = pFrame->MDIGetActive();

      // !Get the active view attached to the active MDI child window!
      CMyView* pView = (CMyView*)pChild->GetActiveView();

      // !Get the active document!
      CMyDoc* pDoc = (CMyDoc*)pChild->GetActiveDocument();

      :)

      I 1 Reply Last reply
      0
      • N Nuri Ismail

        Here is what use in my MDI applications:

        // First get the MDI frame window
        CMDIFrameWnd* pFrame = (CMDIFrameWnd*)AfxGetApp()->m_pMainWnd;

        // !Here we get the active MDI child window!
        CMDIChildWnd* pChild = (CMDIChildWnd*)pFrame->GetActiveFrame();

        // Alternatively you can use
        // CMDIChildWnd* pChild = pFrame->MDIGetActive();

        // !Get the active view attached to the active MDI child window!
        CMyView* pView = (CMyView*)pChild->GetActiveView();

        // !Get the active document!
        CMyDoc* pDoc = (CMyDoc*)pChild->GetActiveDocument();

        :)

        I Offline
        I Offline
        ilostmyid2
        wrote on last edited by
        #3

        oh thanks! i was mistaking:

        CFrameWnd \*pFrameWnd = GetTopLevelFrame();
        CView \*pView = pFrameWnd->GetActiveView();
        

        and i wondered why it returned NULL. now i changed it into:

        Ct2View *AcToolCtrl::pr_getActiveView()
        {
        CView *pView = GetTopLevelFrame()->GetActiveFrame()->GetActiveView();
        ASSERT_KINDOF(Ct2View, pView);
        return (Ct2View *)pView;
        }

        and it worked. :)

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups