FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Make DWT application to support XP theming

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.     Forum Index -> DWT
View previous topic :: View next topic  
Author Message
Shawn Liu



Joined: 09 Mar 2005
Posts: 104
Location: Shanghai, China

PostPosted: Mon May 23, 2005 9:43 am    Post subject: Make DWT application to support XP theming Reply with quote

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
View user's profile Send private message
Carlos



Joined: 19 Mar 2004
Posts: 396
Location: Canyon, TX

PostPosted: Mon May 23, 2005 10:40 am    Post subject: Reply with quote

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
View user's profile Send private message Yahoo Messenger MSN Messenger
Shawn Liu



Joined: 09 Mar 2005
Posts: 104
Location: Shanghai, China

PostPosted: Tue May 24, 2005 1:14 am    Post subject: Reply with quote

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
View user's profile Send private message
Carlos



Joined: 19 Mar 2004
Posts: 396
Location: Canyon, TX

PostPosted: Wed May 25, 2005 8:10 pm    Post subject: Reply with quote

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
View user's profile Send private message Yahoo Messenger MSN Messenger
zwang



Joined: 14 Sep 2005
Posts: 5
Location: Singapore

PostPosted: Thu Sep 22, 2005 5:11 am    Post subject: Reply with quote

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
View user's profile Send private message
Shawn Liu



Joined: 09 Mar 2005
Posts: 104
Location: Shanghai, China

PostPosted: Sun Nov 13, 2005 12:37 pm    Post subject: Reply with quote

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
View user's profile Send private message
Gertje



Joined: 25 Apr 2005
Posts: 9

PostPosted: Thu Jan 19, 2006 9:14 am    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.     Forum Index -> DWT All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group