Removing the Document Name from the Title Bar

翻译 2010年06月06日 15:26:00


Removing the Document Name from the Title Bar

DriveTree doesn't use its document object at all. Its File menu doesn't include document-handling commands. And it doesn't display a document name in its title bar because it doesn't make sense to display a document name when the application doesn't support the loading and saving of documents. But because MFC automatically adds the document name to the title bar, you must take special steps to prevent MFC from inserting a document name.

You'll find the code responsible for removing the document name in the frame window class. CMainFrame::PreCreateWindow contains the statement


FWS_ADDTOTITLE is a special window style specific to MFC that's included in frame windows by default. Windows that have this style have document names added to their window titles; windows that lack this style don't. By stripping the FWS_ADDTOTITLE bit from the window style in PreCreateWindow, CMainFrame prevents the framework from modifying its window title. You can use this technique to remove the document name from the title bar of any document/view application.







您举报文章:Removing the Document Name from the Title Bar