NO

Author Topic: Setting Themes for Win32 Programs  (Read 11529 times)

Knuckles

  • Guest
Setting Themes for Win32 Programs
« on: April 27, 2010, 02:31:13 AM »
I'm having difficulty applying themes to a listview control. 

The MSDN description of SetWindowTheme is at (http://msdn.microsoft.com/en-us/library/bb759827(VS.85).aspx).
It actually has an example of exactly what I want to do (make a listview look like Windows Explorer does in Vista), but when I adapt their example it it doesn't do anything.  Their codes reads:

SetWindowTheme(hwndList, L"Explorer", NULL);

I replaced hwndList with a handle to my listview (generated by GetDlgItem()), and checked the return value.  The function is supposed to return S_OK ( = 0) if it succeeds, and mine does, even though it doesn't actually change the theme.  The listview has the simple pre-XP style.

I'm kind of new to Pelles, and C in general.  MSDN says the function relies on Uxtheme.h, UxTheme.lib, and UxTheme.dll, so I added #include "Uxtheme.h" at the top of my code and put UxTheme.lib in the list of "Library and object files" under the "Linker" tab of Project Options.  I have tried placing UxTheme.dll on the same page under "DLL files with delayed loading" but it didn't change anything.  Is there a step I'm missing?

As a separate but related point, I notice that when I generate and test dialogs in the Resource Editor, they appear with the vista-like theme, but when I actually compile my code they appear with the older pre-XP styles.  Is there a simple way that I can apply the newer styles to my entire program all at once?

Offline TimoVJL

  • Global Moderator
  • Member
  • *****
  • Posts: 2115
Re: Setting Themes for Win32 Programs
« Reply #1 on: April 27, 2010, 11:52:07 AM »
Quote
Is there a simple way that I can apply the newer styles to my entire program all at once?
manifest ???
Related topic
http://forum.pellesc.de/index.php?topic=2210.0

Edit: Example project with MessageBox and manifest.
« Last Edit: April 27, 2010, 05:31:41 PM by timovjl »
May the source be with you

Knuckles

  • Guest
Re: Setting Themes for Win32 Programs
« Reply #2 on: April 27, 2010, 07:44:52 PM »
I got it to work !!! Thanks.

Just in case anyone with similar problems reads this thread in future, it seems that you have to give your manifest a specific name and resource ID for this to work.  It's described at (http://msdn.microsoft.com/en-us/library/bb773175(v=VS.85).aspx#no_extensions)