Removing Untitled from MFC Window

The CFrameWnd class calls a lot of functions before instantiating a window. One of those functions PreCreateWindow, determines the styles of the Window. The styles are constant values viz., WS_MAXIMIZE, WS_MINIMIZE etc.,

All of them are added with an OR operator and passed as a parameter to the PreCreateWindow. The PreCreateWindow takes in a parameter of type CREATESTRUCT structure. This structure has host of other members which contains data about other properties of the window.

If the default styles loaded are changed and the style FWS_ADDTOTITLE is not added to the default style for CREATESTRUCT.style value, the “Untitled” will not be shown as the title of the window.

The sample code is,

BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
{
    if( !CFrameWnd::PreCreateWindow(cs) )
       return FALSE;

    // TODO: Modify the Window class or styles here by modifying
    // the CREATESTRUCT cs
    cs.style = WS_OVERLAPPED | WS_CAPTION | WS_THICKFRAME | WS_SYSMENU |  WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_MAXIMIZE;

    return TRUE;

}