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
Printable View
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
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
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.
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