[RESOLVED] [C++] Win32 API Using Themes
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 10 of 10

Thread: [RESOLVED] [C++] Win32 API Using Themes

  1. #1
    Join Date
    Feb 2011
    Posts
    20

    [RESOLVED] [C++] Win32 API Using Themes

    How do I use themes with win32? I tried doing some research on the matter, and found that supposedly, if I add:

    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="[ProgramName]"
        type="win32"
    />
    <description>Checks to see whether a message will fit on a chageable sign</description>
    <dependency>
        <dependentAssembly>
            <assemblyIdentity
                type="win32"
                name="Microsoft.Windows.Common-Controls"
                version="6.0.0.0"
                processorArchitecture="X86"
                publicKeyToken="6595b64144ccf1df"
                language="*"
            />
        </dependentAssembly>
    </dependency>
    </assembly>
    And

    Code:
    CREATEPROCESS_MANIFEST_RESOURCE_ID RT_MANIFEST "[ProgramName].manifest"
    into my program, then it should make the themes work. However, it did not work for me, and if I don't comment out the CREATEPROCESS line, then I get errors in the program.

    Can anybody point me in the right direction to getting this to work?

    Thanks!

  2. #2
    Join Date
    Feb 2011
    Posts
    20

    Re: [C++] Win32 API Using Themes

    Edit:
    I updated my code to this:

    Code:
    /*.h file*/
    #pragma comment(linker,"\"/manifestdependency:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")
    
    /*RC file*/
    #ifndef CREATEPROCESS_MANIFEST_RESOURCE_ID RT_MANIFEST "[Program Name].manifest"
    #define CREATEPROCESS_MANIFEST_RESOURCE_ID RT_MANIFEST "[Program Name].manifest"
    #endif
    This gets rid of the errors, however, I now find that when I run it, I still get those "errors" which upon closer consideration, is basically anything that would use the theme. (Static, and editboxes)

    I even commented out the part from the resource file, and just with the #pragma code, I still get that issue.

  3. #3
    Join Date
    Nov 2003
    Location
    Belgium
    Posts
    8,062

    Re: [C++] Win32 API Using Themes

    Your #pragma is not entirely correct, try:
    Code:
    #pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'\"")
    Also, an MFC application uses the following code to initialize themes, try if that works for you.
    Code:
    	// InitCommonControlsEx() is required on Windows XP if an application
    	// manifest specifies use of ComCtl32.dll version 6 or later to enable
    	// visual styles.  Otherwise, any window creation will fail.
    	INITCOMMONCONTROLSEX InitCtrls;
    	InitCtrls.dwSize = sizeof(InitCtrls);
    	// Set this to include all the common control classes you want to use
    	// in your application.
    	InitCtrls.dwICC = ICC_WIN95_CLASSES;
    	InitCommonControlsEx(&InitCtrls);

  4. #4
    Join Date
    Feb 2011
    Posts
    20

    Re: [C++] Win32 API Using Themes

    That line was copied directly from MSDN. However, all the asterisk does it targets all processors rather than just X86 processors.

    And I'd like to know how to do it without MFC, that's why I posted in the non-MFC forum.

  5. #5
    Join Date
    Nov 2003
    Location
    Belgium
    Posts
    8,062

    Re: [C++] Win32 API Using Themes

    I know you are not using MFC, but that code I posted is pure Win32 code, so you can just copy/paste that into your project. I was just saying that's how MFC is doing it

  6. #6
    Join Date
    Feb 2011
    Posts
    20

    Re: [C++] Win32 API Using Themes

    Then where do I put it? Before any new windows, after new windows, run them once at the beginning of the program and I'm done...?

  7. #7
    Join Date
    Nov 2003
    Location
    Belgium
    Posts
    8,062

    Re: [C++] Win32 API Using Themes

    That initilization should be done once, at the beginngin of the program.

  8. #8
    Join Date
    Feb 2011
    Posts
    20

    Re: [C++] Win32 API Using Themes

    It's not working. When I have the line InitCommonControlsEx(&InitCtrls); I get:
    error LNK2019: unresolved external symbol __imp__InitCommonControlsEx@4 referenced in function _WinMain@16
    Yes, I have the right header.

  9. #9
    Join Date
    Nov 2003
    Location
    Belgium
    Posts
    8,062

    Re: [C++] Win32 API Using Themes

    Are you linking with Comctl32.lib?

  10. #10
    Join Date
    Feb 2011
    Posts
    20

    Re: [C++] Win32 API Using Themes

    That did it. I guess I should have read both documentations.

    Thanks for all the help!

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center