Posts Tagged ‘XP Themes’

How to make tab control pages transparent while using XP themes?

January 23, 2008 Leave a comment

Having trouble with tab control pages’  gray background while using XP themes? Well to solve this problem we need to do some additional housekeeping(AFAIK)…

Add a message map entry for WM_CTLCOLOR


Override OnCtlColor and add following code…

HBRUSH CTabPage::OnCtlColor( CDC* pDC_i, CWnd* pWnd_i, UINT uCntrlType_i )

   // First do default always
   HBRUSH hBrTemp = CDialog::OnCtlColor( pDC_i, pWnd_i, uCntrlType_i ); 

   // If we have a static control or a dialog control we should return our brush
   // with the DC having a transparent background
   switch( uCntrlType_i )
      case CTLCOLOR_DLG:
          pDC_i->SetBkMode( TRANSPARENT ); // Transparent mode
          hBrTemp = GetSysColorBrush( IsAppThemed() ? COLOR_WINDOW : COLOR_BTNFACE ); // Our brush

   // Return brush to caller
   return hBrTemp;

Note that we don’t need to delete the created brush since we are using a system cached brush. Also it’s good that you create a custom class(something like CTabPage, make this new class derive from CDialog.) and add this code there and then derive all your tab pages from this class instead of CDialog.

Is an application using visual themes?

Categories: Windows API Tags: ,

Enable/Disable XP Visual Styles for your application

May 30, 2007 3 comments

Via resource editor

For VC6 add this one line to your .rc file, open it in a text editor….


YourAppName.exe.manifest should be your application’s manifest file.

Or you can paste YourAppName.exe.manifest to your application folder and XP themes gets enabled.

From VC8 onwards manifest file should only be in your res folder, which will be picked up by the resoource compiler.

Disable themes

To disable XP themes programmatically for a particular window call SetWindowTheme with last two parameters set to L””. E.g.

// Disables theme, I assume you have XP themes applied on your application
SetWindowTheme( GetSafeHwnd(), L"", L"" );

To disable themes systemwide call EnableThemes with it’s only parameter set to FALSE, be careful! you won’t be able to enable it back unless you belong to the TCB(Trusted computing base) group, SE_TCB_PRIVILEGE.

EnableThemes( FALSE ); // No more theming

Another way to disable theming for an application is to right click on the exe goto properties->Compatibility->Disable visual Themes. See this screenshot…

Disable themes

You’ve got some other options too on this page which you should try out. Useful to do some “minor” OS simulation work.

Interesting stuff

Another interesting thing to do is, you’ve noticed that msdev/VS6 doesn’t use XP themes so just rename YourAppName.exe.manifest to msdev.exe.manifest and paste in the msdev.exe parent folder. Restart msdev and see the difference, do the same with visual sourcesafe or any other application that doesn’t support xp themes. Have fun! 🙂


Just incase you don’t have the manifest file with you, search in MSDN with RT_MANIFEST as key. Copy and paste the XML text that you see on the page to the manifest that’s mentioned above.

%d bloggers like this: