Modify the code generated by the MFC App Wizard to use MFC v4.2 or later

Streamline unnecessary code

2025-11-19

Written by: xiaobin

MSVC Version - add

Add the following before and after each “pragma once”:

#if _MSC_VER > 1020
#pragma once
#endif // _MSC_VER > 1020

Visual C++ 5.0 includes MFC 4.2.

VC5 and VC6

Visual C++ 6 was a small update to Visual C++ 5 in terms of both UI and functionality. The biggest change that I observed was having an install time check for Internet Explorer 4 and moving the documentation system to HTML Help. This check was looking at the registry only however, and the HTML Help system worked (albeit without perfect CSS formatting) with Internet Explorer 3.

Under the covers, the dependency on Internet Explorer 4 was also problematic. By default the headers would use new structures that are only supported when Internet Explorer 4 was present, so unless a developer consciously set values like _WIN32_IE themselves, programs generated tended to have an IE4 dependency.

One of the things that made Visual C++ 6 so long lived is it was possible to use an updated Windows SDK, up to Windows 2003 Service Pack 1. This meant that a developer could use Visual C++ 6 without sacrificing any operating system functionality, while retaining the benefit of using MSVCRT.DLL.

Shared Handlers - removed

SHARED_HANDLERS can be defined in an ATL project implementing preview, thumbnail 
and search filter handlers and allows sharing of document code with that project.

If you don’t use ATL’s thumbnails or other features, you can remove the code within the SHARED_HANDLERS macro.

#ifdef SHARED_HANDLERS
    // some code here
#endif // SHARED_HANDLERS

Included files:

MFC Thumbnail Preview and Com DLL with Com Interface

Visual C++ 2010 adds the ability to simply implement Thumbnail and Preview support for Microsoft Foundation Classes (MFC) projects with a registered file extension. The file extension is a critical part of the Thumbnail and Preview support, as the COM DLL that handles the rendering of both thumbnails and previews is mapped by file extension.

Toolbar docking - removed

If you do not want the toolbar to be dockable, please delete it:

    // TODO: Delete these three lines if you don't want the toolbar to be dockable
    m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
    EnableDocking(CBRS_ALIGN_ANY);
    DockControlBar(&m_wndToolBar);
protected:  // control bar embedded members
    CToolBar          m_wndToolBar;