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. View / Childframe activation

View / Childframe activation

Scheduled Pinned Locked Moved C / C++ / MFC
question
5 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.
  • P Offline
    P Offline
    Paul Belikian
    wrote on last edited by
    #1

    Hi, is there a function or message that is sent to a Childframe or view when it becomes active? In other words, I have a few MDI documents open and would like to be notified when the user selects one (it becomes the view that gets focus), or if one of the child's views becomes the active one. I need to know when the user selects between these views when they are selected, but not simply which one is the active view at any given time. Thanks!

    J 1 Reply Last reply
    0
    • P Paul Belikian

      Hi, is there a function or message that is sent to a Childframe or view when it becomes active? In other words, I have a few MDI documents open and would like to be notified when the user selects one (it becomes the view that gets focus), or if one of the child's views becomes the active one. I need to know when the user selects between these views when they are selected, but not simply which one is the active view at any given time. Thanks!

      J Offline
      J Offline
      Jose Lamas Rios
      wrote on last edited by
      #2

      Take a look at CWnd::OnMDIActivate -- jlr http://jlamas.blogspot.com/[^]

      P 1 Reply Last reply
      0
      • J Jose Lamas Rios

        Take a look at CWnd::OnMDIActivate -- jlr http://jlamas.blogspot.com/[^]

        P Offline
        P Offline
        Paul Belikian
        wrote on last edited by
        #3

        Too freaking simple! :mad: Thank you for the direction. I needed to tweak it a bit, but it is perfect! :) LRESULT CWinCTestFrame::OnActivate(WPARAM wParam, LPARAM lParam) { if(((HANDLE) wParam == this->m_hWnd) && (IsWindowVisible())) TRACE("ChildFrame - I'm Activated!\n"); return 0L; }

        J 1 Reply Last reply
        0
        • P Paul Belikian

          Too freaking simple! :mad: Thank you for the direction. I needed to tweak it a bit, but it is perfect! :) LRESULT CWinCTestFrame::OnActivate(WPARAM wParam, LPARAM lParam) { if(((HANDLE) wParam == this->m_hWnd) && (IsWindowVisible())) TRACE("ChildFrame - I'm Activated!\n"); return 0L; }

          J Offline
          J Offline
          Jose Lamas Rios
          wrote on last edited by
          #4

          Paul Belikian wrote: LRESULT CWinCTestFrame::OnActivate(WPARAM wParam, LPARAM lParam) Hmm... Since you are using MFC, a simpler approach would be as follows: In your class declaration :

          afx_msg void OnMDIActivate(BOOL bActivate, CWnd* pActivateWnd, CWnd* pDeactivateWnd);

          In your class implementation file:

          BEGIN_MESSAGE_MAP(CWinCTestFrame, [baseClass])
            //{{AFX_MSG_MAP(CWinCTestFrame)
            ON_WM_MDIACTIVATE()
            .
            .
            .
            //}}AFX_MSG_MAP
          END_MESSAGE_MAP()
           
          void CWinCTestFrame::OnMDIActivate(BOOL bActivate, CWnd* pActivateWnd, CWnd* pDeactivateWnd)
          {
            CMultiFrame_base::OnMDIActivate(bActivate, pActivateWnd, pDeactivateWnd);
            if (bActivate)
            TRACE("ChildFrame - I'm Activated!\n");();
          }

          bActivate will be TRUE or FALSE, depending on whether the child is being activated or deactivated, while pActivateWnd and pDeactivateWnd will point to the child being activated or deactivated, respectively. More details at MSDN[^] BTW, I don't think the call to IsWindowVisible() in your code is making any difference; 'visible' is not the same as 'active'. -- jlr http://jlamas.blogspot.com/[^]

          P 1 Reply Last reply
          0
          • J Jose Lamas Rios

            Paul Belikian wrote: LRESULT CWinCTestFrame::OnActivate(WPARAM wParam, LPARAM lParam) Hmm... Since you are using MFC, a simpler approach would be as follows: In your class declaration :

            afx_msg void OnMDIActivate(BOOL bActivate, CWnd* pActivateWnd, CWnd* pDeactivateWnd);

            In your class implementation file:

            BEGIN_MESSAGE_MAP(CWinCTestFrame, [baseClass])
              //{{AFX_MSG_MAP(CWinCTestFrame)
              ON_WM_MDIACTIVATE()
              .
              .
              .
              //}}AFX_MSG_MAP
            END_MESSAGE_MAP()
             
            void CWinCTestFrame::OnMDIActivate(BOOL bActivate, CWnd* pActivateWnd, CWnd* pDeactivateWnd)
            {
              CMultiFrame_base::OnMDIActivate(bActivate, pActivateWnd, pDeactivateWnd);
              if (bActivate)
              TRACE("ChildFrame - I'm Activated!\n");();
            }

            bActivate will be TRUE or FALSE, depending on whether the child is being activated or deactivated, while pActivateWnd and pDeactivateWnd will point to the child being activated or deactivated, respectively. More details at MSDN[^] BTW, I don't think the call to IsWindowVisible() in your code is making any difference; 'visible' is not the same as 'active'. -- jlr http://jlamas.blogspot.com/[^]

            P Offline
            P Offline
            Paul Belikian
            wrote on last edited by
            #5

            Thanks again! Your suggestion also looks cleaner :) and I'll do it the way you suggested. Jose Lamas Rios wrote: BTW, I don't think the call to IsWindowVisible() in your code is making any difference; 'visible' is not the same as 'active'. Yes, that's true, but in my application, when the view becomes 'active' it sends a message to the mainframe to trigger further action (it's a long story :^) ). The IsVisible call prevents the childframe from sending that message to the mainframe when the child is being closed. Once again, thank you for your help and responses! :-D Paul...

            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