Thread: Win32 API , Windows XP Button styles

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

    Win32 API , Windows XP Button styles

    hello , does any one know the style or extended style to make the windows xp button styles(bubble style) in win32 api

  2. #2
    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.

  3. #3
    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

  4. #4
    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.

  5. #5
    Registered User Rare177's Avatar
    Join Date
    May 2004
    Posts
    214
    thanks you all very much

  6. #6
    Registered User Rare177's Avatar
    Join Date
    May 2004
    Posts
    214
    hmm theres only 1 problem thou.if u dont have the manifest file there it doesnt work
    any one know how to fix this?

  7. #7
    Registered User
    Join Date
    Nov 2003
    Posts
    28
    This is what i do..

    1. Create a custom resource called "RT_MANIFEST" without quotes.
    2. Name the resource "1" without quotes.
    3. Paste in the xml code Ken gave you.
    4. Save & Recompile.

    You still need to use the common controls as stated in previous posts.

  8. #8
    Registered User Rare177's Avatar
    Join Date
    May 2004
    Posts
    214
    ok im not sure what im doing wrong but i cant get it to work

  9. #9
    Yes, my avatar is stolen anonytmouse's Avatar
    Join Date
    Dec 2002
    Posts
    2,544
    Paste this into your resource file:
    Code:
    #ifndef RT_MANIFEST
    #define RT_MANIFEST 24
    #endif
    #ifndef CREATEPROCESS_MANIFEST_RESOURCE_ID
    #define CREATEPROCESS_MANIFEST_RESOURCE_ID 1
    #endif
    
    CREATEPROCESS_MANIFEST_RESOURCE_ID  RT_MANIFEST "YourApp.exe.manifest"
    where YourApp.exe.manifest refers to the manifest file you created as per Ken's post. (This is essentially what Marc was describing).

  10. #10
    Registered User Rare177's Avatar
    Join Date
    May 2004
    Posts
    214
    ok thanks...only problem now is that lcc-win32 says its impossible to read the rc file

  11. #11
    Yes, my avatar is stolen anonytmouse's Avatar
    Join Date
    Dec 2002
    Posts
    2,544
    Apparently, lcc does not support RT_MANIFEST. You can grab the free Resource Hacker to add your manifest to the exe.

  12. #12
    Registered User Rare177's Avatar
    Join Date
    May 2004
    Posts
    214
    its not thats its not reading the manifest its that it isnt read the rc files
    its wierd never happened before

  13. #13
    Registered User
    Join Date
    Jan 2006
    Location
    England, Norwich
    Posts
    38
    Hey,

    For Starters i'm using Dev-cpp.

    I can get the manifest file to work the only problem is that the manifest all ways has to be in teh diretory with the program is there away to make the manifest say become a resourse in the project its self thus being able to chaneg directorys?

    Thanks.

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