Professional UI Solutions
Site Map   /  Register
 
 

Forum

Please Log In to post a new message or reply to an existing one. If you are not registered, please register.

NOTE: Some forums may be read-only if you are not currently subscribed to our technical support services.

Forums » Prof-UIS General Discussion » XP style controls Collapse All
Subject Author Date
Suhai Gyorgy Sep 28, 2005 - 8:09 AM

Dear Support,


I’d like to use XP style controls in my dialogbox created from resource file. Since I don’t want my dialog to be resizable I haven’t used your CExtResizableDialog class but instead the usual CDialog. What settings should I use to have my controls in XP style, like for example rounded-cornered pushbuttons and flat editboxes? Is it some kind of style that I should set in my resource file?


Thank you for all your help, Chris.

Suhai Gyorgy Sep 28, 2005 - 8:55 AM

I found the answer, manifest settings were missing. I wonder though how come AppWizard didn’t generated it into my sourcefiles? Thanks anyway

Technical Support Sep 29, 2005 - 6:56 AM

To apply an XP visual style to the common controls in your application, use ComCtl32.dll version 6 or later. Unlike earlier versions of ComCtl32.dll, version 6 is not redistributable. The only way you can use version 6 of the dynamic-link library (DLL) is to use an operating system that contains it. Windows XP ships with both version 5 and version 6. ComCtl32.dll version 6 contains both the user controls and the common controls. By default, applications use the user controls defined in User32.dll and the common controls defined in ComCtl32.dll version 5.

So, to use visual styles in your application, you must add an application manifest that indicates that ComCtl32.dll version 6 should be used if it is available. Below is an XML content of the manifest file:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?> 


<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">

   <assemblyIdentity 

      processorArchitecture="x86" 

      version="5.1.0.0"

      type="win32"

      name="APPLICATION_NAME"

      />

   <description>APPLICATION_DESCRIPTION</description>

   <dependency>

      <dependentAssembly>

         <assemblyIdentity

            type="win32"

            name="Microsoft.Windows.Common-Controls"

            version="6.0.0.0"

            publicKeyToken="6595b64144ccf1df"

            language="*"

            processorArchitecture="x86"

            />

      </dependentAssembly>

   </dependency>

</assembly>

Replace APPLICATION_NAME with the name of your application and APPLICATION_DESCRIPTION with a brief description.

There are two ways to add the manifest file to your application.
  1. Place the XML manifest file in the same directory as your application’s executable file. The manifest should be named YourApp.exe.manifest, which is a name of the application executable file.
  2. Embed the manifest into the application resources.<ul>
  3. First, add the following line to the resource.h file. Just copy and paste the following:
       #define IDR_MANIFEST 1
    Don’t forget to save the file.
  4. In the Resource View window, right click the resource tree and choose Import..., select the manifest file you have just created and press OK to close the dialog.
  5. When the Custom Resource Type dialog opens, enter 24 and press OK.
  6. Rename the newly imported resource under 24 to IDR_MANIFEST.
  7. Rebuild the application.
Please note that you should also initialize the common controls in your application. To do that, call the InitCommonControls() method at the beginning of the application InitInstance() method.