Click here to Skip to main content
15,901,373 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hey everyone. I have really gotten back into customizing the non client area of windows forms, and I want to be able to get resources (such as bitmaps, and colors) from the currently used windows theme. I found an UxTheme wrapper, but it doesn't quite do what I need it to do. I will use Mozilla Firefox as an example.

This is what Firefox looks like with Windows Aero theme turned on :http://i49.tinypic.com/2rh4s4m.jpg[^]

And this is what Firefox looks like with Windows 7 Basic theme on: http://i45.tinypic.com/2dcj32u.jpg[^]

And finally, this is what Firefox looks like with Windows Classic theme on: http://i46.tinypic.com/2vkylc4.jpg[^]

So how does Firefox get the colors from the Basic theme so that it can be "extended" into the Client area? If you maximize Firefox with the Windows Classic theme on, it will draw the caption with a gradient going toward the beginning of the toolbar.

Any sort of answer will be greatly appreciated!
Posted

1 solution

Most of it is automatic. You can get this info here Windows Vista Aero Glass in .NET Managed Win32 Applications[^]

Basically, the method calls DwmIsCompositionEnabled and if it returns false, then Firefox probably has code that changes the background of (what we could say) the tabs control to whatever color they want to match.

By the way, you probably already can infer but the DwmIsCompositionEnabled determines if Windows Aero is on or off.
 
Share this answer
 
v2
Comments
MikeMatt16 7-Jul-12 23:04pm    
I understand how Windows Aero is handled and extended, but I don't know how they handle Windows Basic, and Windows Classic themes. If needed, getting the name of the theme could help me out. If the theme's name is Windows 7 Basic, than obviously I'll be able to handle it using custom images included with the project, but I would like to know if I can extract the images or colors from the active theme.
JoThousand 8-Jul-12 9:36am    
Well for the colors, you could always use Photoshop or Paint to get the RGB values of the colors. Then you won't need images.

I also found this for you: http://pinvoke.net/default.aspx/uxtheme.GetCurrentThemeName

I hope this works, if not let me know.
MikeMatt16 8-Jul-12 19:53pm    
So I gave that API method a try, and it works for getting the current .msstyles theme. So I can now handle things differently for different Windows 7 Themes.

If you have Aero enabled, than the file name will be Aero.msstyles. if you are using Basic, the file name will be Aero.msstyles, Desktop Composition will be disabled. if you are using Classic, the file name will be empty.
JoThousand 9-Jul-12 1:03am    
Well I'm glad you got it working!
MikeMatt16 9-Jul-12 2:28am    
Yep, Thanks a bunch! I really appreciate it! :D

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900