View previous topic :: View next topic |
Author |
Message |
Shawn Liu
Joined: 09 Mar 2005 Posts: 104 Location: Shanghai, China
|
Posted: Mon May 23, 2005 9:43 am Post subject: Make DWT application to support XP theming |
|
|
There are two ways to make DWT application to support Windows XP theming. Actually, all the application who use native widgets can satisfy.
1) Make a manifest file located in the same place as the executable. The name of the manifest file must match the name of the executable. e.g. if "app.exe", then "app.exe.manifest".
Here is a sample manifest file to download. http://www.dnaic.com/d/download/controlexample.exe.manifest.
Or copy the content below to make a manifest file.
2) Make the manifest as resource inside the executable. You can do this just like the Microsoft windows Calc.exe does. Use VC++ open the calc.exe (open as resource). You will see the manifest content. Resource ID 24|1 when opened with VC6, RT_MANIFEST|1 when opened with VC7. Make your res file the same like the calc.exe.
Unfortunately, this can't work with ASPACK. The app with a manifest as integrated resource, when packed with ASPACK, is damaged and can't run at all.
Here is the content of manifest exported from calc.exe
Code: | <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity
name="Microsoft.Windows.Shell.calc"
processorArchitecture="x86"
version="5.1.0.0"
type="win32"/>
<description>Windows Shell</description>
<dependency>
<dependentAssembly>
<assemblyIdentity
type="win32"
name="Microsoft.Windows.Common-Controls"
version="6.0.0.0"
processorArchitecture="x86"
publicKeyToken="6595b64144ccf1df"
language="*"
/>
</dependentAssembly>
</dependency>
</assembly>
|
You can use it with nothing changed.
screenshot of controlexemple.exe with XP theming supported.
- Shawn Liu |
|
Back to top |
|
|
Carlos
Joined: 19 Mar 2004 Posts: 396 Location: Canyon, TX
|
Posted: Mon May 23, 2005 10:40 am Post subject: |
|
|
Burton Radons in digc provided support for this. Digc created a .res file (or .rc?) that you could link with your object files and you'd get XP theming. I took that code and modified it to work as a stand-alone exe. I can post the code later if you want or you can take a look at digc and see how it's done. |
|
Back to top |
|
|
Shawn Liu
Joined: 09 Mar 2005 Posts: 104 Location: Shanghai, China
|
Posted: Tue May 24, 2005 1:14 am Post subject: |
|
|
to Carlos:
appreciated!
I mean the second approach is achievable without zip the executable. But the executable may be very large in size.
ASPACK is a tool to zip Win32 executable or DLL. If manisfest is insert to the exe, when it's packed with ASPACK, the file is damaged and can't be recognized by Windows.
I am not clear about your app. Is it an executable compressor or just a tool to integrate manifest? |
|
Back to top |
|
|
Carlos
Joined: 19 Mar 2004 Posts: 396 Location: Canyon, TX
|
Posted: Wed May 25, 2005 8:10 pm Post subject: |
|
|
I have two modules:
resbuild.d:
Code: |
private:
const char [] res =
"\xFF\x18\x00\xFF\x01\x00\x30\x00"
"1234"
`<?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="?EXE?"/>
<description>?DESC?</description>
<dependency>
<dependentAssembly>
<assemblyIdentity
type="win32"
name="Microsoft.Windows.Common-Controls"
version="6.0.0.0"
publicKeyToken="6595b64144ccf1df"
language="*"
processorArchitecture="x86"/>
</dependentAssembly>
</dependency>
</assembly>`;
import std.path;
import std.string;
public:
byte [] resourceFile (char [] exefile, char [] desc)
{
byte [] data = cast(byte []) replace (
replace (res, "?EXE?", addExt(exefile,"exe")), "?DESC?", desc );
int point = 8;
*cast(int *) &data [point] = cast(int) (data.length - (point + 4));
return data;
}
|
main.d:
Code: |
import std.file;
import std.path;
import std.stdio;
import std.string;
import resbuild;
void main (char [][] args)
{
if (args.length == 1)
{
writefln("use: ?s EXE [DESCRIPTION]",args[0]);
return;
}
char [] exe = args[1];
char [] desc;
if (args.length == 2)
desc = "D Program";
else
desc = std.string.join(args[2..args.length]," ");
write (addExt(exe,"res"), resourceFile(exe,desc) );
}
|
The resulting app creates a .res that can be linked in the exe. |
|
Back to top |
|
|
zwang
Joined: 14 Sep 2005 Posts: 5 Location: Singapore
|
Posted: Thu Sep 22, 2005 5:11 am Post subject: |
|
|
To fully support WinXP themes, the following four functions need to be dynamically loaded from uxtheme.dll (if available):
IsAppThemed
OpenThemeData
DrawThemeBackground
CloseThemeData
Details can be found in the source of SWT 3.2. |
|
Back to top |
|
|
Shawn Liu
Joined: 09 Mar 2005 Posts: 104 Location: Shanghai, China
|
Posted: Sun Nov 13, 2005 12:37 pm Post subject: |
|
|
zwang wrote: | To fully support WinXP themes, the following four functions need to be dynamically loaded from uxtheme.dll (if available):
IsAppThemed
OpenThemeData
DrawThemeBackground
CloseThemeData
Details can be found in the source of SWT 3.2. |
Yes. Since uxtheme.dll is not available in Windows 2000, these functions should be implemented as function pointer. And check whether they are available at runtime.
SWT 3.2 has some new feature such as themes, GDI Plus. Keeping watching SWT source code can help us prompt DWT. |
|
Back to top |
|
|
Gertje
Joined: 25 Apr 2005 Posts: 9
|
Posted: Thu Jan 19, 2006 9:14 am Post subject: |
|
|
I found it was not possible to link multiple resource files (maybe I didn't look carefully enough??). Any way I changed Carlos' program a bit: I changed write into append.
Then I created a resource file for my other resources and I ran Carlos' program to append the stuff to my resource file.
Then I linked it all to my program and it appears to work when compressed with Aspack...
Code: | import std.file;
import std.path;
import std.stdio;
import std.string;
import resbuild;
void main (char [][] args)
{
if (args.length < 3)
{
writefln("use: ?s EXE RES [DESCRIPTION]",args[0]);
return;
}
char [] exe = args[1];
char [] res = args[2];
char [] desc;
if (args.length == 3)
desc = "D Program";
else
desc = std.string.join(args[3..args.length]," ");
append (res, resourceFile(exe,desc) );
}
|
|
|
Back to top |
|
|
|