Skip to main content
GameDev.net gamedev.net
🔒 Locked

Themes with WINAPI (no mfc allowed)

Started by valleyman86 Nov 8, 2005 at 12:59 AM 12 replies 3.2k views
Original Post
valleyman86
valleyman86
How can I use themes with the winapi and would i have to change a bunch of stuff. I need to know wat libs to add and how #include <> or "". What do I need? I dont know where to start.
Skeleton_V@T
Skeleton_V@T
I assume you're making traditional Win32 apps, there's one window message that fulfill your question:

WM_THEMECHANGED

This message will be sent to all top-level windows right after the Windows theme's changed.

To mutate the current system theme you can also use OpenThemeData () and CloseThemeData () API functions. These are easy to use, I hope you have no trouble with them.

Included headers and libs:
uxtheme.h and uxtheme.lib, using uxtheme.dll
and minimum operating system required is Windows XP.

If you only want to know when the system theme changes, you can use
WM_SYSCOLORCHANGED instead, it's compatible with both Win9x/NT OSes.

V@T

[Edited by - Skeleton_V@T on November 8, 2005 9:25:17 AM]
--> The great thing about Object Oriented code is that it can make small, simple problems look like large, complex ones <--
frob
frob
Just be sure you aren't confusing themes with visual styles.

Themes are something you can change, but probably shouldn't. Themes are the fonts, sizes, and colors for window appearance. It's basically the stuff under Control Panel | Display Properties | Appearance | Advanced.

Visual styles, such as the Windows XP visual style or Windows Classic style, need to be cryptographically signed by Microsoft. There are apps out there like WindowBlinds that replace the library requiring digital signatures and allow custom visual styles.

[Edit: when posting URLs to GameDev, you need to preface them with the http:// protocol identifier or they will be interpreted as relative to http://www.gamedev.net. Fixed. - Oluseyi]

frob.

[Edited by - Oluseyi on November 8, 2005 3:36:23 PM]
valleyman86
valleyman86
Alright how do I include the dll and the lib is linked with the linker correct? Also is there any other code involved I tried to make a button xp style to no avail. Anyone have a small example I can look at (preferably working program) that has maybe one control showing how to make it work? In opentheme function what do you put in as the second parameter. Is there anything I need to do to initialize the theme. I just want to use the basic windows xp theme so that my gui dont look like win98.
frob
frob
Quote:
Original post by valleyman86
uhm i think i got it rigjt i need to make my app look like a typical xp style app. With the cleaner looking buttons and controls.


That's much different from the first comment.


MSDN has an article on that, scroll down to the section titled "To create a manifest".

frob.
valleyman86
valleyman86
sweet that worked. Thx man. Is it possible to have the manifest file be compiled into the exe so I dont have to distribute that with my exe.
frob
frob
Quote:
Original post by valleyman86
sweet that worked. Thx man. Is it possible to have the manifest file be compiled into the exe so I dont have to distribute that with my exe.

You can include the information internally to the app. The exact details of doing it depend on the langauage, but it goes in with the other assembly information.

In the code where you specify the assembly title, version, signing, threading, and security, add a section for common control information.

frob.
Skeleton_V@T
Skeleton_V@T
Quote:
Original post by frob
Quote:
Original post by valleyman86
sweet that worked. Thx man. Is it possible to have the manifest file be compiled into the exe so I dont have to distribute that with my exe.

You can include the information internally to the app. The exact details of doing it depend on the langauage, but it goes in with the other assembly information.

In the code where you specify the assembly title, version, signing, threading, and security, add a section for common control information.

frob.


The simpler solution is to use a resource hacker that can embed the manifest file into the exe itself. In this way, you can easily make any of your programs/others existing programs to use/not use Windows XP visual style. You don't even have to modify one line in your code. And totally compatible with older OSes, in Win9x, it'll just bypass that info.

If you're interested in this solution, I'll post the manifest file along with some useful resource modifiers such as Resource Hacker

Hth
V@T
--> The great thing about Object Oriented code is that it can make small, simple problems look like large, complex ones <--
Skeleton_V@T
Skeleton_V@T
It's a piece of cake. All you have to do is to use Resource Hacker (as I stated above) to add the following file (named ABCD1234.manifest - you can name whatever you like, as the content is important) to the desired executable:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?><assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0"> <assemblyIdentity     version="1.0.0.0"     processorArchitecture="X86"     name="MyName.MyApplication.MyProgram"    type="win32" /> <description>Some explain about your program.</description> <dependency>     <dependentAssembly>         <assemblyIdentity             type="win32"             name="Microsoft.Windows.Common-Controls"             version="6.0.0.0"             processorArchitecture="X86"             publicKeyToken="6595b64144ccf1df"             language="*"         />     </dependentAssembly> </dependency> </assembly>


I hope you get used Resource Hacker, this is an useful utility with simple interface.

V@T
--> The great thing about Object Oriented code is that it can make small, simple problems look like large, complex ones <--
Mercury
Mercury
What I do is open the RC file up in notepad and add this line:
1 RT_MANIFEST "APPNAME.exe.manifest"

APPNAME.exe.manifest is this:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?><assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0"><assemblyIdentity    version="1.0.0.0"    processorArchitecture="X86"    name="APPNAME.APPNAME.APPNAME"    type="win32"/><description>Your application description here.</description><dependency>    <dependentAssembly>        <assemblyIdentity            type="win32"            name="Microsoft.Windows.Common-Controls"            version="6.0.0.0"            processorArchitecture="X86"            publicKeyToken="6595b64144ccf1df"            language="*"        />    </dependentAssembly></dependency></assembly>
tj963
tj963
If you're using Visual Stdio, you can add a resource file and then just insert a manifest resource (the manifest file) and it'll be included in your exe.

tj963
tj963
valleyman86
valleyman86
thx guys that rc file thing helped. I had an idea on how to do this just would never work. Notepad is awesome heh. The resource thing is easy as well but vs might as well make a rc file.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.