Skip to content

Files

Latest commit

0885606 · Oct 5, 2017

History

History
28 lines (23 loc) · 2.07 KB

isolation-of-the-mfc-common-controls-library.md

File metadata and controls

28 lines (23 loc) · 2.07 KB
title ms.custom ms.date ms.reviewer ms.suite ms.technology ms.tgt_pltfrm ms.topic dev_langs helpviewer_keywords ms.assetid caps.latest.revision author ms.author manager
Isolation of the MFC Common Controls Library | Microsoft Docs
11/04/2016
cpp-windows
article
C++
MFC, Common Controls library
7471e6f0-49b0-47f7-86e7-8d6bc3541694
11
mikeblome
mblome
ghogen

Isolation of the MFC Common Controls Library

The Common Controls library is now isolated within MFC, allowing different modules (such as user DLLs) to use different versions of the Common Controls library by specifying the version in their manifests.

An MFC application (or user code called by MFC) makes calls to Common Controls library APIs through wrapper functions named AfxFunctionName, where FunctionName is the name of a Common Controls API. Those wrapper functions are defined in afxcomctl32.h and afxcomctl32.inl.

You can use the AFX_COMCTL32_IF_EXISTS and AFX_COMCTL32_IF_EXISTS2 macros (defined in afxcomctl32.h) to determine whether the Common Controls library implements a certain API instead of calling GetProcAddress.

Technically, you make calls to Common Controls Library APIs through a wrapper class, CComCtlWrapper (defined in afxcomctl32.h). CComCtlWrapper is also responsible for the loading and unloading of comctl32.dll. The MFC Module State contains a pointer to an instance of CComCtlWrapper. You can access the wrapper class using the afxComCtlWrapper macro.

Note that calling Common Controls API directly (not using the MFC wrapper functions) from an MFC application or user DLL will work in most cases, because the MFC application or user DLL is bound to the Common Controls library it requested in its manifest). However, the MFC code itself has to use the wrappers, because MFC code might be called from user DLLs with different Common Controls library versions.