Problems Detecting if Themes are Active

Tech-Archive recommends: Speed Up your PC by fixing your registry

From: Jonathan Wood (jwood_at_softcircuits.com)
Date: 04/10/04


Date: Fri, 9 Apr 2004 18:52:32 -0600

Does anyone know why the following code has problems. I'm trying to take
action only if the current appliction is themed. I tried the version below
and also the one commented out that used IsAppThemed. In both cases, the
functions (IsAppThemed and IsThemeActive) return true and my inner condition
executes even when I am not including my application's manifest.

//typedef BOOL (*LPISAPPTHEMED)(VOID);
typedef BOOL (*LPISTHEMEACTIVE)(VOID);
typedef HRESULT (*LPENABLETHEMEDIALOGTEXTURE)(HWND, DWORD);

BOOL CPanel::OnInitDialog()
{
 CDialog::OnInitDialog();

 HMODULE hModule = LoadLibrary(_T("UxTheme.dll"));
 if (hModule != NULL)
 {
// LPISAPPTHEMED pIsAppThemed;
  LPISTHEMEACTIVE pIsThemeActive;
  LPENABLETHEMEDIALOGTEXTURE pEnableThemeDialogTexture;

// pIsAppThemed = (LPISAPPTHEMED)GetProcAddress(hModule, "IsAppThemed");
  pIsThemeActive = (LPISTHEMEACTIVE)GetProcAddress(hModule,
"IsThemeActive");
// if (pIsAppThemed != NULL && pIsAppThemed())
  if (pIsThemeActive != NULL && pIsThemeActive())
  {
   pEnableThemeDialogTexture =
(LPENABLETHEMEDIALOGTEXTURE)GetProcAddress(hModule,
"EnableThemeDialogTexture");
   if (pEnableThemeDialogTexture != NULL)
   {
    pEnableThemeDialogTexture(m_hWnd, ETDT_ENABLETAB);
   }
  }
  FreeLibrary(hModule);
 }
 return TRUE;
}

Thanks.

-- 
Jonathan Wood
SoftCircuits
http://www.softcircuits.com
Available for consulting: http://www.softcircuits.com/jwood/resume.htm