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

How to enable visual styles in BHO

14 views
Skip to first unread message

Pyerwoh

unread,
Aug 23, 2005, 4:58:04 PM8/23/05
to
Greetings,

I am wondering how to enable visual styles on a windows form that is created
by a BHO? I created the BHO in C# and I have tried the usual method of
calling Application.EnableVisualStyles(), but that does not work, and usually
causes IE to crash.

Any thoughts?

Thanks,
Peter

Igor Tandetnik

unread,
Aug 23, 2005, 8:33:23 PM8/23/05
to
"Pyerwoh" <Pye...@discussions.microsoft.com> wrote in message
news:05DB1AB9-31E5-4F87...@microsoft.com

> I am wondering how to enable visual styles on a windows form that is
> created by a BHO?

http://msdn.microsoft.com/library/en-us/mmc/mmc/supporting_visual_styles_in_snap_ins.asp

It talks about MMC snap-ins, but the same technique has to be done by
any DLL that creates windows and wants them to be themed.
--
With best wishes,
Igor Tandetnik

With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925


Ismail Pazarbasi

unread,
Aug 24, 2005, 8:52:48 AM8/24/05
to
it's about manifest file. I still couldn't "succeed" adding a manifest
file into my module's resources in C# (I would appreciate if someone
shows me something other than opening _exe_ in IDE and adding a
RT_MANIFEST... does C# have resources or something like that?), but in
my C++ BHO, I used a manifest file, and it worked.

Ismail

Pyerwoh

unread,
Aug 24, 2005, 4:37:03 PM8/24/05
to
Thanks for the comments Igor.

How is this done when your assembly is not an exe, but a dll? The only way
I was able to get it to work was to create a manifest for iexplore.exe and
copy it to the Internet Explorer folder, which does enable xp themes --- is
this the accepted way of doing it?

Thanks,
Peter

Igor Tandetnik

unread,
Aug 24, 2005, 4:54:58 PM8/24/05
to
Pyerwoh <Pye...@discussions.microsoft.com> wrote:
> "Igor Tandetnik" wrote:
>
>> "Pyerwoh" <Pye...@discussions.microsoft.com> wrote in message
>> news:05DB1AB9-31E5-4F87...@microsoft.com
>>> I am wondering how to enable visual styles on a windows form that is
>>> created by a BHO?
>>
>> http://msdn.microsoft.com/library/en-us/mmc/mmc/supporting_visual_styles_in_snap_ins.asp
>>
>> It talks about MMC snap-ins, but the same technique has to be done by
>> any DLL that creates windows and wants them to be themed.
>
> How is this done when your assembly is not an exe, but a dll?

An MMC snap-in _is_ a DLL. The article applies to any DLL, and does
_not_ apply to EXEs. I don't understand your question.

Pyerwoh

unread,
Aug 24, 2005, 5:15:06 PM8/24/05
to
Ok, well this is what i have figured out so far. My experience in c++/mfc is
minimal, so I am trying to muddle my way through.

As instructed in the MSDN article, I created a manifest file, added a
reference to the Microsoft Common Control, but I got lost trying to figure
out how to 'Set the ISOLATION_AWARE_ENABLED directive' or to reference the
manifest file. (Not sure how to translate this into .net/c#) .

Maybe i should just ask the question of how to complete the final steps from
the article using C#?

Thanks,
Peter


Thanks,
Peter

Ismail Pazarbasi

unread,
Aug 25, 2005, 4:33:46 AM8/25/05
to
Peter, what you need to do is adding resource manifest into your
resource file. However, as far as I know, there is no "resource file"
for C# projects. If I am wrong, please correct me and show how to do
it. What I have seen on the web, C# people do "File->Open" and open
module's resources in IDE, then add manifest file there. Manifest
resource ID should be 2. Did you check this?

Ismail

Ismail Pazarbasi

unread,
Aug 25, 2005, 4:51:27 AM8/25/05
to
Igor, are you sure it differs from dll to exe? May be, resource ID
could be different.

Ismail

Igor Tandetnik

unread,
Aug 25, 2005, 7:42:38 AM8/25/05
to
"Ismail Pazarbasi" <paza...@gmail.com> wrote in message
news:1124959887....@o13g2000cwo.googlegroups.com

> Igor, are you sure it differs from dll to exe? May be, resource ID
> could be different.

Yes it's different. An EXE should use CREATEPROCESS_MANIFEST_RESOURCE_ID
(defined as 1), a DLL should use ISOLATIONAWARE_MANIFEST_RESOURCE_ID
(defined as 2).

Ismail Pazarbasi

unread,
Aug 26, 2005, 3:44:28 AM8/26/05
to
Oh, yes, that's exactly what I thought.

Ismail

Seb

unread,
Aug 26, 2005, 4:12:25 AM8/26/05
to
Hello,

I have the same pb, I don't arrive displaying a ATL Dialog Box with a
XP Style.
I rode the article propose by Igor but it didn't works.
I don't understand my mistake.

This is the description of my process:

- I created a manifest file
- In the beginning of the stdafx.h file I added :
#define ISOLATION_AWARE_ENABLED 2
#define MANIFEST_RESOURCE_ID 2
- In the end of stdafx.h, I added :
#include "commctrl.h"
- I added in the MyBho.rc the following line:
MANIFEST_RESOURCE_ID RT_MANIFEST "res\\MyBho.manifest"

I tested this but I keep the same style :(
Natturaly I'm using XP.
Do you see my mistake ?

Thx

Seb

Ismail Pazarbasi

unread,
Aug 26, 2005, 4:48:27 AM8/26/05
to
Ok, your manifest file could be unicode? I guess it doesn't work if
manifest file is unicode. Open file in a binary editor. If you see
unicode BOM at the beginning of the message (2 bytes AFAIK), then it's
unicode.

Ismail

Seb

unread,
Aug 26, 2005, 7:08:05 AM8/26/05
to
No it isn't an unicode file

Seb

unread,
Aug 26, 2005, 7:48:22 AM8/26/05
to
Do you see an other thing ?
Can be you have a little project which works to help me ?

Thx

Seb

Igor Tandetnik

unread,
Aug 26, 2005, 8:00:15 AM8/26/05
to
"Seb" <kipco...@gmail.com> wrote in message
news:1125043945.8...@g47g2000cwa.googlegroups.com

> This is the description of my process:
>
> - I created a manifest file
> - In the beginning of the stdafx.h file I added :
> #define ISOLATION_AWARE_ENABLED 2
> #define MANIFEST_RESOURCE_ID 2

Put that into resource.h, not stdafx.h. The former is included in .rc,
the latter is not, so the resource compiler never sees your define.

Alternatively, write

ISOLATIONAWARE_MANIFEST_RESOURCE_ID RT_MANIFEST "res\\MyBho.manifest"

ISOLATIONAWARE_MANIFEST_RESOURCE_ID is already defined appropriately.

Seb

unread,
Aug 26, 2005, 8:44:20 AM8/26/05
to
Thx Igor,

but I always have the same problem :(
It isn't work.

One query, what is the difference between the rc file and the rc2 file
?
Do you know where I can find a sample ?

I repeat my new process:

In Stdafx.h :
#include "commctrl.h"

In resource.h (in beginning):


#define ISOLATION_AWARE_ENABLED 2
#define MANIFEST_RESOURCE_ID 2

MyDll.manifest (in the 'res' directory) :

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


MyDll.rc :

#include "resource.h"

ISOLATIONAWARE_MANIFEST_RESOURCE_ID RT_MANIFEST "res\\MyDll.manifest"

Igor Tandetnik

unread,
Aug 26, 2005, 9:33:07 AM8/26/05
to
Seb <kipco...@gmail.com> wrote:
> One query, what is the difference between the rc file and the rc2 file
> ?

None really. Just a naming convention. The IDE manages the .rc file for
you, inserting and removing pieces as you work in resource editors, so
it is somewhat difficult to put handwritten code in there. So when one
needs to, it is customary to create a .rc2 file, put any custom code
there, and #include it in .rc . The IDE does not touch .rc2.

By the way, to include anything in .rc and make sure it stays put, do
the following. In the IDE, open Resource Viewer, right-click on
ProjectName.rc node and choose Resource Includes. A dialog appears with
two large edit boxes. Whatever you put in the top box will appear at the
beginning of your .rc file. It usually already contains #include
"winres.h" line - put any additional headers there. The contents of the
bottom box will be placed at the end of .rc file. You can specify some
resource statements there directly (e.g. the one-liner that includes the
manifest) or you can #include "your.rc2" if you have a lot of custom
resource code that you want to conveniently edit in a regular code
editor.

> Do you know where I can find a sample ?
>
> I repeat my new process:
>
> In Stdafx.h :
> #include "commctrl.h"
>
> In resource.h (in beginning):
> #define ISOLATION_AWARE_ENABLED 2

That goes into stdafx.h, not into resource.h - and make sure you put it
at the very top, before including any Windows headers.

> #define MANIFEST_RESOURCE_ID 2

That one goes into resource.h - or, if you use
ISOLATIONAWARE_MANIFEST_RESOURCE_ID, you don't need it at all.

Seb

unread,
Aug 26, 2005, 10:13:21 AM8/26/05
to
Why my pig don't want flying :(
I"m trying, I'm trying but no Xp style...

I'm despairing ...
Fly fly my pig

Other ideas Igor ?

Seb

Seb

unread,
Aug 29, 2005, 4:08:53 AM8/29/05
to
OK it works :D

Thank you very much guru Igor.

0 new messages