changeset 106:e4a62cdcd2e0

Added code that creates a manifest file in the temp directory and loads it to force Windows XP themes
author Jacob Carlborg <doobnet@gmail.com> <jacob.carlborg@gmail.com>
date Mon, 11 Feb 2008 00:56:33 +0100
parents 127fb6e60c53
children a378481be65f 6f75fdfa1bcd
files dwt/internal/win32/OS.d
diffstat 1 files changed, 60 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/dwt/internal/win32/OS.d	Sun Feb 10 21:46:54 2008 +0100
+++ b/dwt/internal/win32/OS.d	Mon Feb 11 00:56:33 2008 +0100
@@ -21,6 +21,14 @@
 import tango.sys.SharedLib : SharedLib;
 static import tango.stdc.stdlib;
 
+import tango.stdc.string : memset;
+import tango.stdc.stringz : toString16z;
+import tango.text.convert.Utf : toString16;
+import tango.io.FilePath;
+static import tango.io.TempFile;
+import tango.io.File;
+
+
 import tango.util.log.Trace;
 void trace(int line ){
     //Trace.formatln( "OS {}", line );
@@ -253,8 +261,57 @@
         //PORTING_CHANGE: made by version
         //IsUnicode = !IsWin32s && !IsWin95;
         /* Load the manifest to force the XP Theme */
-        //if (System.getProperty (NO_MANIFEST) is null) {
-            if (!OS.IsWinCE && OS.WIN32_VERSION >= OS.VERSION (5, 1)) {
+
+		ULONG_PTR ulpActivationCookie;
+		ACTCTX actctx;
+		HANDLE hActCtx = INVALID_HANDLE_VALUE;
+		DWORD dwLastError;
+		
+		tango.io.TempFile.TempFile.Style style = {tango.io.TempFile.TempFile.Transience.Transient};
+		
+		scope File file;
+		scope temp = new tango.io.TempFile.TempFile(style);
+		scope filePath = temp.path;
+		
+		const char[] filename = "dwt.manifest";
+		const char[] manifest = `<?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="dwt" type="win32"/>
+									<description>D Widget Toolkit</description>
+									<dependency>
+										<dependentAssembly>
+											<assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" processorArchitecture="X86" publicKeyToken="6595b64144ccf1df" language="*"/>
+										</dependentAssembly>
+									</dependency>
+								</assembly>`;
+		
+		filePath.file = filename;
+		
+		if (!filePath.exists)
+		{
+			file = new File(filePath.toString);
+			file.write(manifest);
+		}
+		
+		memset(&actctx, 0, actctx.sizeof);
+		actctx.cbSize = actctx.sizeof;
+		actctx.lpSource = toString16(filePath.toString).toString16z();
+		
+		// Create the activation context, then delete the string - we don't need it
+		// anymore.
+		hActCtx = OS.CreateActCtx(&actctx);
+		
+		// Did we fail creating the activation context?
+		if (hActCtx == INVALID_HANDLE_VALUE)
+			Trace.formatln("The Activation Context could not be created");
+		
+		// Activate the context and make use of it
+		if (!OS.ActivateActCtx(hActCtx, &ulpActivationCookie))
+			Trace.formatln("The Activation Context failed to load");
+
+
+/+         //if (System.getProperty (NO_MANIFEST) is null) {
+           if (!OS.IsWinCE && OS.WIN32_VERSION >= OS.VERSION (5, 1)) {
 trace(__LINE__);
                 TCHAR[] buffer = new TCHAR[ MAX_PATH ];
                 HANDLE hModule = OS.GetLibraryHandle ();
@@ -286,7 +343,7 @@
                 */
             }
         //}
-
++/
         /* Make the process DPI aware for Windows Vista */
         if (OS.WIN32_VERSION >= OS.VERSION (6, 0)) OS.SetProcessDPIAware ();