Results 1 to 8 of 8

Thread: VB - Give Your App An XP Theme (With Embedded Manifest File)

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Sep 2006
    Location
    Scotland
    Posts
    1,054

    VB - Give Your App An XP Theme (With Embedded Manifest File)

    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.

    Code:
    <?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:

    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:

    Code:
    #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:

    Code:
    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!!!
    Last edited by 03myersd; Apr 18th, 2008 at 06:05 AM.

  2. #2
    PowerPoster Radjesh Klauke's Avatar
    Join Date
    Dec 2005
    Location
    Sexbierum (Netherlands)
    Posts
    2,244

    Re: VB - Give Your App An XP Theme (With Embedded Manifest File)

    Great tuto Helpful.


    If you found my post helpful, please rate it.

    Codebank Submission: FireFox Browser (Gecko) in VB.NET, Load files, (sub)folders treeview with Windows icons

  3. #3
    Member
    Join Date
    Oct 2007
    Posts
    39

    Re: VB - Give Your App An XP Theme (With Embedded Manifest File)

    What and how would we edit the manifest file to make it show what vista instead of xp?

    cheers

  4. #4

    Thread Starter
    Frenzied Member
    Join Date
    Sep 2006
    Location
    Scotland
    Posts
    1,054

    Re: VB - Give Your App An XP Theme (With Embedded Manifest File)

    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.

  5. #5
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    Re: VB - Give Your App An XP Theme (With Embedded Manifest File)

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

  6. #6
    Junior Member
    Join Date
    Jan 2008
    Posts
    26

    Re: VB - Give Your App An XP Theme (With Embedded Manifest File)

    noob question - where is rc.exe?


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

  7. #7

    Thread Starter
    Frenzied Member
    Join Date
    Sep 2006
    Location
    Scotland
    Posts
    1,054

    Re: VB - Give Your App An XP Theme (With Embedded Manifest File)

    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.

  8. #8
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    Re: VB - Give Your App An XP Theme (With Embedded Manifest File)

    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

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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width