CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    May 1999
    Posts
    20

    How can I change the default view title in a MDI app

    Hi!

    When I use doc-view in a MDI app, there is
    an automatic title for each view (i.e. if
    I open a new document with 2 views, the first
    titled "doc 1:1" and the second "doc 1:2").
    How can I put the title I want for each view?

    Regards,
    Eyal


  2. #2
    Join Date
    May 1999
    Location
    Geneva
    Posts
    32

    Re: How can I change the default view title in a MDI app

    CDocument *pDoc = GetDocument();
    pDoc->SetTitle("New Title");

    Beware if there are some other views attach to this document this other view take the same title

    Christian Niquille


  3. #3
    Join Date
    May 1999
    Posts
    20

    Re: How can I change the default view title in a MDI app

    Thanks...

    But the problem is that the document
    changes the title BACK when a new view is
    added / removed / got focus...

    The CDocument class addes the doc and view
    counter to the title set by SetTitle()!
    i.e. if I write SetTitle("xxx") then after
    a while I get xxx:1, xxx:2...

    Eyal.



  4. #4
    Join Date
    May 1999
    Location
    Geneva
    Posts
    32

    Re: How can I change the default view title in a MDI app

    Setting Titles for New Windows
    When you click New Window on an MDI application's Window menu, no new document is created, so OnNewDocument is not invoked. The title of the new window is the document title for that document object, with ":2" appended after the title. The existing document window has ":1" appended to its title. The titles of new windows on that document will be appended sequentially starting with ".3." When you close any window on that document, the framework renumbers all the remaining windows.
    If the default numbering is not appropriate for your application, you can create your own titles for new windows. The steps necessary to change the title of an MDI child window frame are as follows:
    1. Override the PreCreateWindow function of the child frame class, as shown in this example:
    BOOL CChildFrame::PreCreateWindow(CREATESTRUCT &cs)
    {
    cs.style&=~(LONG)FWS_ADDTOTITLE;
    if (!CMDIChildWnd::PreCreateWindow(cs))
    return FALSE;
    return TRUE;
    }

    2. Override the OnInitialUpdate function of the view class, as shown in this example:
    void CXXXXView::OnInitialUpdate()
    {
    CView::OnInitialUpdate();
    GetParent()->SetWindowText(GetDocument()->GetTitle()+ " - This is a test!");
    }



    Christian Niquille


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured