10

I'm trying to let the user choose if he wants to use themed style or not. Is it possible to dynamically "load" the XPManifest?

If user accepts the themed style then use the manifest, otherwise use the classic theme. At program startup after dialog with style selection closes I would like to do something like:

if UserWantsThemedStyle then
  LoadManifestSomehow
else
  UseClassicStyle;

Is it even possible to do it at runtime?

Thanks

TLama
  • 75,147
  • 17
  • 214
  • 392
  • 1
    Check this question http://stackoverflow.com/questions/4393723/how-to-switch-an-application-between-themed-and-not-themed-at-run-time – RRUZ Sep 23 '11 at 14:42

1 Answers1

12

Yes you can do this. You need to use the activation context API which allows you to activate different manifests at runtime. I have used it to enable themes in an Excel add-in.

David Heffernan
  • 601,492
  • 42
  • 1,072
  • 1,490
  • thanks. Looks like what I'm looking for. I found [your answer](http://stackoverflow.com/questions/5132679/apply-windows-theme-to-office-com-add-in/5133222#5133222) but I don't get how to use it. I'm using Delphi 2009, so I have to modify your code a bit to compile. I'll paste it in my question. – TLama Sep 23 '11 at 09:45
  • The code in that question is fine in D6 I think. I was using D6 when I wrote it. You may need to put the manifest into a separate DLL rather than your exe to avoid it being picked up and applied by the loader. – David Heffernan Sep 23 '11 at 09:49
  • yeah I see it now. So that's my problem. So if I put it into a dll and load this dll then I get it to work? – TLama Sep 23 '11 at 09:59
  • One way to do it would be to put the activation context code into a DLL and make the act of loading that DLL perform the activation. Or you could just have a pure resource DLL that contained the manifest and activate it from the exe. Looking at my code, I don't understand why I set both lpSource and hModule. That seems unnecessary. – David Heffernan Sep 23 '11 at 10:07
  • Actually, looking at the activation context documentation again, it seems that you can just supply a file rather than a bound resource. That might be easier for you, certainly whilst testing this out. – David Heffernan Sep 23 '11 at 10:34