home *** CD-ROM | disk | FTP | other *** search
- Path: news.easynet.co.uk!usenet
- From: dgo@easynet.co.uk (dgo)
- Newsgroups: comp.lang.c++,comp.os.ms-windows.programmer.tools.mfc
- Subject: Re: CFormView and SetWindowText()
- Date: 9 Apr 1996 08:29:34 GMT
- Organization: easynet
- Message-ID: <4kd75e$o85@lemon.easynet.co.uk>
- References: <4k0p7i$btp@news.icubed.com>
- NNTP-Posting-Host: dgo.easynet.co.uk
- Mime-Version: 1.0
- Content-Type: Text/Plain; charset=ISO-8859-1
- X-Newsreader: WinVN 0.99.6
-
- In article <4k0p7i$btp@news.icubed.com>, stevejones@ansys.com° says...
- >
- >Using MFC:
- >
- >I've got an MDI app using a CFormView derived class for the
- >views. I collect data from via controls in this view. Once
- >I get a particular CString datum, m_filename, I try to
- >change the view windows caption in the title bar to that
- >CString:
- >
- >SetWindowText(m_filename);
- >
- >However, nothing happens. GetWindowText() returns my
- >string. But visually, the change doesn't take effect. I do
- >this sort of thing regularly with dialog windows without any
- >trouble. What am I doing wrong?
- >
- You need to override OnUpdateFrameTitle() in a class derived from
- CMDIChildWnd which will be associated with your form view. The reason that
- your version doesn't work is that for child MDI windows the window text is
- ignored in producing the frame title which instead is made up of the filename
- and the number of the view associated with that document.
-
- This is a version I have used so that when there is no filename associated
- with an SDI form it has no title. The priciples will hold for MDI children as
- well.
-
- void CSDIChildFrame::OnUpdateFrameTitle(BOOL bAddToTitle)
- {
- CString sCurTitle, sAppTitle, sDocTitle;
- CDocument* pDoc = GetActiveDocument();
- if (pDoc)
- {
- pDoc->GetDocTemplate()->GetDocString(sAppTitle,
- CDocTemplate::windowTitle);
- sDocTitle = pDoc->GetTitle();
-
- if (sDocTitle != "Untitled" && bAddToTitle)
- sAppTitle += " - " + sDocTitle;
-
- GetWindowText(sCurTitle);
- if (sCurTitle != sAppTitle)
- SetWindowText(sAppTitle);
- }
- }
-
- happy hunting!
-
- daniel
-
-