Windows XP Style controls in your MFC/WIN32 Applications

Discussion in 'MFC' started by shabbir, Apr 23, 2006.

  1. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    This article will show you how you can convert all your applications from Windows 98 looks to the Windows XP looks. Its just too simple and does not require any code changes from the developers point of view. Other all things are expected to work as normal.

    Note that MSDN requires you to call InitCommonControls by linking to ComCtl32.lib but I dont see any need for the same in the below mention process but if it doesn't work you can try it out. Try calling the function InitCommonControls in the initinstance of your application.

    1. Just create a simple text file using any normal text editor like notepad and put the following content into the file and save it as ExeName.exe.manifest.
    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="CompanyName.ProductName.YourApplication"
        type="win32"
    />
    <description>Your application description here.</description>
    <dependency>
        <dependentAssembly>
            <assemblyIdentity
                type="win32"
                name="Microsoft.Windows.Common-Controls"
                version="6.0.0.0"
                processorArchitecture="X86"
                publicKeyToken="6595b64144ccf1df"
                language="*"
            />
        </dependentAssembly>
    </dependency>
    </assembly>
    
    2. Go to the File Viewer window and add the ExeName.exe.manifest file to your workspace.
    3. Add the following line into the RC fle of your application
    CREATEPROCESS_MANIFEST_RESOURCE_ID RT_MANIFEST "ExeName.exe.manifest"

    Note : Remember if you are using some other DLL's for the resources then you need to be adding the
    CREATEPROCESS_MANIFEST_RESOURCE_ID RT_MANIFEST "ExeName.exe.manifest"
    to each of the resouces dll as well as to the executables.

    Sample output
    Default them
    [​IMG]

    XP theme
    [​IMG]

    The attached zipped file contains the source as well as the executable.
     

    Attached Files:

    Last edited: Jan 21, 2017
  2. coderzone

    coderzone Super Moderator

    Joined:
    Jul 25, 2004
    Messages:
    736
    Likes Received:
    38
    Trophy Points:
    28
    Really nice article.
     
  3. THRESHE

    THRESHE New Member

    Joined:
    Dec 18, 2006
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    Thanks a lot. It's the only site where I've found this example :)
     
  4. 4688.ankit

    4688.ankit New Member

    Joined:
    Sep 26, 2007
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    attatched code(zip file) not working
     
  5. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    What seems to be not working?
     
  6. 4688.ankit

    4688.ankit New Member

    Joined:
    Sep 26, 2007
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    i opened the project in vc++ 6.0 .it ran successfully but the dialog box didn't have the XP look i.e the buttons,progressbars,etc were the same as they come normally in vc++ 6.0
     
  7. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    You should have the manifest variable defined. Try getting the value of it instead of the macro in the rc file.
     
  8. johnsvakel

    johnsvakel New Member

    Joined:
    Jan 21, 2008
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    0
    Nice article, very useful, thanx a lot :thinking:
     
  9. alirizwan84

    alirizwan84 New Member

    Joined:
    Feb 4, 2008
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    Well article is a good one and trick works but only for an MFC application.What about Win32 applications.I tried it in Win32 application but nothing happens.It works for Win32 application only if the manifest file is in the same folder in which the exe file is otherwise not.Plz tell how to embedd the manifest file directly in the Win32 application as u have done in ur MFC project.
     
  10. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    Did you try adding the manifest as a resource to the project in Win32
     
  11. elec.shabnam

    elec.shabnam New Member

    Joined:
    Feb 13, 2008
    Messages:
    102
    Likes Received:
    0
    Trophy Points:
    0
    Excellent but i am just started to study prog.
     
  12. parvez.yu

    parvez.yu New Member

    Joined:
    Feb 14, 2008
    Messages:
    100
    Likes Received:
    0
    Trophy Points:
    0
    nice example
     
  13. ashruuk

    ashruuk New Member

    Joined:
    Feb 28, 2009
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    Can I Use this method in Regular MFC DL?
    ,How?
    Plz Help Me.

    Thankx In Advance
     
  14. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    What you mean by Regular and is there anything called irregular ?
     
  15. dabo

    dabo New Member

    Joined:
    May 8, 2009
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    I'm having trouble too. First of all, in order to make the sample code work I had to set "Enable Incremental Linking" to "No". Otherwise I got this error while linking:

    1>Linking...
    1>CVTRES : fatal error CVT1100: duplicate resource. type:MANIFEST, name:1, language:0x0409
    1>LINK : fatal error LNK1123: failure during conversion to COFF: file invalid or corrupt

    Doing the same to my project didn't help though, it linked successfully but my application now exits right away. Does anyone have any ideas what might be wrong?
     
  16. dabo

    dabo New Member

    Joined:
    May 8, 2009
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    Sry I was too quick to read, forgot to make the InitCommonControls call. Now it works.
     
  17. hypheni

    hypheni New Member

    Joined:
    Aug 4, 2009
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    The post is really Awesome... I found this after a long googling... Thanks a lot...
     
  18. Michaelzee

    Michaelzee New Member

    Joined:
    Aug 8, 2009
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    Thanks a ton for the article. The example program really helped me out too.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice