www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Modern Windows GUI visual styles

reply Valery <free_on mail.ru> writes:
Recently I spent a few hours to find a way to enable a new styles of Windows XP
controls from the code (without manual created external manifest files,
resource files, ...). The only solution I found in DFL library and it looks
quite complicated.

Maybe should create that function at the level of the compiler or linker?
Sep 09 2009
next sibling parent reply Jeremie Pelletier <jeremiep gmail.com> writes:
Valery Wrote:

 Recently I spent a few hours to find a way to enable a new styles of Windows
XP controls from the code (without manual created external manifest files,
resource files, ...). The only solution I found in DFL library and it looks
quite complicated.
 
 Maybe should create that function at the level of the compiler or linker?

As far as I know, the only way to get the newer common controls library is to use an assembly manifest, be it external or compiled as a resource. I haven't looked into DFL but I'm pretty sure it simply generates the proper manifest resource and link it in the executable.
Sep 09 2009
next sibling parent reply Valery <free_on mail.ru> writes:
Jeremie Pelletier Wrote:

 As far as I know, the only way to get the newer common controls library is to
use an assembly manifest, be it external or compiled as a resource. I haven't
looked into DFL but I'm pretty sure it simply generates the proper manifest
resource and link it in the executable.

Yes, in DFL creates a manifest file and so on, but it's done at runtime by method enableVisualStyles. I think that there should be a simpler way to enable new styles independent of library or native Win32 API you use.
Sep 09 2009
next sibling parent Valery <free_on mail.ru> writes:
Or at least describe the process of change styles through the manifest files in
the documentation and the section D for Win32 on site.
Sep 09 2009
prev sibling next sibling parent reply Stewart Gordon <smjg_1998 yahoo.com> writes:
Valery wrote:
 Jeremie Pelletier Wrote:
 
 As far as I know, the only way to get the newer common controls 
 library is to use an assembly manifest, be it external or compiled 
 as a resource. I haven't looked into DFL but I'm pretty sure it 
 simply generates the proper manifest resource and link it in the 
 executable.

Yes, in DFL creates a manifest file and so on, but it's done at runtime by method enableVisualStyles. I think that there should be a simpler way to enable new styles independent of library or native Win32 API you use.

Indeed, I'd like to know why M$ decided to bundle two versions of the relevant DLLs and require the programmer to use a manifest in order to access the modern version.
 Or at least describe the process of change styles through the 
 manifest files in the documentation and the section D for Win32 on 
 site.

Indeed, I drove myself mad trying to find out how to make it work, and eventually discovered keeping a .manifest file alongside the .exe. We need more resources (NPI) teaching how to do it the tidier way. Stewart.
Sep 09 2009
next sibling parent reply Roald Ribe <rr.nospam nospam.teikom.no> writes:
Stewart Gordon wrote:
 Indeed, I drove myself mad trying to find out how to make it work, and 
 eventually discovered keeping a .manifest file alongside the .exe.  We 
 need more resources (NPI) teaching how to do it the tidier way.

In your .rc file (which more or less all WIN32 GUI apps needs anyway) write in a line like: CREATEPROCESS_MANIFEST_RESOURCE_ID RT_MANIFEST "manifest.xml" *** In a separate file named: manifest.xml <?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="Microsoft.Windows.Generic" type="win32" /> <description>YourApplication</description> <dependency> <dependentAssembly> <assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" processorArchitecture="X86" publicKeyToken="6595b64144ccf1df" language="*" /> </dependentAssembly> </dependency> </assembly> Also to work, the executable flags of the .exe file has to specifiy NT version 4.0 or higher as a requirement (probably default in most compilers by now.) Roald
Sep 09 2009
parent Stewart Gordon <smjg_1998 yahoo.com> writes:
Roald Ribe wrote:
 Stewart Gordon wrote:
 Indeed, I drove myself mad trying to find out how to make it work, and 
 eventually discovered keeping a .manifest file alongside the .exe.  We 
 need more resources (NPI) teaching how to do it the tidier way.

In your .rc file (which more or less all WIN32 GUI apps needs anyway) write in a line like: CREATEPROCESS_MANIFEST_RESOURCE_ID RT_MANIFEST "manifest.xml"

I take it this hasn't been tried by enough D programmers, given that the DM headers are out of date. One must use the magic numbers directly: 1 24 "manifest.xml" http://stackoverflow.com/questions/1402137 Stewart.
Sep 10 2009
prev sibling parent Kagamin <spam here.lot> writes:
Stewart Gordon Wrote:

 Indeed, I'd like to know why M$ decided to bundle two versions of the 
 relevant DLLs and require the programmer to use a manifest in order to 
 access the modern version.

AFAIK manifest is a solution for the dll hell problem.
Sep 10 2009
prev sibling parent Kagamin <spam here.lot> writes:
Valery Wrote:

 Yes, in DFL creates a manifest file and so on, but it's done at runtime by
method enableVisualStyles.
 I think that there should be a simpler way to enable new styles independent of
library or native Win32 API you use.
 

Sep 10 2009
prev sibling parent "Adam D. Ruppe" <destructionator gmail.com> writes:
On Wed, Sep 09, 2009 at 08:27:56PM +0100, Stewart Gordon wrote:
 Indeed, I'd like to know why M$ decided to bundle two versions of the 
 relevant DLLs and require the programmer to use a manifest in order to 
 access the modern version.

Backward compatibility. Details here: http://blogs.msdn.com/oldnewthing/archive/2008/01/29/7294949.aspx -- Adam D. Ruppe http://arsdnet.net
Sep 09 2009
prev sibling next sibling parent "Robert Jacques" <sandford jhu.edu> writes:
On Wed, 09 Sep 2009 05:19:22 -0400, Valery <free_on mail.ru> wrote:

 Recently I spent a few hours to find a way to enable a new styles of  
 Windows XP controls from the code (without manual created external  
 manifest files, resource files, ...). The only solution I found in DFL  
 library and it looks quite complicated.

 Maybe should create that function at the level of the compiler or linker?

Out of curiosity, why not use DFL? Since then you'd only have to call Application.enableVisualStyles(); I'm pretty sure both QT and GTK (or whatever GUI lib you want to use) also have a nice wrapper for enabling XP styles.
Sep 09 2009
prev sibling next sibling parent Jacob Carlborg <doob me.com> writes:
On 9/9/09 11:19, Valery wrote:
 Recently I spent a few hours to find a way to enable a new styles of Windows
XP controls from the code (without manual created external manifest files,
resource files, ...). The only solution I found in DFL library and it looks
quite complicated.

 Maybe should create that function at the level of the compiler or linker?

There is no good solution for this problem. I was working on this for DWT and you somehow always need to have a manifest file. The problem is that windows doesn't load the correct dll and that's what the manifest file is for. You can look at the bottom of http://hg.dsource.org/projects/dwt-win/file/210994f12c4c/README.txt for a couple of options. If I remember correctly DFL creates a manifest file at runtime and then loads it. /Jacob Carlborg
Sep 09 2009
prev sibling next sibling parent "Eric Suen" <eric.suen.tech gmail.com> writes:
Hi,

Take a look Windows API:  CreateActCtx, ActivateActCtx, DeactivateActCtx and 
ReleaseActCtx and the struct ACTCTX

You still need a manifest file, but that file can generate by program, and 
you can turn on/off the XP theme.

"ACTCTX.lpSource  Null-terminated string specifying the path of the manifest 
file or PE image to be used to create the activation context. If this path 
refers to an EXE or DLL file, the lpResourceName member is required."

The attachment is the cpp code I wrote for Java...

Regards,

Eric Suen

 Recently I spent a few hours to find a way to enable a new styles of 
 Windows XP controls from the code (without manual created external 
 manifest files, resource files, ...). The only solution I found in DFL 
 library and it looks quite complicated.

 Maybe should create that function at the level of the compiler or linker?

Sep 09 2009
prev sibling parent reply Tim M <tim.matthews7 gmail.com> writes:
Valery Wrote:

 Recently I spent a few hours to find a way to enable a new styles of Windows
XP controls from the code (without manual created external manifest files,
resource files, ...). The only solution I found in DFL library and it looks
quite complicated.

Microsoft says to use Application.EnableVisualStyles http://msdn.microsoft.com/en-us/library/system.windows.forms.application.enablevisualstyles.aspx DFL provides a method also called Application.EnableVisualStyles. Looks complicated?
Sep 11 2009
parent reply Daniel Keep <daniel.keep.lists gmail.com> writes:
Tim M wrote:
 Microsoft says to use Application.EnableVisualStyles
http://msdn.microsoft.com/en-us/library/system.windows.forms.application.enablevisualstyles.aspx

Umm... you do realise that's for .NET, right?
Sep 11 2009
parent reply Tim M <tim.matthews7 gmail.com> writes:
Daniel Keep Wrote:

 
 
 Tim M wrote:
 Microsoft says to use Application.EnableVisualStyles
http://msdn.microsoft.com/en-us/library/system.windows.forms.application.enablevisualstyles.aspx

Umm... you do realise that's for .NET, right?

Run it through a debugger and you will probably find that both provide an abstraction over the same complicated win32 api functions.
Sep 12 2009
parent Christopher Wright <dhasenan gmail.com> writes:
Tim M wrote:
 Daniel Keep Wrote:
 
 Tim M wrote:
 Microsoft says to use Application.EnableVisualStyles
http://msdn.microsoft.com/en-us/library/system.windows.forms.application.enablevisualstyles.aspx


Run it through a debugger and you will probably find that both provide an abstraction over the same complicated win32 api functions.

Or look at Mono's implementation. Or use Reflector <http://www.red-gate.com/products/reflector/> -- it's free.
Sep 13 2009