Themes with WINAPI (no mfc allowed)

Started by
12 comments, last by valleyman86 18 years, 5 months ago
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.
-------------------------------------------
http://www.MurderDev.com - Developing Killer Software
http://www.MobileCellOut.com - Cell Phone Contract Exchange
Advertisement
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 <--
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]
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.
-------------------------------------------
http://www.MurderDev.com - Developing Killer Software
http://www.MobileCellOut.com - Cell Phone Contract Exchange
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.
-------------------------------------------
http://www.MurderDev.com - Developing Killer Software
http://www.MobileCellOut.com - Cell Phone Contract Exchange
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.
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.
-------------------------------------------
http://www.MurderDev.com - Developing Killer Software
http://www.MobileCellOut.com - Cell Phone Contract Exchange
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.
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 <--
yea. That would be cool. Is it too hard?
-------------------------------------------
http://www.MurderDev.com - Developing Killer Software
http://www.MobileCellOut.com - Cell Phone Contract Exchange

This topic is closed to new replies.

Advertisement