I have a DLL that may display a dialog window using the following MFC code:
void ShowMyDialog()
{
BOOL bInitted = SUCCEEDED(::CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE));
INITCOMMONCONTROLSEX InitCtrls;
InitCtrls.dwSize = sizeof(InitCtrls);
InitCtrls.dwICC = ICC_WIN95_CLASSES;
InitCommonControlsEx(&InitCtrls);
//InitCommonControls(); //Tried also with just this call
AfxEnableControlContainer();
HMODULE hDll = NULL;
if(GetModuleHandleEx(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT,
(LPCWSTR) ShowMyDialog,
&hDll) &&
hDll)
{
AfxSetResourceHandle(hDll);
CMyDialog dl; //Derived from CDialog
dl.DoModal();
}
if(bInitted)
::CoUninitialize();
}
This works, but the dialog shown doesn't have visual styles enabled:
I found this article on how to enable visual styles for a DLL. So I added the resource file with suggested manifest content:
and gave it resource ID of 123:
But still no cigar. What am I missing here?