# HG changeset patch # User Jacob Carlborg # Date 1202687793 -3600 # Node ID e4a62cdcd2e056316e85d8ea8a411d41d248ddc9 # Parent 127fb6e60c531bf2bc59d89b1f41167d21487257 Added code that creates a manifest file in the temp directory and loads it to force Windows XP themes diff -r 127fb6e60c53 -r e4a62cdcd2e0 dwt/internal/win32/OS.d --- 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 = ` + + + D Widget Toolkit + + + + + + `; + + 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 ();