How to get rid of "Untitled - MyApp" in MFC

Microsoft outdid themselves when they designed MFC such that applications are automatically named according to the document view paradigm. When you use MFC to create either an SDI or MDI application, your main window is probably called something like "Untitled - MyApp." If you don't particularly care for the document view paradigm, other than perhaps wishing to benefit from the separation of user interface and program core, then you're left in the dark...

To get rid of the "Untitled" alone, you can override the CDocument virtual function "SetTitle" as shown below.

   void CMyDoc::SetTitle(LPCTSTR lpszTitle) 

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;

      // Set caption of main frame window

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)
    return CFrameWnd::PreCreateWindow(cs);


  • Lightweight perceptive – Nike Loose TR Right in divulge 2013 3 series

    Posted by Tufffruntee on 04/22/2013 03:00am

    Nike 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=]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=]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=]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.

  • reliable mlb jersey

    Posted by baroneqzx on 03/12/2013 05:41pm

    clarisonic 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

  • CFrameTitle can also benefit from OnUpdateFrameTitle()

    Posted by Legacy on 11/11/2003 12:00am

    Originally posted by: Shaul

    If you want to embed a frame inside one of your panes, you can control its title text as follows:

    void CCmaTreeView::OnSelchanged(NMHDR* pNMHDR, LRESULT* pResult)

    CString title;

    title = "blabala";

    // Inform Frame
    CRightFrameWnd * frame = (CRightFrameWnd *)(GetParent())->GetParent();
    frame->OnUpdateFrameTitle(false); // false if you want your text only.

    *pResult = 0;

  • No need to override SetTitle

    Posted by Legacy on 05/31/2003 12:00am

    Originally 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.

  • Simpler way to change the default title

    Posted by Legacy on 01/03/2003 12:00am

    Originally posted by: Tony dixon

    there are two way to change the default title of a MFC app.

    1) in the appwizared on step 6 there is a Advanced button, press this and dialog will let you enter the name of the application.
    2) edit the string table for value (128 for SDI and 129 for MDI)this a list of items delimited by char (10), the first in the list is the app name.

    But this only works on MDI apps, for SDI the AppWizard has an error so you have to edit the IDR_MAINFRAME item in the string table.

    This is the string linked to the IDR_MAINFRAME item in the string table.

    Tonys Test App\n\nTest\nTonys Test Files (*.bin)\n.bin\nTest.Document\nTest Document

    The error is in the placement of the \n as so "Tonys Test App\n\n" the two \n is the error they should not be together, but one should be at the start of the string as below.

    \nTonys Test App\nTest\nTonys Test Files (*.bin)\n.bin\nTest.Document\nTest Document

    This works with out hard coding the name also windows use this value from the application when associating files.

  • Multiple view problem

    Posted by Legacy on 05/02/2002 12:00am

    Originally 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.

  • Try this one, you can customize your title..

    Posted by Legacy on 05/31/2001 12:00am

    Originally 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 &= ~(LONG) FWS_ADDTOTITLE; in
    CMainFrame :: PreCreateWindow(CREATESTRUCT& cs).

    void CGenericDoc::SetTitle(LPCTSTR lpszTitle)
    CWnd * pWnd = AfxGetMainWnd();
    CString csTitle;

    if ( CString(lpszTitle) == CString(_T("Untitled")) )
    if (pWnd)
    csTitle = csTitle + _T(" - ") + lpszTitle;
    if (pWnd)

  • Thanks all, especialy Richard.

    Posted by Legacy on 03/30/2000 12:00am

    Originally posted by: Dave Swann

    I'm a bit of a beginer trying to build a complex application.
    Iv'e discovered thay it is possible to have a FRAME window in a static splitter pane, and wanted to use its title bar to display info from the view. -
    void CSomeView::OnPaint()
    CPaintDC dc(this); // device context for painting
    CSomeFrame* pFrame;
    VERIFY( pFrame = (CSomeFrame*)GetParentFrame() );
    pFrame->SetWindowText("What ever the info is");

    Thanks again Richard.

  • More easy way

    Posted by Legacy on 02/02/2000 12:00am

    Originally 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 &= ~FWS_ADDTOTITLE;

  • Easier way

    Posted by Legacy on 08/14/1999 12:00am

    Originally 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");



  • Loading, Please Wait ...

Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

Most Popular Programming Stories

More for Developers

RSS Feeds

Thanks for your registration, follow us on our social networks to keep up-to-date