.netwindowsdelphidelphi-6

What is the native call equivalent to Application.EnableVisualStyles?


I have a legacy windows application that is having screen rendering problems with the latest Win10 Creators update. I see .NET applications can resolve the issue by calling Application.EnableVisualStyles. However given that my app was written pre dotnet (in Delphi 6) I hope there is a native system call that I can use to do the same thing.


Solution

  • In Delphi 6, you cannot use visual styles directly. You need to use a third party library, Mike Lischke's Windows XP Theme Manager. In fact this library formed the basis of the built in support that was included in Delphi 7, as can readily be observed by reading the source code.

    In order to use this in your Delphi 6 program you need to take the following steps:

    1. Include the XP Theme Manager library in your project.
    2. Link an application manifest resource to your executable that specifies comctl32 v6. There are many resource online explaining how to do this, I won't repeat them here.

    Note that if your program does not currently link an application manifest then you might find that other behaviour changes when you do so. Without a manifest, a program is virtualized under UAC. With a manifest, virtualization is disabled. Now, virtualization was introduced in Vista back in 2005 as a crutch to help developers adapt to changes introduced with UAC. If you still have not adapted your program to UAC, then I would suggest that it is perhaps high time that you do so!