using Visual Studio 2015, I have a MMC Snapin that is expected to use the Common Controls Version 6. In order to achieve it, I created XML Manifests and attached it to my Snapin.DLL. Type 24 (RT_MANIFEST), ID 2 (or 3).
I am able to create V6 Windows Controls such as Buttons myself using the Win32 API with ISOLATION_AWARE 1, a manifest in RT_MANIFEST/2 and no own activation context switching.
I am also able to create V6 Windows Controls such as Buttons myself using the Win32 API with no ISOLATION_AWARE, activating my own activation context from RT_MANIFEST/3 using ActivateActCtx .
But as soon as I use MFC classes to instanciate controls, MFC selects the wrong activation context for me and all i get is a V5 Control.
HWND hwndButton = ::CreateWindow("BUTTON","direct button",
WS_TABSTOP | WS_VISIBLE | WS_CHILD | BS_DEFPUSHBUTTON,
10,10,100,100,m_hWnd,NULL,(HINSTANCE)GetWindowLong(m_hWnd, GWL_HINSTANCE),NULL);
CButton *testButton = new CButton();
testButton->Create("MFC Button", WS_CHILD | WS_VISIBLE, CRect(10, 120, 200, 220),this, 12345);
This happens regardless of ISOLATION_AWARE defined for my application or not, and regardless of the Resource ID (2 or 3) used for the RT_MANIFEST.
It seems that MFC140.dll was compiled with ISOLATION_AWARE and tries to identify the correct activation context to use. According to the debugger it goes through winbase.inl, Function WinbaseIsolationAwarePrivatetRgzlnPgpgk(...), where it boils down to
if (!IsolationAwareQueryActCtxW(
QUERY_ACTCTX_FLAG_ACTCTX_IS_ADDRESS
| QUERY_ACTCTX_FLAG_NO_ADDREF,
&WinbaseIsolationAwarePrivateT_UnPgpgk,
NULL,
ActivationContextBasicInformation,
&actCtxBasicInfo,
sizeof(actCtxBasicInfo),
NULL))
goto Exit;
Which queries the activation context for an address inside the mfc140.dll. I believe the code is expected to be inline in my own application (as written in a comment, and as tests showed, if it is, it works ok), but inside mfc140 it queries the wrong component for an activation context.
It gets one, but i don't know from where, since the MFC140.dll does not have one in its resources. The activation context it gets selects the v5 common controls.
I cannot use RT_MANIFEST(24)/ resource ID 1, which might work, since i am in an DLL.
So my Questions are:
- how do i disable the activation context management in MFC140.dll? OR
- how do i provide the correct activation context to MFC?