Skip to content
⌘ NSIS Forum Archive

Aero plug-in

109 posts

Afrow UK#

Aero plug-in



Enables Windows Aero glass effect on NSIS (outer) UI.



Edit: Worth noting this plug-in does nothing on < Vista or when DWM composition (glass) is disabled on installer init. The plug-in handles theme changes once it has been loaded (i.e. reverts to original UI if glass is disabled).

Stu
Anders#
I made a plugin similar to this a while back but I never got around to posting it since I could not find a documented value to use for the text glow size. Did you just make one up or what?

I guess I don't have to complete my version now, thanks Afrow =)
Afrow UK#
Just used 10. You can actually get the glow size from the current theme using another API so I may change it.

I've had a report of the button text being transparent on one or two machines which doesn't seem to happen on any of mine so I might need to fix that soon. When you use the branding text with glow, it has to paint a black brush where the aero is but that results in the button text being transparent too (looks awful) and therefore I've had to do some simple button drawing myself (using WM_PAINTCLIENT). To fix the button text at the moment I'm just using WM_PAINTCLIENT onto the current DC's HBRUSH (this seems to work fine for me - but I don't really know why lol). However, I may have to use double buffering (BeginBufferedPaint) with a portion with full opacity (BufferedPaintSetAlpha) to fix properly. Will post new version today probably. Other option is owner draw the buttons but I want to avoid that. I'd rather let Windows do it for me (WM_PAINTCLIENT).

Stu
Afrow UK#
New version uploaded which uses the glow size for the current theme and fixes the button text transparency bug on some systems.

FYI to get the glow size (12 by default) you use GetThemeInt with TMT_TEXTGLOWSIZE. The theme I used is "CompositedWindow::Window".

Probably worth mentioning also that if you use /nobranding then because the plug-in does not need to draw any glow text, it doesn't need to use a black brush for the aero (I use magic pink instead with SetLayeredWindowAttributes/LWA_COLORKEY). As a result, the buttons are untouched and therefore you get the proper button glow fade in/out on mouse in/out. Owner-drawn or WM_PAINT handled buttons lose this fade in/out unfortunately and there's nothing one can do about it. Even .NET apps loses this effect if you set UseCompatibleTextRendering=true for buttons. The missing effect is not noticeable though (unless you're me lol) so branding text is on by default 🙂.

Stu
Anders#
Is SetLayeredWindowAttributes + DwmExtendFrameIntoClientArea a valid thing to do? IIRC SetLayeredWindowAttributes had problems with the DWM in the early Vista days.


You are using "CompositedWindow::Window" when loading and "Window" in WM_THEMECHANGED, this can't be correct can it?


Also, you are hard-coding a 2px change in what I assume is some sort of button border hack? What about alternative Visual Styles?
Afrow UK#
Originally Posted by Anders View Post
Is SetLayeredWindowAttributes + DwmExtendFrameIntoClientArea a valid thing to do? IIRC SetLayeredWindowAttributes had problems with the DWM in the early Vista days.


You are using "CompositedWindow::Window" when loading and "Window" in WM_THEMECHANGED, this can't be correct can it?


Also, you are hard-coding a 2px change in what I assume is some sort of button border hack? What about alternative Visual Styles?
1. I've tested on Vista and it seems to work OK. Maybe I shouldn't bother though and just go with the black brush method. Both methods are written about by Microsoft developers though IIRC.

2. Well spotted. Will fix.

3. Yes. I'm having to set the inner part of the button to opaque to fix the black->transparent button text. I originally used 4px but 2px seems to be the minimum. I never thought of other themes. Not sure if there is a better way to do this without having to draw the button myself. Any ideas?

Stu
Anders#
In my plugin I use one of the theme api's to calculate the size of the button IIRC

Also, you are destroying windows you don't own, this is not OK IMHO (In my Aero plugin I hide them and if aero is turned off, I display them again, 100% original layout in classic theme...)

As a final note; I don't really think "_WndProc_" is the best prop name to use, it is a bit generic, I'm using "NSIS:P:Aero", feel free to using something similar (or the same, both plugins should not be used at the same time anyway)
Anders#
Originally Posted by Afrow UK View Post
So is that how your plug-in does the buttons too or does it owner-draw them?
I use subclassing and WM_PRINT?CLIENT? like you do, but I use one of the GetThemeBackgroundSomething functions to calculate the area to mask off for the round corners.

I was going to look into adding the animation back but got bored and stopped working on the plugin...
Afrow UK#
Is it GetThemeBackgroundRegion? How would that be used with BufferedPaintSetAlpha which requires a RECT?

Stu
Anders#
I'm thinking it was GetThemeBackgroundContentRect

But you should be able to get a RECT from HRGN also...

Or you can use the HRGN to mask off the HDC...
Afrow UK#
So far so good although I've just remembered why I had to destroy those controls instead of hiding them (at least for MUI). MUI hides/shows them itself when you enter/leave the welcome/finish pages. How did you overcome this or did you not notice this problem?

Stu
Afrow UK#
In response to WM_NOTIFY_OUTER_NEXT? It seems that the show function gets called after that notification and so my attempts fail. Calling the old window procedure first also doesn't seem to work. I guess one option, which would also avoid any potential flickering of the controls being shown/hidden, would be to move them off the UI on plug-in load while saving their original positions...

Stu
Yathosho#
here's what happens when defining MUI_BGCOLOR (mind the background of those buttons)
Afrow UK#
New plug-in version (.2) uploaded. Still waiting for Yathosho to check his button issue is fixed though (but I can't seem to reproduce so perhaps it is fixed).

Fair number of changes/fixes:
1.0.0.2 - 4th May 2011
* Fixed typo Window -> CompositedWindow::Window in WM_THEMECHANGED
(thanks Anders).
* Now uses theme text colour for branding text (but still original
font).
* Improved fall-back drawing if DWM composition is disabled (all drawing
then handled by Windows/NSIS).
* Now re-shows old branding text and horizontal ruler when DWM
composition is disabled.
* Plug-in now loads even if DWM composition is disabled, but could be
enabled.
* Now only handles WM_CTLCOLORBTN for the Back, Next and Cancel buttons.
* Now uses GetThemeBackgroundContentRect to determine the button area
to draw opaque.
Stu

Edit: Oh and I changed the button property names to _StuAeroWndProc_ 🙂
jiake#
I have not used the plugin yet, for I am still using Windows XP.
The problem was found by other person, he lets me to feedback.
Afrow UK#
Currently using MultiByteToWideChar in the ANSI plug-in (DrawThemeTextEx is Unicode only) so this is likely the problem. I will change the code to avoid it when I have time (i.e. call GetWindowTextW).

Stu
Afrow UK#
New version uploaded which should fix your Chinese characters bug (I hope).
1.0.0.3 - 19th May 2011
* Now always uses GetWindowTextW for the branding text (as DrawThemeTextEx is Unicode only).
Stu
Afrow UK#
New version:
* Fixed transparent button text in some situations for Next/Back/Cancel buttons.
http://nsis.sourceforge.net/File:Aero.zip

Stu
Yathosho#
Originally Posted by Afrow UK View Post
* Fixed transparent button text in some situations for Next/Back/Cancel buttons.
did anybody say transparency?
T.Slappy#
@Yathosho: MUI2 contains two dialogs: outer [which is transparent] and inner dialog [that grey area]
There is probably som problem with inner dialog transparency...
Afrow UK#
I'm not sure what you are trying to do but you can't mix Aero with Windows controls without owner drawing them. I had to draw the navigation buttons myself to fix the transparency issue (and it still wasn't perfect until the last release). The problem is that the transparency key is black (and it has to be) and so all black objects (text etc.) will be rendered transparent.

Stu