VC dialogs & XP themes

  • Thread starter Thread starter Egbert Nierop \(MVP for IIS\)
  • Start date Start date
E

Egbert Nierop \(MVP for IIS\)

When I build some add-ins for the management console using C++, the add-ins
made by me show a Win2000 interface while the rest of the add-ins made by MS
are using XP themes.

What am I missing?

Cheers
 
Am I correct to say that ATL (shipped with Vstudio 2003 as well) simply does
not work with theming?

I don't see the connection. What has ATL to do with XP themes?

One of the limitations imposed by VS2003 (that wasn't in VS2002) is
that only Unicode builds get a manifest - so non-Unicode builds won't
appear themed. Is that perhaps the situation you're hitting?

Dave
 
David Lowndes said:
I don't see the connection. What has ATL to do with XP themes?

I Know that ATL is not WTL but ATL has a lot of DialogImpl tools and VC
allows you to edit dialogs by using the resource editor.

There is a XPTHeme.cpp file, but I'm still puzzled why MS did not support
that out of the box or I'm simply missing some hidden feature?


What I did:
1) #include "commctrl.h"
2) #define ISOLATION_AWARE_ENABLED 1 (!! if you leave out the 1, it will not
compile!)3) #define MANIFEST_RESOURCE_ID 2
In the rc file
MANIFEST_RESOURCE_ID RT_MANIFEST "myDll.dll.manifest"(manifest contents not
shown here in this post)
One of the limitations imposed by VS2003 (that wasn't in VS2002) is
that only Unicode builds get a manifest - so non-Unicode builds won't
appear themed. Is that perhaps the situation you're hitting?

No, I stopped compiling for Win98 and ANSI compatible apps already 5 years
ago.
 
What I did:
1) #include "commctrl.h"
2) #define ISOLATION_AWARE_ENABLED 1 (!! if you leave out the 1, it will not
compile!)3) #define MANIFEST_RESOURCE_ID 2
In the rc file
MANIFEST_RESOURCE_ID RT_MANIFEST "myDll.dll.manifest"(manifest contents not
shown here in this post)

Other than compiling with the definition you mention, ensuring the
definition is visible for the appropriate include files, and ensuring
that your DLL really does have the manifest resource (open the DLL in
VS to be sure), I'm not aware that you have to do anything else to get
themes to work (though I've never tried with an MMC snap-in)

The following says pretty much the same:

http://msdn.microsoft.com/library/en-us/shellcc/platform/commctls/userex/cookbook.asp?frame=true#mmc

Dave
 
It's not enough to add the manifest in your resource's textinclude, but
you need to add it to your resource.h file as well, if it's not in
there.
 
It's not enough to add the manifest in your resource's textinclude, but
you need to add it to your resource.h file as well, if it's not in
there.

Huh?

Please explain what you mean.

Dave
 
David Lowndes said:
Other than compiling with the definition you mention, ensuring the
definition is visible for the appropriate include files, and ensuring
that your DLL really does have the manifest resource (open the DLL in
VS to be sure), I'm not aware that you have to do anything else to get
themes to work (though I've never tried with an MMC snap-in)

Sure I did!
thanks however for the hint.
 
David Lowndes said:
Other than compiling with the definition you mention, ensuring the
definition is visible for the appropriate include files, and ensuring
that your DLL really does have the manifest resource (open the DLL in
VS to be sure), I'm not aware that you have to do anything else to get
themes to work (though I've never tried with an MMC snap-in)

The following says pretty much the same:

http://msdn.microsoft.com/library/en-us/shellcc/platform/commctls/userex/cookbook.asp?frame=true#mmc

Indeed.
And such as docs suggest. MFC with C++.NET can by design handle themes if
you only add the resource stuff and the flags.

And ATL does not. If somebody can confirm me this, I simply know the next
step.

(Before someone says that ATL is not graphical such as MFC or WTL, I must
slightly disagree, ATL supports MMC snapins).
 
If you use ATL, no support for XP Theming is available.

I can't see how you conclude something like that (other than the fact
that it's apparently not working in your circumstance).

What relevance has that article with ATL? It's title says it's for
owner drawn controls? Do you use an owner drawn control in your ATL
based MMC snap-in?

Dave
 
David Lowndes said:
I can't see how you conclude something like that (other than the fact
that it's apparently not working in your circumstance).


What relevance has that article with ATL?

Why ask about relevance. If you know a better group, please tell me.
It's title says it's for
owner drawn controls? Do you use an owner drawn control in your ATL

The fact is, that non-owner drawn controls in ATL wont have XP styles.
Another fact is that developers in C# for instance, without a lot of
modification, can support styles and I've red the same about MFC.

ATL is left over. MS should make a clear point about their ATL support like
"ATL development has been frozen since 2000".

Now I'm not 100% sure whether or not I can support themes using the current
code or not.

based MMC snap-in?


Everything that I meet during development is ATL related.
If I do MFC, I would post it in MFC.
 
I mean:

3 TEXTINCLUDE
BEGIN
"CREATEPROCESS_MANIFEST_RESOURCE_ID RT_MANIFEST
"".\\myapp.exe.manifest""\r\n"
"\0"
END


CREATEPROCESS_MANIFEST_RESOURCE_ID RT_MANIFEST ".\myapp.exe.manifest"

in .rc file is not enough to enable visual styles. it also needs

#define IDR_MANIFEST 1

in resource.h
 
I know for a fact you can get XP themes to work in an atl dll. I have a
BHO built using ATL that has themes enabled in all of its dialog boxes.
If the host app supports linking in the commctrl dll via the isloation
aware method, then your atl dll should too..

Here is what I did.

1. added
/D ISOLATION_AWARE_ENABLED
to the command line args in the project properties. This is so it is
top level

2. added the standard manifest for common control v6 as a resource type
RT_MANIFEST and changed the id to 2.

3. in resource.h define IDR_MANIFEST to be 2

worked for me
 
Solution:
It has to be defined in resource.h and not in stdafx.h

For some, this might be obvious if the MSDN mentions this, but the MSDN does
only say:
Define a manifest resource ID of 2.

#define MANIFEST_RESOURCE_ID 2 Solution:had to be done in resource.h and not
in stdafx.h.Now it works!
 
Couple of months ago, I have realized that my application doesn't
support visual styles, even though I have added it into my .rc file.
Then I compared the project's .rc and resource.h files with another
project's ones (written with WTL), which supports visual styles, and I
have seen that IDR_MANIFEST is not defined in former one. This is why I
told you that it's not enough to have manifest in your .rc but you also
need to #define it in your resource.h.

I am not sure why, but, for example, having TYPELIB in .rc file is also
insufficient to embed type library in COM dll, if it's not defined in
resource.h.

May be this is not related to resource IDs, but with resource count.
Because I have defined my manifest resource id 241, and it worked as
well.

Ismail
 
Ismail Pazarbasi said:
Couple of months ago, I have realized that my application doesn't
support visual styles, even though I have added it into my .rc file.
Then I compared the project's .rc and resource.h files with another
project's ones (written with WTL), which supports visual styles, and I
have seen that IDR_MANIFEST is not defined in former one. This is why I
told you that it's not enough to have manifest in your .rc but you also
need to #define it in your resource.h.

I am not sure why, but, for example, having TYPELIB in .rc file is also
insufficient to embed type library in COM dll, if it's not defined in
resource.h.

May be this is not related to resource IDs, but with resource count.
Because I have defined my manifest resource id 241, and it worked as
well.

I can explain. If you don't define the correct resource_id, the typelibrary
won't be found by Windows by using FindResourceEx(..) or LoadMenu(..)
LoadTypeLib ...etc. A resource id is usedin those parameters.

The C++ compiler does not warn you if you forgot to define a resource id. I
found by opening the DLL in resource edit mode, that the manifest was having
an ID of 0.
 
in my resource.h:

#define IDR_MYTYPELIB 1111

in my .rc

1 TYPELIB "navigation.tlb"

this works fine. I am not sure whether this is "the correct" way, I
have seen this example on KB. What I don't understand here is the
relationship between IDR_MYTYPELIB and the typelib resource in .rc.
IDR_MYTYPELIB is not used in .rc. Same applies to manifest. I have
changed my manifest id to 241 in .h, it works again, but not used that
name/id in .rc.
 
Back
Top