none
C++ MFC Application Looks Dated RRS feed

  • Question

  • All,

    I am working with an old Windows MFC application that looks dated (old fashioned, like Windows 3.1).  What is the best way to update it so it uses the newer style windows in XP and Vista?

    Thank you
    Paul
    Thursday, July 9, 2009 2:47 PM

Answers

  • You could try and make it use the latest manifest via putting this somewhere in your code (stdafx.h for example)



    #if defined _M_IX86
    #pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'\"")
    #elif defined _M_IA64
    #pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='ia64' publicKeyToken='6595b64144ccf1df' language='*'\"")
    #elif defined _M_X64
    #pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='amd64' publicKeyToken='6595b64144ccf1df' language='*'\"")
    #else
    #pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")
    #endif


    Other than that your options are to re-write the UI using another GUI kit. Either the new MFC 2008 Feature pack (visual studio 2008+ only), or QT which I have heard good things about.

    Thanks
    Thursday, July 9, 2009 2:51 PM

All replies

  • You could try and make it use the latest manifest via putting this somewhere in your code (stdafx.h for example)



    #if defined _M_IX86
    #pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'\"")
    #elif defined _M_IA64
    #pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='ia64' publicKeyToken='6595b64144ccf1df' language='*'\"")
    #elif defined _M_X64
    #pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='amd64' publicKeyToken='6595b64144ccf1df' language='*'\"")
    #else
    #pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")
    #endif


    Other than that your options are to re-write the UI using another GUI kit. Either the new MFC 2008 Feature pack (visual studio 2008+ only), or QT which I have heard good things about.

    Thanks
    Thursday, July 9, 2009 2:51 PM
  • Mark,

    Thank you.  I will give it a try and post my findings...
    Paul
    Thursday, July 9, 2009 2:52 PM
  • Or even rewrite the UI in WPF (well the VS 2010 devs did that anyway) :-)
    http://blog.voidnish.com
    Thursday, July 9, 2009 2:53 PM
    Moderator
  • The first step would be to add a common control manifest, so the XP themes will be automatically applied to your controls. 

    Create a new project, with this option checked, and see what you get.  It puts an obscure block that starts like this: #pragma comment(linker,"/manifestdependency....

    ...into your stdafx.h file.  Copying this block into your old project might work.

    BTW, this feature is only available in apps that use unicode.

    There are lots of other visual options available in new MFC projects that use the MFC feature pack, so you might try them out in toy projects to see if anything looks worth doing.  Most of these features (like a ribbon interface) will require reworking the old code and/or porting it into a new project.

    Thursday, July 9, 2009 3:06 PM
  • Hi,

    The common manifest stuff I pasted previously works in none unicode apps (well it does for our MFC app!).

    WFP while interesting has quite a few issues with font rendering and performance with a lot of controls. (Many .Net UI kits have similar performance issues). All in all its a case of try and evaluate each possible solution and take it from there.

    It all depends on how much time and resources you have to effectively re-write your app.

    Thanks.
    Thursday, July 9, 2009 3:09 PM
  • Agree that there's a time/resource issue at play when porting the UI to WPF, but porting to the new MFC feature pack features would involve a non-trivial rewrite anyway.

    Personally speaking, unless his product is really looking for a modern looking UI upgrade, it may be best to just get the XP themes working, and to not worry about getting new UI like ribbons, fancy WPF transforms/animations etc.
    http://blog.voidnish.com
    Thursday, July 9, 2009 3:12 PM
    Moderator
  • If you are doing a complete rewrite of the GUI, then those suggestions are great, but if all you are concerned about is the dated look of the windows themselves...

    What is wrong with registering classes that use the new styles, and letting MFC do what it does best? Why try to force WPF, or .NET on top of the 2 technologies that are built to replace/supplant MFC?

    If all you want are EX style bits, just register your own window classes.

    Thursday, July 9, 2009 4:49 PM