PDA

Click to See Complete Forum and Search --> : VB - Give Your App An XP Theme (With Embedded Manifest File)


03myersd
Oct 18th, 2007, 01:12 PM
I have seen a lot of threads about asking how to give an app an XP theme. There have been almost as many asking how to embed the manifest file so that they don't have to send two files. There is even a similar one here in the code bank. But this one does not require you to install any other programs. After some research I have found that this is the best way:

Step 1: Paste this into a new text file called Exename.exe.manifest, where Exename is the name of your executable. I find that you are best leaving it as project1.exe then rename once you have finished all of these steps.

<?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=" "
type="win32"
/>
<description></description>
<dependency>
<dependentAssembly>
<assemblyIdentity
type="win32"
name="Microsoft.Windows.Common-Controls"
version="6.0.0.0"
processorArchitecture="X86"
publicKeyToken="6595b64144ccf1df"
language="*"
/>
</dependentAssembly>
</dependency>
</assembly>

Step 2: Paste this into your source code:

Private Declare Function InitCommonControls Lib "comctl32.dll" () As Long

Private Sub Form_Initialize()
InitCommonControls
End Sub

Step 3: Paste this into another text file and rename as exename.rc:

#define RT_MANIFEST 24
#define APP_MANIFEST 1

APP_MANIFEST RT_MANIFEST ExeName.exe.manifest



Step 4: Open a new command line session. Then move to the folder where your project and the above files are located. Use this command:

rc.exe /r ExeName.rc

Step 5: Add this newly created Resource file to your project by going to Project and then Add new resource file.

Step 6: Compile.



I have noticed that sometimes this doesn't work instantly. The best thing to do is just delete everything you created in these steps and start again. The other main problem is accidentally not renaming files.

I have also heard that your manifest file should be a multiple of 4 bytes. I don't think that this has ever been an issue for me.



Hope this is useful to everyone out there!!!

Radjesh Klauke
Oct 18th, 2007, 01:56 PM
Great tuto ;) Helpful.

TANOV2-(password :@)
Dec 30th, 2007, 06:37 AM
What and how would we edit the manifest file to make it show what vista instead of xp?

cheers

03myersd
Dec 30th, 2007, 06:45 AM
Im note sure. I don't have vista so I cant test it out. But I guess you would check to see what the most recent version of the Microsoft Common Controls is and change it to that? Thats just a guess though.

dilettante
Dec 30th, 2007, 03:57 PM
Calling InitCommonControls/InitCommonControlsEx in the startup Form's Initialize event handler is sometimes too late. You'll hear a Windows alert sound and never see your program start. Generally it is safer to use a module with Sub Main in it where you make this call, then go ahead and Show your main Form.

The manifest only needs to be a multiple of 4 bytes if you embed it. Otherwise the process of including it as a resource pads it out with NULs to a multiple of 4 bytes, which results in an XML syntax error.

The "doesn't work instantly" seems to have something to do with caching somewhere, either for the filesystem itself or something to do with Windows caching things it "knows" about a program that has run recently. Probably one of those "fast run" things that came out with XP and is carried over to Vista too (prefetch folder).

What and how would we edit the manifest file to make it show what vista instead of xp?
I assume you're hoping to get a "Vista look" on XP by some magic. There's no magic, Vista appearance can't be requested this way. It uses the same technique as XP to get a themed appearance. It simply applies the Vista theme instead of the XP theme.


It's pretty easy to make a simple manifest generator program that will also patch it into another EXE. I think I've seen a few out there.

I use MMM (http://mmm4vb6.atom5.com/mmm-next-generation-1166.html) which also can include the Vista Trust element to bypass Vista's AppCompat shims and if desired request elevated execution. It will either create a separate .manifest file or embed it, your option. Of course MMM's big bonus is registration-free COM for many ActiveX libraries, but that's optional too.

m3fs
Jan 8th, 2008, 09:51 AM
noob question - where is rc.exe?


I try to run it and it give me a file name invalid error.

03myersd
Jan 8th, 2008, 11:32 AM
I have only tried it on a few computers. It works on my three computers at home. All run home edition. The one at school runs pro and it doesn't work. Sorry I can't be more help.

Dilettante has given me some useful information about it which I will put into the post as soon as I have time. Try his link on MMM. I have tried it and found it works extremely well.

dilettante
Jan 11th, 2008, 07:18 PM
I find rc.exe in both:

C:\Program Files\Microsoft Visual Studio\VB98\Wizards

and:

C:\Program Files\Microsoft Visual Studio\Common\MSDev98\Bin

It also installs with the Platform SDK:

Microsoft® Windows® Software Development Kit for Windows Vista™ and .NET Framework 3.0 Runtime Components (http://www.microsoft.com/downloads/details.aspx?familyid=7614FE22-8A64-4DFB-AA0C-DB53035F40A0&displaylang=en)

You can tell it to "take a hike" about the .Net Framework, to save a ton of disk.