Rodrigo Farias Rezino
Rodrigo Farias Rezino

Reputation: 2799

How do I make my application use the Windows theme?

I'm working with some windows API to create a little application. I already created the buttons, windows, alright.

But the problem is the components I created don't look like the OS theme. They look very simple:

As you can see on image

See the button as example.

How do I enable the Windows theme? It can be in C or Delphi.

Upvotes: 5

Views: 6788

Answers (5)

Phoenix
Phoenix

Reputation: 11

If your executable name is YourAppName.exe then, create a manifest file named YourAppName.exe.manifest in the same directory where the executable application is.

YourAppName.exe.manifest:

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

For embedding manifest file into executable use mt.exe commandline syntax:

mt.exe –manifest YourAppName.exe.manifest -outputresource:YourAppName.exe;1

Upvotes: 0

Vantomex
Vantomex

Reputation: 2295

In Visual Styles Reference: Functions of MSDN, I found an interesting functions, that is, SetWindowTheme(). It can be used to either to apply or remove visual style to/from a control/window, there are several steps need to be done to enable Visual Style in an application.

To use Windows Theme api, you'll need JwaUxTheme unit of JEDI API Library.

However, applying theme from Windows Theme files (.theme) to an application seems has to be done by turning off visual style from controls and write owner drawn controls based on information from .theme files. MSDN has a documentation about .theme file specification (see the first reference below).

Some good references:

Is Windows Presentation Foundation (WPF) Themes bad? There is a code example how to load it here.

If you use VCL, Theme Engine and Skin Engine has a complete support of themes for Windows XP.

If beauty application is your priority (without supports for Windows themes), I think, BusinessSkinForm and DynamicSkinForm is the best choice.

Upvotes: 0

user160694
user160694

Reputation:

  1. It depends on what version of Delphi you're using. IIRC pre-Delphi 6 you need to add the needed manifest by hand. D7 and later has a component that need to be dropped on a form to add theme support (it simply adds the manifest), until D2007 IIRC added a simple check in the project options.
  2. Earlier version of Delphi won't show themed design form. You will see themes only at run time.
  3. Not all controls may support themes. Themes require the proper draw API to be called, if a control doesn't comply it won't be themed. The standard grid is a good example, it isn't draw themed until a late version.

Upvotes: 3

Mike Sutton
Mike Sutton

Reputation: 4211

If you're using Delphi 2007 or later, Project > Options > Application > Use Windows Themes needs to be checked.

(This should be automatically checked for new applications).

Upvotes: 1

user180326
user180326

Reputation:

For an application using windows controls, that is documented in this msdn article

Edit: To make a long story short, Windows needs to know for an application if it was intended to use the new style controls. Some older apps just aren't compatible with the new skinned looks of XP and later. Each exe should therefore declare with which version it is compatible in a manifest, an embedded xml file in the executable. The manifest is used for other things like declaring what you are or aren't compatible with (DLL versions, 120 dpi) as well as registration-free com.

Upvotes: 6

Related Questions