9014

MFC application title

I am creating a simple clock application using MFC. My application title appears as follows : "CLOCK - [CLOCK1]". How do I reset it to simply "CLOCK"? FYI, I have enabled the Document-View architecture.

Answer1:

Put in this override of the MFC title:

void CMainFrame::OnUpdateFrameTitle(BOOL bAddToTitle) { SetWindowText(L"CLOCK"); }

Answer2:

There's an answer here, but I feel that the following solution is more "proper".

In addition to overriding CMainFrame::OnUpdateFrameTitle(), you also need to override CMainFrame::PreCreateWindow() as below:

BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs) { cs.style &= ~FWS_ADDTOTITLE; return CFrameWndEx::PreCreateWindow(cs); // replace CFrameWndEx by CFrameWnd if } // your CMainFrame is based on CFrameWnd

A note: it is better to use AfxSetWindowText(m_hWnd, _T("foo")) instead of SetWindowText(_T("foo")) to avoid excessive flicker, it checks that the text is different before setting the window text.

Answer3:

You can change it in visual editor by clicking on a your window and typing a title. Or you can add this code in function OnInitDialog

this->SetWindowText(L"CLOCK");

Recommend

  • win32 api edit control can't be selected or edited
  • How to remove the border of the client area of a window?
  • MFC Ribbon: RemoveAllSubItems() in CView::OnUpdate leads to access violation (VS2008)
  • How to insert string in edit control
  • How does MFC interpret SetWindowTextW(LPCTSTR)?
  • EN_PROTECTED and RichEdit
  • c# bind winforms chart to list of objects
  • Generate a unique string based on a pair of strings
  • Deleting a widget from QTableView
  • multidatatrigger with multibinding in ControlTemplate.Triggers
  • Is there a parser equivalent of 'fragment' marking in ANTLR4?
  • Build Successful but not running on simulator
  • Checking if an array in C is symmetric
  • c# open webrowser in many tab
  • Bypass multiple inheritance in Java
  • how to find common suffix in java by using method
  • Display java JPanel in a JFrame
  • onBackPressed() not being executed
  • iOS: Detect app start via notification press
  • Java: can you cast Class into a specific interface?
  • how to adjust image in a panel in Java swing?
  • How to access EntityManager inside Entity class in EJB3
  • how to do an event when i swipe from fragment to the other
  • Update CALayer sublayers immediately
  • JFileChooser in front of fullscreen Swing application
  • HTML download movie download link
  • How to draw moving and Running sine wave chart using JFree chart in java?
  • AES padding and writing the ciphertext to a disk file
  • Possible to stop flickering java tooltip in heavyweight mode?
  • Updating server-side rendering client-side
  • How to extract text from Word files using C#?
  • sending/ receiving email in Java
  • Eraser for UIBezierPath
  • Suggestions to manage Login/Logout transitions
  • Exception on Android 4.0 `android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode)`
  • unknown Exception android
  • EntityFramework adding new object to nested object collection
  • Checking variable from a different class in C#
  • failed to connect to specific WiFi in android programmatically
  • How can I use threading to 'tick' a timer to be accessed by other threads?