You can use the following snippet to get the current theme information. If you map WM_THEMECHANGED function in your source, your program will be notified when the user changes the current theme. You can simply get more information about the new theme as follows.
The documentation in MSDN is not really detailed about the preconditions to use the APIs. Anyway I had found to meet meet the following requirements.
1. It will be failed if you try to call from a console application. The application should be a windows application
2. The application should be linked and enabled with windows common control version 6.
3. Even the application has enabled Visual styles, it will be failed if the global theme has changed to “Classic” appearance
Please share more information through your comments. Anyway use the following snippets to get the current theme information.
// Link with UxTheme.dll
#pragma comment (lib, "uxtheme.lib")
BOOL CThemeSampleMFCDlg::RefreshThemeInfo(void)
{
WCHAR szThemeName[MAX_PATH] = { 0 };
WCHAR szColorBuff[MAX_PATH] = { 0 };
WCHAR szSizeBuff[MAX_PATH] = { 0 };
HRESULT hr = GetCurrentThemeName(szThemeName, MAX_PATH,
szColorBuff, MAX_PATH,
szSizeBuff, MAX_PATH );
if (SUCCEEDED( hr ))
{
std::wstring strInfo( szThemeName );
strInfo += L"\r\n";
strInfo += szColorBuff;
strInfo += L"\r\n";
strInfo += szSizeBuff;
SetDlgItemTextW( IDC_EDIT1,strInfo.c_str());
}
else
{
SetDlgItemTextW(IDC_EDIT1, L"Failed to Query Theme Info"); // Probably classic theme or so
}
return 0;
}