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
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 "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 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"
<snip> 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.
 
manifest is the simplest way to use styles.
Sep 10 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?
begin 666 spket.cpp M" T*(V1E9FEN92!34$M%5%]&54,H<F,L(&9U;F,I($I.24584$]25"!R8R!* M(%P-"B 871Y<&4 8V%R<F%Y(#T 3E5,3#L 7 T*("!I9B H:F%R<F%Y*2!I M9B H*&-A<G)A>2 ]("AA='EP92D 96YV+3Y'9710<FEM:71I=F5!<G)A>4-R M:71I8V%L*&IA<G)A>2P 2DY)7T9!3%-%*2D /3T 3E5,3"D 9V]T;R!D;VYE M.PT*( T*(V1E9FEN92!214Q%05-%*&IA<G)A>2P 8V%R<F%Y*2!I9B H:F%R M:6-A;"AJ87)R87DL(&-A<G)A>2P 2DY)7T%"3U)4*3L-"B-D969I;F4 4D5, M($)/3TP *$I.24-!3$P *D%C=&EV871E06-T0W1X4')O8RDH2$%.1$Q%+"!5 M3$].1U]05%(J*3L-"G1Y<&5D968 0D]/3" H2DY)0T%,3" J1&5A8W1I=F%T M94%C=$-T>%!R;V,I*$173U)$+"!53$].1U]05%(I.PT*='EP961E9B!V;VED M96YV+"!J8VQA<W,L(&IB;V]L96%N(&ES56YI8V]D92P :FEN=$%R<F%Y(&-T M" DO+TES5&AE;65!8W1I=F4 )B8 27-!<'!4:&5M960 ;F]T('=O<FL 87, M97AP96-T960-" E"3T],(&ES07!P5&AE;65D(#T M3D-%(&-O;6-T3&EB(#T M*&-O;6-T3&EB("$]($Y53$PI('L-" D)1$Q,1T545D524TE/3E!23T, 9&QL M4')O8R ]("A$3$Q'151615)324].4%)/0RD 1V5T4')O8T%D9')E<W,H8V]M M;W)Y*"9V97));F9O+"!S:7IE;V8H=F5R26YF;RDI.PT*"0D)=F5R26YF;RYC M;F9O+F1W36%J;W)697)S:6]N(#X M"7T-" D-" E"3T],(')C(#T M0W1X(#T 3E5,3#L-" D)54Q/3D=?4%12*B!U;'!!8W1I=F%T:6]N0V]O:VEE M(#T 3E5,3#L- M>2 B2V5R;F5L,S(B*3L-" D):68 *&ME<FYE;" ]/2!.54Q,*0T*"0D)<F5T M=7)N($I.25]&04Q313L-" D)"0T*"0EH06-T0W1X(#T ;F5W($A!3D1,13L- M9')E<W,H:V5R;F5L+" B0W)E871E06-T0W1X5R(I.PT*"0D)"6EF("AC<F5A M=$UO9'5L949I;&5.86UE5RAS<&ME=%]H86YD;&4L(&QP1FEL96YA;64L(&QE M;&5N86UE("$](&9I;&5N86UE*0T*"0D)"0D)"61E;&5T95M=(&QP1FEL96YA M"0EL<$9I;&5N86UE(#T M;'!&:6QE;F%M92 ]/2!.54Q,*0T*"0D)"0D)"6)R96%K.PT*"0D)"0E]('=H M"0EA8W1C=' N8V)3:7IE(#T M=' N;'!3;W5R8V4 /2!L<$9I;&5N86UE.PT*"0D)"0D)86-T8W1X+F1W1FQA M86-T8W1X+FQP4F5S;W5R8V5.86UE(#T 34%+14E.5%)%4T]54D-%5RA-04Y) M3" F)B!L<$9I;&5N86UE("$](&9I;&5N86UE*0T*"0D)"0D)9&5L971E6UT M=$-T>$%0<F]C(&-R96%T94%C=$-T>%!R;V, /2 H0W)E871E06-T0W1X05!R M;V,I($=E=%!R;V-!9&1R97-S*&ME<FYE;"P (D-R96%T94%C=$-T>$$B*3L- M5$-46$$ 86-T8W1X.PT*"0D)"0E$5T]21"!L96YG=& /2!-05A?4$%42#L- M"6Y3:7IE(#T 1V5T36]D=6QE1FEL94YA;65!*'-P:V5T7VAA;F1L92P ;'!& M:6QE;F%M92P ;&5N9W1H*3L-" D)"0D)"6EF("AN4VEZ92 \(&QE;F=T:"D- M" D)"0D)"0EB<F5A:SL-" D)"0D)"0T*"0D)"0D);E-I>F4 /2 P.PT*"0D) M6UT ;'!&:6QE;F%M93L-" D)"0D)"0D-" D)"0D)"6QE;F=T:" K/2!-05A? M4$%42#L-" D)"0D)"6QP1FEL96YA;64 /2!N97< 8VAA<EML96YG=&A=.PT* M"0D)"0D):68 *&QP1FEL96YA;64 /3T 3E5,3"D-" D)"0D)"0EB<F5A:SL- M>"DI.PT*"0D)"0D)86-T8W1X+F-B4VEZ92 ]('-I>F5O9BAA8W1C=' I.PT* M"0D)"0D)86-T8W1X+FQP4V]U<F-E(#T ;'!&:6QE;F%M93L-" D)"0D)"6%C M=&-T>"YD=T9L86=S(#T 04-40U187T9,04=?4D533U520T5?3D%-15]604Q) M1#L-" D)"0D)"6%C=&-T>"YL<%)E<V]U<F-E3F%M92 ]($U!2T5)3E1215-/ M86UE("$]($Y53$P )B8 ;'!&:6QE;F%M92 A/2!F:6QE;F%M92D-" D)"0D) M(" J:$%C=$-T>" A/2!)3E9!3$E$7TA!3D1,15]604Q512D >PT*"0D)"7)C M(#T M*&II;G0J+"!C=' L(&-T>$%R<F%Y*0T*"0D)"0D-" D)"0D)8W1X6S!=(#T M<F5I;G1E<G!R971?8V%S=#QJ:6YT/BAH06-T0W1X*3L-" D)"0D)8W1X6S%= M(#T <F5I;G1E<G!R971?8V%S=#QJ:6YT/BAU;'!!8W1I=F%T:6]N0V]O:VEE M87-E06-T0W1X4')O8R!R96QE87-E06-T0W1X4')O8R ]("A296QE87-E06-T M0W1X4')O8RD 1V5T4')O8T%D9')E<W,H:V5R;F5L+" B4F5L96%S94%C=$-T M>"(I.PT*"0D)"0EI9B H<F5L96%S94%C=$-T>%!R;V, (3T 3E5,3"D-" D) M0T4 :V5R;F5L(#T M2$%.1$Q%*B!H06-T0W1X(#T <F5I;G1E<G!R971?8V%S=#Q(04Y$3$4J/BAH M96%S94%C=$-T>%!R;V, (3T 3E5,3"D-" D)"0ER96QE87-E06-T0W1X4')O M(" (" (" (" (" ($173U)$(')E87-O;BP-"B (" (" (" (" M(" (" (" 3%!63TE$(')E<V5R=F5D*0T*>PT*"7-P:V5T7VAA;F1L92 ] M;VP 27-4:&5M95-U<'!O<G0H*0T*>PT*"6EF("AT:&5M95]S=&%T=7, /3T M,"D >PT*"0ET:&5M95]S=&%T=7, /2 Q.PT*"0E(24Y35$%.0T4 =&AE;64 M/2!,;V%D3&EB<F%R>2 B57A4:&5M92(I.PT*"0EI9B H=&AE;64 (3T 3E5, M3"D >PT*"0D)=&AE;65?<W1A='5S(#T ,CL-" D)"49R965,:6)R87)Y*'1H M96UE*3L-" D)?0T*"7T-" D-" ER971U<FX *'1H96UE7W-T871U<R ]/2 R M*3L-"GT-" T*<W1A=&EC(&)O;VP 27-!<'!4:&5M960H*0T*>PT*"6EF(" A M27-4:&5M95-U<'!O<G0H*2D-" D)<F5T=7)N(&9A;'-E.PT*"0D-" E"3T], M(&ES07!P5&AE;65D(#T M3$PI('L-" D)1$Q,1T545D524TE/3E!23T, 9&QL4')O8R ]("A$3$Q'1516 M15)324].4%)/0RD 1V5T4')O8T%D9')E<W,H8V]M8W1,:6(L(")$;&Q'9716 M:7IE;V8H=F5R26YF;RDI.PT*"0D)=F5R26YF;RYC8E-I>F4 /2!S:7IE;V8H M:6]N(#X M<F%R>2 B57A4:&5M92(I.PT*"0D)"6EF("AT:&5M94QI8B A/2!.54Q,*2![ M=&EV95!R;V,I($=E=%!R;V-!9&1R97-S*'1H96UE3&EB+" B27-4:&5M94%C M=&EV92(I.PT*"0D)"0EI9B H86-T4')O8R F)B!A8W10<F]C*"D /3T 5%)5 M12D >PT*"0D)"0D)27-!<'!4:&5M9610<F]C('1H96UE9%!R;V, /2 H27-! M<'!4:&5M9610<F]C*2!'9710<F]C061D<F5S<RAT:&5M94QI8BP (DES07!P M"0D)"6ES07!P5&AE;65D(#T M" D)"0D)1G)E94QI8G)A<GDH=&AE;65,:6(I.PT*"0D)"7T-" D)"7T-" D) M8FQE5&AE;6EN9U!R;V, =&AE;6EN9U!R;V, /2 H16YA8FQE5&AE;6EN9U!R M;V,I($=E=%!R;V-!9&1R97-S*'1H96UE3&EB+" B16YA8FQE5&AE;6EN9R(I M.PT*"0EI9B H=&AE;6EN9U!R;V, (3T 3E5,3"D-" D)"7)C(#T =&AE;6EN ` end
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
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.
Or look at Mono's implementation. Or use Reflector <http://www.red-gate.com/products/reflector/> -- it's free.
Sep 13 2009