How to get rid of "Untitled - MyApp" in MFC
To get rid of the "Untitled" alone, you can override the CDocument virtual function "SetTitle" as shown below.
void CMyDoc::SetTitle(LPCTSTR lpszTitle)
{
CDocument::SetTitle("MyTitle");
}
This will produce a main window title of the type "MyTitle - MyApp". But perhaps all you want is "MyApp".
You can set the main window title from just about anywhere in your application using the statement shown below.
(AfxGetMainWnd( ))->SetWindowText("MyApp");
The problem with this approach is that MFC in its infinite wisdom will reset your window title to the "Document - App" default as soon as a document object is constructed. If you care to change MFC's default behavior ( not advised ) look up WINMDI.CPP; it's the culprit.
Finally, you can overwrite the CFrameWnd virtual function "OnUpdateFrameTitle" in your apps CMainFrame class. Bud Milwood, a friend of mine, pointed out the function's very existence when I was loosing my sanity browsing the MFC online help. Don't try to look up "OnUpdateFrameTitle" in the Microsoft Developer Studio online help. It's not there. So use it merrily, but use it wisely, subsequent versions of MFC may not support it. The following code snippet shows how...
void CMainFrame::OnUpdateFrameTitle(BOOL Nada)
{
// get app name from string table resource
//----------------------------------------
CString csAppName;
csAppName.Format(AFX_IDS_APP_TITLE);
// Set caption of main frame window
//---------------------------------
SetWindowText(csAppName);
}
Another and probably safer method has been brought to my attention by Stephen Michael Schimpf at CyberSky.Simplenet.Com. You can modify the window style in 'PreCreateWindow' as follows:
BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
{
cs.style &= ~(LONG) FWS_ADDTOTITLE;
return CFrameWnd::PreCreateWindow(cs);
}

Comments
Lightweight perceptive â Nike Loose TR Right in divulge 2013 3 series
Posted by Tufffruntee on 04/22/2013 03:00amNike Free TR Suited 3 salient features is to exploit the brand-new forge: Nike Let off 5 soles improved bending Gouge; new tractor formation making training more focused when; lighter load, the permeability is stronger, and more smart shoe designs not lone make shoes [url=http://northernroofing.co.uk/roofins.cfm]nike free[/url] more pleasant wearing, barefoot training feel, but also more stylish appearance. Nike Relieve TR Fitting 3 provides supreme lateral stability, you can take the legs in the lap boost during training. Strong vamp majuscule letters breathable grate, disgrace sparkle's unique delineate can be [url=http://fossilsdirect.co.uk/glossarey.cfm]nike huarache free[/url] seen by virtue of it. Lightweight, difficult, piddling froth material used through very some seams, more obedient, advocate is stronger. Requirement more help, role of a training vex, lather come in more parts of the shortage after flexibility, effervescence loose. Put to use two-ply tongue moisture wicking counterfeit materials, tiresome on your feet, refrain from maintain feet sear and comfortable. Phylite [url=http://northernroofing.co.uk/roofins.cfm]nike free run[/url] midsole offers lightweight stupor level, superior durability and even outsole can do to greatly reduce the comprehensive load of the shoe. Qianzhang pods on the outsole and heel-shaped Green rubber enhances the shoe multi-directional drag on extraordinary surfaces.
Replyreliable mlb jersey
Posted by baroneqzx on 03/12/2013 05:41pmclarisonic mia 2 outlet discount clarisonic mia clarisonic online store clarisonic outlet store clarisonic mia canada cheap clarisonic canada cheap clarisonic uk clarisonic uk authentic nfl jerseys wholesale nhl jerseys
ReplyCFrameTitle can also benefit from OnUpdateFrameTitle()
Posted by Legacy on 11/11/2003 12:00amOriginally posted by: Shaul
ReplyNo need to override SetTitle
Posted by Legacy on 05/31/2003 12:00amOriginally posted by: Sam Hobbs
I am nearly certain that it is not necessary to override CDocument::SetTitle; I am nearly certain that merely calling it will work.
ReplySimpler way to change the default title
Posted by Legacy on 01/03/2003 12:00amOriginally posted by: Tony dixon
ReplyMultiple view problem
Posted by Legacy on 05/02/2002 12:00amOriginally posted by: Jonathan Liu
How to set different title names for multiple views of the same document. It seems the OnPaint() in view window is the place to set the title, although is not a nice way to do so.
ReplyTry this one, you can customize your title..
Posted by Legacy on 05/31/2001 12:00amOriginally posted by: Jacob Joseph
Override CDocument::SetTitle, dont call the base class function. This will remove the 'Untitled' from a new document and also can customize your title. This eg sets the title as 'My App - doc name'. I did this for a SDI app.
Dont forget to add the line
cs.style &= ~(LONG) FWS_ADDTOTITLE; in
CMainFrame :: PreCreateWindow(CREATESTRUCT& cs).
Replyvoid CGenericDoc::SetTitle(LPCTSTR lpszTitle)
{
CWnd * pWnd = AfxGetMainWnd();
CString csTitle;
csTitle.LoadString(IDS_CUSTINFO_TITLE);
if ( CString(lpszTitle) == CString(_T("Untitled")) )
{
if (pWnd)
pWnd->SetWindowText((LPCTSTR)(csTitle));
}
else
{
csTitle = csTitle + _T(" - ") + lpszTitle;
if (pWnd)
pWnd->SetWindowText((LPCTSTR)(csTitle));
}
}
Thanks all, especialy Richard.
Posted by Legacy on 03/30/2000 12:00amOriginally posted by: Dave Swann
ReplyMore easy way
Posted by Legacy on 02/02/2000 12:00amOriginally posted by: Konstantin Pilkevitch
I think that the best way to do this is to add such string
in PreCreateWindow(CREATESTRUCT &cs) function of CMainFrame
cs.style &= ~FWS_ADDTOTITLE;
ReplyEasier way
Posted by Legacy on 08/14/1999 12:00amOriginally posted by: Richard Stringer
The easiest solution I have found is to override the OnPaint() function of the view class and using a pointer to the current frame window change the title using SetWindowText(). A advantage is thet you can easily change the title to relflect the current state of the application this way.
void CMainView::OnPaint()
{
CPaintDC dc(this); // device context for painting
CMainFrame* pFrame;
VERIFY( pFrame = (CMainFrame*)GetParentFrame() );
pFrame->SetWindowText("What ever the title is");
}
Richard
ReplyLoading, Please Wait ...