-
February 11th, 2011, 08:53 PM
#1
[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!
-
February 12th, 2011, 01:22 AM
#2
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.
-
February 12th, 2011, 09:27 AM
#3
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);
-
February 12th, 2011, 10:25 AM
#4
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.
-
February 12th, 2011, 10:26 AM
#5
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
-
February 12th, 2011, 11:05 AM
#6
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...?
-
February 14th, 2011, 07:30 AM
#7
Re: [C++] Win32 API Using Themes
That initilization should be done once, at the beginngin of the program.
-
February 18th, 2011, 06:28 PM
#8
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.
-
February 19th, 2011, 04:06 AM
#9
Re: [C++] Win32 API Using Themes
Are you linking with Comctl32.lib?
-
February 19th, 2011, 11:09 AM
#10
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|