XP Button theme in COM add-in

  • Thread starter Scott McPhillips [MVP]
  • Start date
S

Scott McPhillips [MVP]

I am writing a Word 2007 COM add-in in native C++ with ATL. My dialogs
display buttons with the old, square-corner style with no color. So I'm
trying to improve the button's appearance to use the XP themes.

This Knowledge Base article <http://support.microsoft.com/kb/830033>
describes how to apply Windows XP themes to Office COM add-ins. However,
this article has not been updated since Visual C++ version 6. I have been
trying to apply it in Visual C++ 2008 without success.

In part, the article says
"Add the manifest file to your resource file, as in the following example:
#include "windows.h"
ISOLATIONAWARE_MANIFEST_RESOURCE_ID RT_MANIFEST "mydllname.dl.manifest"

What "resource file" is that referring to? I don't know of any "resource
files" that include windows.h. Putting it into my project's .rc file either
has no effect or produces "fatal error CVT1100: duplicate resource",
depending on where within the .rc file it is placed.

I also tried using this new pragma to get the linker to add the required
manifest section:
#pragma comment(linker,"/manifestdependency:\"type='win32'
name='Microsoft.Windows.Common-Controls' version='6.0.0.0'
processorArchitecture='x86' publicKeyToken='6595b64144ccf1df'
language='*'\"")

This succeeded in adding the section to my add-in's embedded manifest file,
but there is still no change to my buttons appearance. Should this work in
Word 2007?
 
S

SvenC

Hi Scott,
This Knowledge Base article <http://support.microsoft.com/kb/830033>
describes how to apply Windows XP themes to Office COM add-ins.
I have been trying to apply it in Visual C++ 2008 without success.
... I also tried using this new pragma to get the linker to add the
required manifest section:
#pragma comment(linker,"/manifestdependency:\"type='win32'
name='Microsoft.Windows.Common-Controls' version='6.0.0.0'
processorArchitecture='x86' publicKeyToken='6595b64144ccf1df'
language='*'\"")

How does your manifest look like and which ID does it have? The ID
should be 2 as it is a dll manifest.

An addin of mine uses this manifest and the common controls work:

<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity version="1.2.3.4" processorArchitecture="X86"
name="my Addin" type="win32"></assemblyIdentity>
<description>my addin</description>
<dependency>
<dependentAssembly>
<assemblyIdentity
type="win32"
name="Microsoft.Windows.Common-Controls"
version="6.0.0.0" processorArchitecture="X86"
publicKeyToken="6595b64144ccf1df" language="*">
</assemblyIdentity>
</dependentAssembly>
</dependency>
<dependency>
</assembly>

In addition I add this to my code:

INITCOMMONCONTROLSEX iex = { sizeof(INITCOMMONCONTROLSEX),
ICC_COOL_CLASSES|ICC_STANDARD_CLASSES|ICC_TAB_CLASSES|ICC_USEREX_CLASSES };
InitCommonControlsEx(&iex);
 
S

Scott McPhillips [MVP]

SvenC said:
Hi Scott,


How does your manifest look like and which ID does it have? The ID
should be 2 as it is a dll manifest.

An addin of mine uses this manifest and the common controls work:

<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity version="1.2.3.4" processorArchitecture="X86"
name="my Addin" type="win32"></assemblyIdentity>
<description>my addin</description>
<dependency>
<dependentAssembly>
<assemblyIdentity
type="win32"
name="Microsoft.Windows.Common-Controls"
version="6.0.0.0" processorArchitecture="X86"
publicKeyToken="6595b64144ccf1df" language="*">
</assemblyIdentity>
</dependentAssembly>
</dependency>
<dependency>
</assembly>

In addition I add this to my code:

INITCOMMONCONTROLSEX iex = { sizeof(INITCOMMONCONTROLSEX),
ICC_COOL_CLASSES|ICC_STANDARD_CLASSES|ICC_TAB_CLASSES|ICC_USEREX_CLASSES };
InitCommonControlsEx(&iex);


Thanks, Sven. It's good to know that it can work :)

Yes, I have InitCommonControlsEx. I don't see an ID anywhere and don't see
any documentation about an ID. This is what I am getting for a manifest
file (embedded by VS2008 using the #pragma
comment(linker,"/manifestdependency....)

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
<security>
<requestedPrivileges>
<requestedExecutionLevel level="asInvoker"
uiAccess="false"></requestedExecutionLevel>
</requestedPrivileges>
</security>
</trustInfo>
<dependency>
<dependentAssembly>
<assemblyIdentity type="win32" name="Microsoft.VC90.DebugCRT"
version="9.0.21022.8" processorArchitecture="x86"
publicKeyToken="1fc8b3b9a1e18e3b"></assemblyIdentity>
</dependentAssembly>
</dependency>
<dependency>
<dependentAssembly>
<assemblyIdentity type="win32" name="Microsoft.VC90.ATL"
version="9.0.21022.8" processorArchitecture="x86"
publicKeyToken="1fc8b3b9a1e18e3b"></assemblyIdentity>
</dependentAssembly>
</dependency>
<dependency>
<dependentAssembly>
<assemblyIdentity type="win32"
name="Microsoft.Windows.Common-Controls" version="6.0.0.0"
processorArchitecture="x86" publicKeyToken="6595b64144ccf1df"
language="*"></assemblyIdentity>
</dependentAssembly>
</dependency>
</assembly>
 
S

SvenC

Hi Scott,
Yes, I have InitCommonControlsEx.

I guess you call it as early as possible?
I don't see an ID anywhere and don't see
any documentation about an ID.

I meant the resource ID. Just open your dll with Visual Studio as resource
file.
You should see an RT_MANIFEST section with hopefully one entry named 2.
A manifest with ID 1 is for exe files, ID 2 is for dll files.
This is what I am getting for a manifest
file (embedded by VS2008 using the #pragma
comment(linker,"/manifestdependency....)

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
....

The manifest itself looks good to me.
 
S

Scott McPhillips [MVP]

SvenC said:
Hi Scott,


I guess you call it as early as possible?


I meant the resource ID. Just open your dll with Visual Studio as resource
file.
You should see an RT_MANIFEST section with hopefully one entry named 2.
A manifest with ID 1 is for exe files, ID 2 is for dll files.

...

The manifest itself looks good to me.


Thanks for the info Sven. Yes, that all looks good: when I open the DLL I
see the RT_MANIFEST with a 2 and I see the common controls dependency in
there with the binary viewer, but alas, still no pretty buttons.
 
S

SvenC

Yes, I have InitCommonControlsEx.
Thanks for the info Sven. Yes, that all looks good: when I open the DLL I
see the RT_MANIFEST with a 2 and I see the common controls dependency in
there with the binary viewer, but alas, still no pretty buttons.

I use only property sheets in the Office COM Addin and its tabs and buttons
are shown in XP style.

How do you create the buttons which do not get XP themed?
Custom dialogs in an RC file?
 
S

Scott McPhillips [MVP]

SvenC said:
I use only property sheets in the Office COM Addin and its tabs and
buttons
are shown in XP style.

How do you create the buttons which do not get XP themed?
Custom dialogs in an RC file?


Yes, just very ordinary dialog templates in an RC file. And for controls I
have only buttons, edits, statics and one tab.
 
S

SvenC

Hi Scott,
Yes, just very ordinary dialog templates in an RC file. And for controls
I have only buttons, edits, statics and one tab.

Strange. If you want you can send me your dialog definition and the
code how you create the dialog then I will add it to my addin and see
how it displays.
 
S

Scott McPhillips [MVP]

That would be much appreciated, Sven.
Please email your email address to me scottmcp at mvps.org
 
S

SvenC

How do you create the buttons which do not get XP themed?
Just for the records, as we solved this offline:

Deriving a dialog from CAxDialogImpl prevents XP theming.
If possible, use CDialogImpl instead.
 
S

Scott McPhillips [MVP]

And thank you for that Sven! :)

SvenC said:
Just for the records, as we solved this offline:

Deriving a dialog from CAxDialogImpl prevents XP theming.
If possible, use CDialogImpl instead.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top