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. MDI current active view: how to?

MDI current active view: how to?

Scheduled Pinned Locked Moved C / C++ / MFC
architecturehelptutorialquestion
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.
  • G Offline
    G Offline
    Guy Lecomte
    wrote on last edited by
    #1

    Hi I have an MDI application which deal with 3 types of document: let's say IMAGE, TEXT, SHEET. this is a classical doc/view architecture with multidoct emplate. I'd like to have an modeless dialog which execute (when a button in this dialog is clicked) an action on the current topmost visible mdi child, only if it is an image. That means, if the current open window is a TEXT window, the button does nothing. But if it is a IMAGE window, it runs the process. How to get the actual topmost MDI view and its type? (in fact, I need a pointer to the actual topmost ImageView window) BTW I've tried to maintain a ImageView pointer, called *currentView, which is set to the actual active ImageView but it does not work well because when the user closes the ImageView, the pointer is not set to the next open ImageView window (in this case we suppose there are several imageview window open). Please, Help, I can't find a solution for those pb. Thank you very much in advance regards Guy LECOMTE

    J 1 Reply Last reply
    0
    • G Guy Lecomte

      Hi I have an MDI application which deal with 3 types of document: let's say IMAGE, TEXT, SHEET. this is a classical doc/view architecture with multidoct emplate. I'd like to have an modeless dialog which execute (when a button in this dialog is clicked) an action on the current topmost visible mdi child, only if it is an image. That means, if the current open window is a TEXT window, the button does nothing. But if it is a IMAGE window, it runs the process. How to get the actual topmost MDI view and its type? (in fact, I need a pointer to the actual topmost ImageView window) BTW I've tried to maintain a ImageView pointer, called *currentView, which is set to the actual active ImageView but it does not work well because when the user closes the ImageView, the pointer is not set to the next open ImageView window (in this case we suppose there are several imageview window open). Please, Help, I can't find a solution for those pb. Thank you very much in advance regards Guy LECOMTE

      J Offline
      J Offline
      Joaquin M Lopez Munoz
      wrote on last edited by
      #2

      The line

      CView* pView=((CMDIFrameWnd*)AfxGetApp()->m_pMainWnd)->MDIGetActive()->GetActiveView();

      gives you a pointer to the active view. Then, you can check wether the view is of IMAGE type with something like:

      if(pView->IsKindOf(RUNTIME_CLASS(CImageView))){
      //...
      }

      For this last check to work, CImageView must have a runtime-type declaration using DECLARE_DYNAMIC or a similar macro from several MFC provides you with: possibly, the MFC wizard has already done that for you (I don't remember), but in any case you'd better check it out. Joaquín M López Muñoz Telefónica, Investigación y Desarrollo Want a Boost forum in Code Project? Vote here[^]!

      G 1 Reply Last reply
      0
      • J Joaquin M Lopez Munoz

        The line

        CView* pView=((CMDIFrameWnd*)AfxGetApp()->m_pMainWnd)->MDIGetActive()->GetActiveView();

        gives you a pointer to the active view. Then, you can check wether the view is of IMAGE type with something like:

        if(pView->IsKindOf(RUNTIME_CLASS(CImageView))){
        //...
        }

        For this last check to work, CImageView must have a runtime-type declaration using DECLARE_DYNAMIC or a similar macro from several MFC provides you with: possibly, the MFC wizard has already done that for you (I don't remember), but in any case you'd better check it out. Joaquín M López Muñoz Telefónica, Investigación y Desarrollo Want a Boost forum in Code Project? Vote here[^]!

        G Offline
        G Offline
        Guy Lecomte
        wrote on last edited by
        #3

        Thanks a lot! That helped me and it solved my problem...partially. I explain: when I click the dialog button, now, everything is ok. I get the good window pointer etc...Fine.;) I call this sollution "from dialog to CView". Now I have the other problem "From CView to dialog". A modeless dialog is open and displays automatically some info of the current active topmost CImageView. What I need is to automatically maintain the current CImageView pointer and notify the dialog when this pointer changes. For example, when the user closes a CImageView window (and assuming there are several open CImageView and other CView windows) I'd like my dialog to be automatically notified by the new CView window and if it is a CImageView window the dialog should update its info. It is longer to explain than to see, but I'm sure you get it.:wtf: Thank a lot in advance Guy LECOMTE

        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