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 UpdateAllViews

MDI UpdateAllViews

Scheduled Pinned Locked Moved C / C++ / MFC
questionannouncement
15 Posts 3 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.
  • T Tom Archer

    The point of doc/view and the UpdateAllViews feature is that you're storing the data in the document. When that data is updated, calling UpdateAllViews allerts all views working with that data that it has changed. Cheers, Tom Archer Inside C#,
    Extending MFC Applications with the .NET Framework It's better to listen to others than to speak, because I already know what I'm going to say anyway. - friend of Jörgen Sigvardsson

    E Offline
    E Offline
    EddieRich
    wrote on last edited by
    #3

    Well, consider Visual Studio. If you have 5 source files open ( the documents ), and you go and change the text color in the options menu, ALL the views will update. The color of the text being displayed in the view is common to ALL views. It is NOT part of the data.

    T 1 Reply Last reply
    0
    • E EddieRich

      :confused: If I modify a static variable in my derived CView class, let's say the text color, how can I make ALL views in my MDI App update to use the new color ? What I want is for "AllDocs" to "UpdateAllViews".

      N Offline
      N Offline
      Neville Franks
      wrote on last edited by
      #4

      RoboTed wrote: What I want is for "AllDocs" to "UpdateAllViews". Invalidate() the MDI Client window. If that doesn't work you could: a) iterate all docs and call UpdateAllView() for each one. b) iterate all MDI Client window.children and Invalidate each one. Neville Franks, Author of ED for Windows. Free Trial at www.getsoft.com

      E 1 Reply Last reply
      0
      • N Neville Franks

        RoboTed wrote: What I want is for "AllDocs" to "UpdateAllViews". Invalidate() the MDI Client window. If that doesn't work you could: a) iterate all docs and call UpdateAllView() for each one. b) iterate all MDI Client window.children and Invalidate each one. Neville Franks, Author of ED for Windows. Free Trial at www.getsoft.com

        E Offline
        E Offline
        EddieRich
        wrote on last edited by
        #5

        My problem is that I don't know alot about MFC. What is "the MDI Client window" and how do I get to it ? How do I "iterate all docs" ? Which class owns the docs ? If I can't find a function in the help files, then I won't know where to find it. There is no "GetFirstDocument" function, or a "GetFirstView", especially for an MDI app. All I am doing (for now) is handling a menu message ( change color ) which opens a CColorDialog and let's me pick a color. I want ALL my views to use the new color.

        N T 2 Replies Last reply
        0
        • E EddieRich

          My problem is that I don't know alot about MFC. What is "the MDI Client window" and how do I get to it ? How do I "iterate all docs" ? Which class owns the docs ? If I can't find a function in the help files, then I won't know where to find it. There is no "GetFirstDocument" function, or a "GetFirstView", especially for an MDI app. All I am doing (for now) is handling a menu message ( change color ) which opens a CColorDialog and let's me pick a color. I want ALL my views to use the new color.

          N Offline
          N Offline
          Neville Franks
          wrote on last edited by
          #6

          Here is some code to scan all views. If you want code to scan all docs or all MDI children let me know./** Run 'Scan_Func' for each Template.Document.View * * @param pTemplate Ptr to Template whose document -> views are are to be scanned. * If NULL scan Text windows. * @param Scan_Func Ptr to CEDTextView method to call for each view * @param iVar1 int to pass on to Scan_Func as param 1 * * @see <A HREF="d:\ED32\EDDoc.cpp#^CEDDoc::ScanDocs"> * @caller VwProperties(), VwRedraw() * * @return if Scan_Func returns false stop scanning and return current pCEDTextView, * else return NULL */ CEDTextView* // static CEDTextView::ScanViews( SECMultiDocTemplate* pTemplate, int(CEDTextView::*Scan_Func)( int ), int iVar1 ) { // TODO: change this to use GetDocument()->GetDocTemplate() and remove app code. // need docking view in own CEDOutputDoc. Also remove static from function // so GetDocument() can be called. if ( pTemplate == NULL ) { CEDApp* pApp = (CEDApp*)AfxGetApp(); ASSERT_VALID( pApp ); pTemplate = pApp->GetTemplate( IDR_EDTYPE ); // scan Text Windows } ASSERT( pTemplate != NULL ); // We iterate through each document for this template // and then each view for each document. POSITION Dpos = pTemplate->GetFirstDocPosition(); while ( Dpos != NULL ) { CEDDoc* pDoc = (CEDDoc*)pTemplate->GetNextDoc( Dpos ); if ( pDoc->DocGetVmb() != NULL ) { POSITION Vpos = pDoc->GetFirstViewPosition(); while ( Vpos != NULL ) { CEDTextView* pView = (CEDTextView*)pDoc->GetNextView( Vpos ); ASSERT( pView->IsKindOf( RUNTIME_CLASS( CEDTextView ) ) ); if ( pView->IsKindOf( RUNTIME_CLASS( CEDTextView ) ) ) // if Scan_Func returns false stop scanning and return current pCEDTextView, if ( !(pView->*Scan_Func)( iVar1 ) ) return pView; } } } return NULL; // scanned all views } // example scan function int CEDTextView::VwDraw( int iOpts ) { ..... } // example use CEDTextView::ScanViews( pTemplate, VwDraw, 0 );

          Neville Franks, Author of ED for Windows. Free Trial at www.getsoft.com

          E 1 Reply Last reply
          0
          • E EddieRich

            Well, consider Visual Studio. If you have 5 source files open ( the documents ), and you go and change the text color in the options menu, ALL the views will update. The color of the text being displayed in the view is common to ALL views. It is NOT part of the data.

            T Offline
            T Offline
            Tom Archer
            wrote on last edited by
            #7

            What you described was nothing like this. You described a piece of data belonging to one view whose change you wanted announced to other views. What you're comparing to in VS is a global setting used with all views. Cheers, Tom Archer Inside C#,
            Extending MFC Applications with the .NET Framework It's better to listen to others than to speak, because I already know what I'm going to say anyway. - friend of Jörgen Sigvardsson

            E 1 Reply Last reply
            0
            • E EddieRich

              My problem is that I don't know alot about MFC. What is "the MDI Client window" and how do I get to it ? How do I "iterate all docs" ? Which class owns the docs ? If I can't find a function in the help files, then I won't know where to find it. There is no "GetFirstDocument" function, or a "GetFirstView", especially for an MDI app. All I am doing (for now) is handling a menu message ( change color ) which opens a CColorDialog and let's me pick a color. I want ALL my views to use the new color.

              T Offline
              T Offline
              Tom Archer
              wrote on last edited by
              #8

              RoboTed wrote: There is no "GetFirstDocument" function, or a "GetFirstView", especially for an MDI app Instead of telling us what there isn't - when you clearly don't know - you might try following the advice of those that have done this. Cheers, Tom Archer Inside C#,
              Extending MFC Applications with the .NET Framework It's better to listen to others than to speak, because I already know what I'm going to say anyway. - friend of Jörgen Sigvardsson

              E 1 Reply Last reply
              0
              • T Tom Archer

                RoboTed wrote: There is no "GetFirstDocument" function, or a "GetFirstView", especially for an MDI app Instead of telling us what there isn't - when you clearly don't know - you might try following the advice of those that have done this. Cheers, Tom Archer Inside C#,
                Extending MFC Applications with the .NET Framework It's better to listen to others than to speak, because I already know what I'm going to say anyway. - friend of Jörgen Sigvardsson

                E Offline
                E Offline
                EddieRich
                wrote on last edited by
                #9

                "The point of doc/view and the UpdateAllViews feature is that you're storing the data in the document. When that data is updated, calling UpdateAllViews allerts all views working with that data that it has changed." Yes, I know that. I have used "UpdateAllViews". I get it. As I said before, I am asking how I can update ALL views in my App, not just the ones related to one document. Changing the text color has nothing to do with "the data in the document", it relates to how the view displays it. Therefore, the textcolor is a static member in my view class and has a static access function. Once I change the color variable, I need all the views in my App to redraw themselves. Simply calling UpdateAllViews will only update the views attached to that ONE document.

                T 1 Reply Last reply
                0
                • N Neville Franks

                  Here is some code to scan all views. If you want code to scan all docs or all MDI children let me know./** Run 'Scan_Func' for each Template.Document.View * * @param pTemplate Ptr to Template whose document -> views are are to be scanned. * If NULL scan Text windows. * @param Scan_Func Ptr to CEDTextView method to call for each view * @param iVar1 int to pass on to Scan_Func as param 1 * * @see <A HREF="d:\ED32\EDDoc.cpp#^CEDDoc::ScanDocs"> * @caller VwProperties(), VwRedraw() * * @return if Scan_Func returns false stop scanning and return current pCEDTextView, * else return NULL */ CEDTextView* // static CEDTextView::ScanViews( SECMultiDocTemplate* pTemplate, int(CEDTextView::*Scan_Func)( int ), int iVar1 ) { // TODO: change this to use GetDocument()->GetDocTemplate() and remove app code. // need docking view in own CEDOutputDoc. Also remove static from function // so GetDocument() can be called. if ( pTemplate == NULL ) { CEDApp* pApp = (CEDApp*)AfxGetApp(); ASSERT_VALID( pApp ); pTemplate = pApp->GetTemplate( IDR_EDTYPE ); // scan Text Windows } ASSERT( pTemplate != NULL ); // We iterate through each document for this template // and then each view for each document. POSITION Dpos = pTemplate->GetFirstDocPosition(); while ( Dpos != NULL ) { CEDDoc* pDoc = (CEDDoc*)pTemplate->GetNextDoc( Dpos ); if ( pDoc->DocGetVmb() != NULL ) { POSITION Vpos = pDoc->GetFirstViewPosition(); while ( Vpos != NULL ) { CEDTextView* pView = (CEDTextView*)pDoc->GetNextView( Vpos ); ASSERT( pView->IsKindOf( RUNTIME_CLASS( CEDTextView ) ) ); if ( pView->IsKindOf( RUNTIME_CLASS( CEDTextView ) ) ) // if Scan_Func returns false stop scanning and return current pCEDTextView, if ( !(pView->*Scan_Func)( iVar1 ) ) return pView; } } } return NULL; // scanned all views } // example scan function int CEDTextView::VwDraw( int iOpts ) { ..... } // example use CEDTextView::ScanViews( pTemplate, VwDraw, 0 );

                  Neville Franks, Author of ED for Windows. Free Trial at www.getsoft.com

                  E Offline
                  E Offline
                  EddieRich
                  wrote on last edited by
                  #10

                  Perfect !!! GetFirstDocPosition and GetNextDoc is exactlly what I was looking for !!! Thank You so much !!!!

                  N 1 Reply Last reply
                  0
                  • T Tom Archer

                    What you described was nothing like this. You described a piece of data belonging to one view whose change you wanted announced to other views. What you're comparing to in VS is a global setting used with all views. Cheers, Tom Archer Inside C#,
                    Extending MFC Applications with the .NET Framework It's better to listen to others than to speak, because I already know what I'm going to say anyway. - friend of Jörgen Sigvardsson

                    E Offline
                    E Offline
                    EddieRich
                    wrote on last edited by
                    #11

                    I said a "static" variable in the class. It does NOT belong to one view, it belongs ( is shared by ) ALL instances of that view class.

                    T 1 Reply Last reply
                    0
                    • E EddieRich

                      "The point of doc/view and the UpdateAllViews feature is that you're storing the data in the document. When that data is updated, calling UpdateAllViews allerts all views working with that data that it has changed." Yes, I know that. I have used "UpdateAllViews". I get it. As I said before, I am asking how I can update ALL views in my App, not just the ones related to one document. Changing the text color has nothing to do with "the data in the document", it relates to how the view displays it. Therefore, the textcolor is a static member in my view class and has a static access function. Once I change the color variable, I need all the views in my App to redraw themselves. Simply calling UpdateAllViews will only update the views attached to that ONE document.

                      T Offline
                      T Offline
                      Tom Archer
                      wrote on last edited by
                      #12

                      Then you need to use an object that is accessable across all your views/documents. The first one that comes to mind is the application object which can be obtained via AfxGetApp. By the way, unless you lose the attitude I doubt you'll get much more help around here. Cheers, Tom Archer Inside C#,
                      Extending MFC Applications with the .NET Framework It's better to listen to others than to speak, because I already know what I'm going to say anyway. - friend of Jörgen Sigvardsson

                      1 Reply Last reply
                      0
                      • E EddieRich

                        I said a "static" variable in the class. It does NOT belong to one view, it belongs ( is shared by ) ALL instances of that view class.

                        T Offline
                        T Offline
                        Tom Archer
                        wrote on last edited by
                        #13

                        You were not very clear about whether or not this was a single view type or if you had other view types. At any rate, people like myself freely give our time to help others as a gesture of community spirit. Your rudeness surely won't help you garner much help around here. Cheers, Tom Archer Inside C#,
                        Extending MFC Applications with the .NET Framework It's better to listen to others than to speak, because I already know what I'm going to say anyway. - friend of Jörgen Sigvardsson

                        E 1 Reply Last reply
                        0
                        • T Tom Archer

                          You were not very clear about whether or not this was a single view type or if you had other view types. At any rate, people like myself freely give our time to help others as a gesture of community spirit. Your rudeness surely won't help you garner much help around here. Cheers, Tom Archer Inside C#,
                          Extending MFC Applications with the .NET Framework It's better to listen to others than to speak, because I already know what I'm going to say anyway. - friend of Jörgen Sigvardsson

                          E Offline
                          E Offline
                          EddieRich
                          wrote on last edited by
                          #14

                          Sorry if I sound rude, or "have an attitude". I thought I was perfectly clear in the original question when I said -- What I want is for "AllDocs" to "UpdateAllViews" --. "Instead of telling us what there isn't - when you clearly don't know - you might try following the advice of those that have done this." There is no function called "GetFirstDocument". If I "clearly don't know", then maybe someone should tell Microsoft, becuase they neglected to put it in the help files. I would love nothing more than to follow your advice, that is why I originally posted the question. "Then you need to use an object that is accessable across all your views/documents. The first one that comes to mind is the application object which can be obtained via AfxGetApp." Sorry to be "rude" again, but that still doesn't answer the question. So now I have a pointer to CMyApp, ok, what do I do to get all the documents and UpdateAllViews ? My point here is that your not giving me advice, your giving me half answers that never solve the original problem. I apologize for my attitude, I did not intend to offend anyone, I just wanted to know how other applications update every view in the app. I wanted to know how other software engineers have implemented a " UpdateAllInstantiatedViewsInTheApp() " function.

                          1 Reply Last reply
                          0
                          • E EddieRich

                            Perfect !!! GetFirstDocPosition and GetNextDoc is exactlly what I was looking for !!! Thank You so much !!!!

                            N Offline
                            N Offline
                            Neville Franks
                            wrote on last edited by
                            #15

                            RoboTed wrote: Thank You so much !!!! Glad to be of help. Oh and thanks for the thankyou. Neville Franks, Author of ED for Windows. Free Trial at www.getsoft.com

                            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