Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

XP Button theme in COM add-in

13 views
Skip to first unread message

Scott McPhillips [MVP]

unread,
Mar 24, 2009, 1:37:09 PM3/24/09
to
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?

--
Scott McPhillips [VC++ MVP]

SvenC

unread,
Mar 24, 2009, 3:35:32 PM3/24/09
to
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);

--
SvenC

Scott McPhillips [MVP]

unread,
Mar 24, 2009, 7:25:29 PM3/24/09
to
"SvenC" <Sv...@nospam.nospam> wrote in message
news:efvSzeLr...@TK2MSFTNGP03.phx.gbl...


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>

SvenC

unread,
Mar 25, 2009, 3:54:14 AM3/25/09
to
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.

--
SvenC

Scott McPhillips [MVP]

unread,
Mar 25, 2009, 9:41:02 AM3/25/09
to
"SvenC" <Sv...@nospam.nospam> wrote in message
news:u0Zxl7Rr...@TK2MSFTNGP03.phx.gbl...


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.

SvenC

unread,
Mar 25, 2009, 1:19:53 PM3/25/09
to
>>> Yes, I have InitCommonControlsEx.
>>
>> I guess you call it as early as possible?
>
> 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?

--
SvenC

Scott McPhillips [MVP]

unread,
Mar 25, 2009, 8:14:51 PM3/25/09
to
"SvenC" <Sv...@nospam.nospam> wrote in message
news:Op18q3Wr...@TK2MSFTNGP02.phx.gbl...

> 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.

SvenC

unread,
Mar 27, 2009, 5:05:23 AM3/27/09
to
Hi Scott,

>> 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.

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.

--
SvenC

Scott McPhillips [MVP]

unread,
Mar 27, 2009, 10:02:20 AM3/27/09
to
That would be much appreciated, Sven.
Please email your email address to me scottmcp at mvps.org

"SvenC" <Sv...@nospam.nospam> wrote in message

news:%23CVvqsr...@TK2MSFTNGP05.phx.gbl...

--
Scott McPhillips [VC++ MVP]

SvenC

unread,
Mar 28, 2009, 4:24:51 AM3/28/09
to
>>>> 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.

Just for the records, as we solved this offline:

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

--
SvenC

Scott McPhillips [MVP]

unread,
Mar 28, 2009, 4:19:52 PM3/28/09
to
And thank you for that Sven! :)

"SvenC" <Sv...@nospam.nospam> wrote in message

news:Ooaer63r...@TK2MSFTNGP06.phx.gbl...


> Just for the records, as we solved this offline:
>
> Deriving a dialog from CAxDialogImpl prevents XP theming.
> If possible, use CDialogImpl instead.
>
> --
> SvenC

--
Scott McPhillips [VC++ MVP]

0 new messages