Thread: Win32 API , Windows XP Button styles

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User dalek's Avatar
    Join Date
    May 2003
    Posts
    135
    Unfortunately its a little more difficult than just adding a style (which is what I had hoped you could do initialy!). You need to include a windows manifest file as a resource and init the common controls. There is a brief link here describing the process. If you have any other troubles getting it to work, come back and ask.
    Last edited by dalek; 05-26-2004 at 03:33 AM.

  2. #2
    Registered User Rare177's Avatar
    Join Date
    May 2004
    Posts
    214

    Thanks!!

    ok thanks for that.gave me a clear understanding 1 thing.
    how do i include this in a C , win32 api program.thanks

  3. #3
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    Using Windows XP Visual Styles

    Perhaps the quickest/shortest route is to link with comctl32.lib, use InitCommonControlsEx and include the manifest file in the same directory as the executable. For example:
    Code:
    #include <windows.h>
    #include <tchar.h>
    
    #if defined __MINGW_H
    #define _WIN32_IE 0x0400
    #endif
    
    #include <commctrl.h> /*link with comctl32.lib (-lcomctl32 with DevCpp(MinGW))*/
    
    int WINAPI _tWinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,
                         LPTSTR lpCmdLine,int nCmdShow)
    {
    INITCOMMONCONTROLSEX iccx;
    iccx.dwSize=sizeof(INITCOMMONCONTROLSEX);
    iccx.dwICC=0;
    InitCommonControlsEx(&iccx);
    
    MessageBox(0,
      _T("Don't forget to include your xp manifest\nin the same directory as this exe."),
      _T("XP Manifest Styles"),
      MB_OK);
    return 0;
    }
    Build that and call the exe 'manifest_demo.exe' then save the following as manifest_demo.exe.manifest in the same directory:
    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.manifest_demo.exe"
      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>
    Last edited by Ken Fitlike; 05-26-2004 at 06:14 AM.
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. BN_CLICKED, change button style
    By bennyandthejets in forum Windows Programming
    Replies: 13
    Last Post: 07-05-2010, 11:42 PM
  2. Question..
    By pode in forum Windows Programming
    Replies: 12
    Last Post: 12-19-2004, 07:05 PM
  3. Windows XP visual styles
    By larry in forum Windows Programming
    Replies: 9
    Last Post: 08-09-2003, 02:09 PM
  4. Windows XP visual styles in C#?
    By Shag in forum C# Programming
    Replies: 3
    Last Post: 03-26-2003, 06:25 AM